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


Java Encodings.UTF_8属性代码示例

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


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

示例1: testEurope

@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,代码行数:18,代码来源:WeightedDatasetCSVGeneratorTest.java

示例2: importStates

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,代码行数:23,代码来源:Country.java

示例3: test

@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,代码行数:17,代码来源:WeightedCSVSampleGeneratorTest.java

示例4: test

@Test
public void test() throws IOException {
    CSVCellIterator iterator = new CSVCellIterator("org/databene/csv/names-abc.csv", ',', Encodings.UTF_8);
    DataContainer<String> container = new DataContainer<String>();
    assertEquals("Alice",  iterator.next(container).getData());
    assertEquals("Bob",    iterator.next(container).getData());
    assertEquals("Charly", iterator.next(container).getData());
    assertNull(iterator.next(container));
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:9,代码来源:CSVCellIteratorTest.java

示例5: testGerman

@Test
public void testGerman() {
    Set<String> deNames = CollectionUtil.toSet("Elise", "Robert", "Karl");
    LocalCSVGenerator<String> deGen = new LocalCSVGenerator<String>(String.class, 
    		CSV_LOCAL_FILENAME, Locale.GERMAN, ".csv", Encodings.UTF_8);
    deGen.init(context);
    for (int i = 0; i < 10; i++) {
        String name = GeneratorUtil.generateNonNull(deGen);
        assertTrue(deNames.contains(name));
    }
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:11,代码来源:LocalCSVGeneratorTest.java

示例6: createArtificialNameGenerator

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,代码行数:8,代码来源:CompanyNameGenerator.java

示例7: testWithHeader

@Test
public void testWithHeader() throws Exception {
	ComplexTypeDescriptor countryDescriptor = createCountryDescriptor();
	ComplexTypeDescriptor personDescriptor = createPersonDescriptor(countryDescriptor);
	CSVEntityIterator iterator = new CSVEntityIterator(PLAIN_URI, personDescriptor, new NoOpConverter<String>(), ',', Encodings.UTF_8);
    assertEquals(new Entity(personDescriptor, "name", "Alice", "age", 23), nextOf(iterator));
    assertEquals(new Entity(personDescriptor, "name", "Bob", "age", 34), nextOf(iterator));
    assertEquals(new Entity(personDescriptor, "name", "Charly", "age", 45), nextOf(iterator));
    assertUnavailable(iterator);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:10,代码来源:CSVEntityIteratorTest.java

示例8: testDE

@Test
public void testDE() {
    WeightedDatasetCSVGenerator<String> source = new WeightedDatasetCSVGenerator<String>(
    		String.class, FAMILY_NAME + "_{0}.csv", "DE", REGION, false, Encodings.UTF_8);
    NonNullGenerator<String> generator = WrapperFactory.asNonNullGenerator(source);
    generator.init(context);
    boolean mueller = false;
    for (int i = 0; i < 1000; i++) {
        if ("Müller".equals(generator.generate()))
            mueller = true;
    }
    assertTrue(mueller);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:13,代码来源:WeightedDatasetCSVGeneratorTest.java

示例9: testReset

@Test
public void testReset() {
	CSVEntitySource source = new CSVEntitySource(PERSON_URI, createPersonDescriptor(), Encodings.UTF_8);
	source.setContext(new DefaultBeneratorContext());
    checkIteration(source.iterator(), "name", "age", false);
    checkIteration(source.iterator(), "name", "age", false);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:7,代码来源:CSVEntitySourceTest.java

示例10: testWithoutHeaders

@Test
public void testWithoutHeaders() {
	CSVEntitySource source = new CSVEntitySource(PERSON_URI_WO_HEADERS, createPersonDescriptor(), Encodings.UTF_8);
	source.setColumns(new String[] { "c1", "c2" });
	source.setContext(new DefaultBeneratorContext());
    checkIteration(source.iterator(), "c1", "c2", false);
    checkIteration(source.iterator(), "c1", "c2", false);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:8,代码来源:CSVEntitySourceTest.java

示例11: XMLModelExporter

public XMLModelExporter(File file, boolean lazy) {
	this(file, Encodings.UTF_8, lazy);
}
 
开发者ID:aravindc,项目名称:jdbacl,代码行数:3,代码来源:XMLModelExporter.java

示例12: getXMLEncoding

private String getXMLEncoding() {
	String configuredEncoding = setup.getEncoding();
	return (StringUtil.isEmpty(configuredEncoding) ? Encodings.UTF_8 : configuredEncoding);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:4,代码来源:ProjectBuilder.java

示例13: CNPJGenerator

public CNPJGenerator(boolean formatted) {
	super(LOCAL, Encodings.UTF_8);
	this.random = new Random();
	this.formatted = formatted;
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:5,代码来源:CNPJGenerator.java

示例14: WebmailDomainGenerator

public WebmailDomainGenerator() {
	super("/org/databene/domain/net/webmailDomain.csv", Encodings.UTF_8);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:3,代码来源:WebmailDomainGenerator.java

示例15: createCSVGenerator

private static LocalCSVGenerator<String> createCSVGenerator(Gender gender, Locale locale) {
 return new LocalCSVGenerator<String>(String.class, baseName(gender), locale, ".csv", Encodings.UTF_8);
}
 
开发者ID:raphaelfeng,项目名称:benerator,代码行数:3,代码来源:NobilityTitleGenerator.java


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