本文整理汇总了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);
}
示例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);
}
示例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));
}
}
示例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));
}
示例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));
}
}
示例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;
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例11: XMLModelExporter
public XMLModelExporter(File file, boolean lazy) {
this(file, Encodings.UTF_8, lazy);
}
示例12: getXMLEncoding
private String getXMLEncoding() {
String configuredEncoding = setup.getEncoding();
return (StringUtil.isEmpty(configuredEncoding) ? Encodings.UTF_8 : configuredEncoding);
}
示例13: CNPJGenerator
public CNPJGenerator(boolean formatted) {
super(LOCAL, Encodings.UTF_8);
this.random = new Random();
this.formatted = formatted;
}
示例14: WebmailDomainGenerator
public WebmailDomainGenerator() {
super("/org/databene/domain/net/webmailDomain.csv", Encodings.UTF_8);
}
示例15: createCSVGenerator
private static LocalCSVGenerator<String> createCSVGenerator(Gender gender, Locale locale) {
return new LocalCSVGenerator<String>(String.class, baseName(gender), locale, ".csv", Encodings.UTF_8);
}