当前位置: 首页>>代码示例>>Java>>正文


Java Encodings类代码示例

本文整理汇总了Java中org.databene.commons.Encodings的典型用法代码示例。如果您正苦于以下问题:Java Encodings类的具体用法?Java Encodings怎么用?Java Encodings使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Encodings类属于org.databene.commons包,在下文中一共展示了Encodings类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: importStates

import org.databene.commons.Encodings; //导入依赖的package包/类
private void importStates() {
      this.states = new OrderedNameMap<State>();
      String filename = "/org/databene/domain/address/state_" + isoCode + ".csv";
      if (!IOUtil.isURIAvailable(filename)) {
      	LOGGER.debug("No states defined for {}", this);
      	return;
      }
ComplexTypeDescriptor stateDescriptor = (ComplexTypeDescriptor) new BeanDescriptorProvider().getTypeDescriptor(State.class.getName());
CSVEntitySource source = new CSVEntitySource(filename, stateDescriptor, Encodings.UTF_8);
source.setContext(new DefaultBeneratorContext());
      DataIterator<Entity> iterator = source.iterator();
      DataContainer<Entity> container = new DataContainer<Entity>();
      while ((container = iterator.next(container)) != null) {
      	Entity entity = container.getData();
      	State state = new State();
      	mapProperty("id", entity, state, true);
      	mapProperty("name", entity, state, true);
      	mapProperty("defaultLanguage", entity, state, false);
      	state.setCountry(this);
      	addState(state);
      }
      IOUtil.close(iterator);
  }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:24,代码来源:Country.java

示例2: testGraph

