當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。