import org.databene.commons.Encodings; //导入依赖的package包/类
@Test
public void testGraph() throws Exception {
	ComplexTypeDescriptor countryDescriptor = createCountryDescriptor();
	ComplexTypeDescriptor personDescriptor = createPersonDescriptor(countryDescriptor);
	// Define expected countries
	Entity germany = new Entity(countryDescriptor, "isoCode", "DE", "name", "Germany");
	Entity usa = new Entity(countryDescriptor, "isoCode", "US", "name", "USA");
	// Define expected persons
	Entity alice = new Entity(personDescriptor, "name", "Alice", "age", 23, "country", germany);
	Entity bob   = new Entity(personDescriptor, "name", "Bob", "age", 34, "country", usa);
	// iterate CSV file and check iterator output 
	CSVEntityIterator iterator = new CSVEntityIterator(GRAPH_URI, personDescriptor, null, ',', Encodings.UTF_8);
    assertEquals(alice, nextOf(iterator));
    assertEquals(bob, nextOf(iterator));
    assertUnavailable(iterator);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:17,代码来源:CSVEntityIteratorTest.java

示例3: testInlineJavaScript

import org.databene.commons.Encodings; //导入依赖的package包/类
@Test
public void testInlineJavaScript() {
	EvaluateStatement stmt = new EvaluateStatement(
		true,
		constant("message"),
		constant("'Hello World'"),
		null,
		null,
		null,
		null,
		constant("fatal"),
		constant(Encodings.UTF_8),
		constant(false),
		null,
		null);
	stmt.execute(context);
	assertEquals("Hello World", context.get("message"));
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:19,代码来源:EvaluateStatementTest.java

示例4: testUriMapping

import org.databene.commons.Encodings; //导入依赖的package包/类
@Test
public void testUriMapping() {
	EvaluateStatement stmt = new EvaluateStatement(
		true,
		constant("message"),
		null,
		constant("/org/databene/benerator/engine/statement/HelloWorld.js"),
		null,
		null,
		null,
		constant("fatal"),
		constant(Encodings.UTF_8),
		constant(false),
		null,
		null);
	stmt.execute(context);
	assertEquals("Hello World", context.get("message"));
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:19,代码来源:EvaluateStatementTest.java

示例5: testShell

import org.databene.commons.Encodings; //导入依赖的package包/类
@Test
public void testShell() {
	String cmd = "echo 42";
	if (SystemInfo.isWindows())
		cmd = "cmd.exe /C " + cmd;
	EvaluateStatement stmt = new EvaluateStatement(
			true,
			constant("result"),
			constant(cmd),
			null,
			constant("shell"),
			null,
			null,
			constant("fatal"),
			constant(Encodings.UTF_8),
			constant(false),
			null,
			null);
		stmt.execute(context);
		assertEquals(42, context.get("result"));
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:22,代码来源:EvaluateStatementTest.java

示例6: testStorageSystem

import org.databene.commons.Encodings; //导入依赖的package包/类
@Test
public void testStorageSystem() {
	StSys stSys = new StSys();
	Expression<StSys> stSysEx = ExpressionUtil.constant(stSys);
	EvaluateStatement stmt = new EvaluateStatement(
			true,
			constant("message"),
			constant("HelloHi"),
			null,
			null,
			stSysEx,
			null,
			constant("fatal"),
			constant(Encodings.UTF_8),
			constant(false),
			null,
			null);
		stmt.execute(context);
		assertEquals("HelloHi", stSys.execInfo);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:21,代码来源:EvaluateStatementTest.java

示例7: test

import org.databene.commons.Encodings; //导入依赖的package包/类
@Test
public void test() throws ParseException {
	// prepare
    SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy");
    ParseFormatConverter<Date> converter = new ParseFormatConverter<Date>(Date.class, format, false);
    WeightedCSVSampleGenerator<Date> generator = new WeightedCSVSampleGenerator<Date>(
    		Date.class, FILE_PATH, Encodings.UTF_8, converter);
    generator.init(context);
    // run test
    List<Date> expectedDates = CollectionUtil.toList(sdf.parse("01.02.2003"), sdf.parse("02.02.2003"), 
    		sdf.parse("03.02.2003"));
    for (int i = 0; i < 10; i++) {
        Date generatedDate = GeneratorUtil.generateNonNull(generator);
        assertTrue("generated date not in expected value set: " + sdf.format(generatedDate),
                expectedDates.contains(generatedDate));
    }
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:18,代码来源:WeightedCSVSampleGeneratorTest.java

示例8: testEurope

import org.databene.commons.Encodings; //导入依赖的package包/类
@Test
public void testEurope() {
    WeightedDatasetCSVGenerator<String> source = new WeightedDatasetCSVGenerator<String>(
    		String.class, FAMILY_NAME + "_{0}.csv", "europe", REGION, false, Encodings.UTF_8);
    NonNullGenerator<String> generator = WrapperFactory.asNonNullGenerator(source);
    generator.init(context);
    boolean mueller = false; // German name
    boolean garcia = false;  // Spanish name
    for (int i = 0; i < 100000 && (!mueller || !garcia); i++) {
        String name = generator.generate();
        if ("Müller".equals(name))
            mueller = true;
        if ("García".equals(name))
            garcia = true;
    }
    assertTrue(mueller);
    assertTrue(garcia);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:19,代码来源:WeightedDatasetCSVGeneratorTest.java

示例9: dropTables

import org.databene.commons.Encodings; //导入依赖的package包/类
protected void dropTables() throws Exception {
	try {
		connection = DBUtil.connect(ENVIRONMENT, false);
		DBUtil.executeScriptFile(DROP_TABLES_FILE_NAME, Encodings.UTF_8, connection, false, null);
	} finally {
		DBUtil.close(connection);
	}
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:9,代码来源:AbstractModelTest.java

示例10: testRunScript

import org.databene.commons.Encodings; //导入依赖的package包/类
@Test
public void testRunScript() throws Exception {
	Connection connection = HSQLUtil.connectInMemoryDB(getClass().getSimpleName());
	ErrorHandler errorHandler = new ErrorHandler(getClass());
	DBExecutionResult result = DBUtil.executeScriptFile(SCRIPT_FILE, Encodings.ISO_8859_1, connection, true, errorHandler);
	assertTrue(result.changedStructure);
	Object[][] rows = (Object[][]) DBUtil.queryAndSimplify("select * from T1", connection);
	assertEquals(1, rows.length);
	assertTrue(Arrays.equals(ArrayUtil.buildObjectArrayOfType(Object.class, 1, "R&B"), rows[0]));
	int count = (Integer) DBUtil.queryAndSimplify("select count(*) from T1", connection);
	assertEquals(1, count);
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:13,代码来源:DBUtilTest.java

示例11: testWriteDocument

import org.databene.commons.Encodings; //导入依赖的package包/类
@Test
public void testWriteDocument() throws Exception {
    Document doc = XMLUtil.createDocument("root");
    Element root = doc.getDocumentElement();
    root.setAttribute("att", "val");
    Element node = doc.createElement("node");
    root.appendChild(node);
    node.setTextContent("text");
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    content.writeDocument(doc, Encodings.UTF_8, out);
    assertEquals(SIMPLE_XML, new String(out.toByteArray(), Encodings.UTF_8));
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:13,代码来源:XmlContentImplTest.java

示例12: testCreateDocument

import org.databene.commons.Encodings; //导入依赖的package包/类
@Test
public void testCreateDocument() throws Exception {
    Map<String, Object> variables = new HashMap<String, Object>();
    variables.put("attvar", "val");
    variables.put("textvar", "text");
    Document doc = content.createDocument(FTL_TEMPLATE, Encodings.UTF_8, variables);
    verifySimpleDocument(doc);
}
 
开发者ID:AludraTest,项目名称:aludratest,代码行数:9,代码来源:XmlContentImplTest.java

示例13: iterateCsv

import org.databene.commons.Encodings; //导入依赖的package包/类
private static void iterateCsv(GeneratorFactory generatorFactory) {
	Generator<String[]> generator = SourceFactory.createCSVLineGenerator(
			"org/databene/benerator/products.csv", ';', Encodings.UTF_8, true);
	init(generator);
	String[] row;
	while ((row = generateNonNull(generator)) != null) // null signals that the generator is used up
		System.out.println(Arrays.toString(row));
	close(generator);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:10,代码来源:GeneratorFactoryDemo.java

示例14: setCountry

import org.databene.commons.Encodings; //导入依赖的package包/类
private void setCountry(String countryCode) {
try {
       Map<String, String> formats = IOUtil.readProperties("/org/databene/domain/address/postalCodeFormat.properties", Encodings.UTF_8);
       pattern = Pattern.compile(formats.get(countryCode));
      } catch (IOException e) {
       throw new ConfigurationError("Error initializing " + getClass().getSimpleName() + 
       		" with country code '" + countryCode + "'");
      }
  }
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:10,代码来源:PostalCodeValidator.java

示例15: createArtificialNameGenerator

import org.databene.commons.Encodings; //导入依赖的package包/类
private TokenCombiner createArtificialNameGenerator() {
 try {
 	return new TokenCombiner(ORG + "artificialName.csv", false, '-', Encodings.UTF_8, false);
    } catch (Exception e) {
    	LOGGER.info("Cannot create artificial company name generator: " + e.getMessage());
    	return null;
    }
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:9,代码来源:CompanyNameGenerator.java


注:本文中的org.databene.commons.Encodings类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。