本文整理汇总了Java中com.fasterxml.jackson.dataformat.csv.CsvMapper.configure方法的典型用法代码示例。如果您正苦于以下问题:Java CsvMapper.configure方法的具体用法?Java CsvMapper.configure怎么用?Java CsvMapper.configure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.dataformat.csv.CsvMapper
的用法示例。
在下文中一共展示了CsvMapper.configure方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRunSorterFirstColumn
import com.fasterxml.jackson.dataformat.csv.CsvMapper; //导入方法依赖的package包/类
@Test
public final void testRunSorterFirstColumn() throws Exception {
CsvFactory csvFactory = new CsvFactory();
csvFactory.enable(CsvParser.Feature.TRIM_SPACES);
// csvFactory.enable(CsvParser.Feature.WRAP_AS_ARRAY);
csvFactory.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
CsvMapper mapper = new CsvMapper(csvFactory);
mapper.enable(CsvParser.Feature.TRIM_SPACES);
// mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY);
mapper.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
// mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY,
// true);
CsvSchema schema = CsvSchema.builder().setUseHeader(false).build();
verifyCSV(testInput1, 1, 2, 4, mapper, schema);
try (Reader inputReader = Files.newBufferedReader(testInput1, StandardCharsets.UTF_8)) {
CSVSorter.runSorter(inputReader, testOutput, 1, schema, CSVSorter.getComparator(0), true);
}
verifyCSV(testOutput, 1, 2, 4, mapper, schema);
}
示例2: testRunSorterSecondColumn
import com.fasterxml.jackson.dataformat.csv.CsvMapper; //导入方法依赖的package包/类
@Test
public final void testRunSorterSecondColumn() throws Exception {
CsvFactory csvFactory = new CsvFactory();
csvFactory.enable(CsvParser.Feature.TRIM_SPACES);
// csvFactory.enable(CsvParser.Feature.WRAP_AS_ARRAY);
csvFactory.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
CsvMapper mapper = new CsvMapper(csvFactory);
mapper.enable(CsvParser.Feature.TRIM_SPACES);
// mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY);
mapper.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
// mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY,
// true);
CsvSchema schema = CsvSchema.builder().setUseHeader(false).build();
verifyCSV(testInput1, 1, 2, 4, mapper, schema);
try (Reader inputReader = Files.newBufferedReader(testInput1, StandardCharsets.UTF_8)) {
CSVSorter.runSorter(inputReader, testOutput, 1, schema, CSVSorter.getComparator(1), true);
}
verifyCSV(testOutput, 1, 2, 4, mapper, schema);
}
示例3: testRunSorterSecondColumnThenFirst
import com.fasterxml.jackson.dataformat.csv.CsvMapper; //导入方法依赖的package包/类
@Test
public final void testRunSorterSecondColumnThenFirst() throws Exception {
CsvFactory csvFactory = new CsvFactory();
csvFactory.enable(CsvParser.Feature.TRIM_SPACES);
// csvFactory.enable(CsvParser.Feature.WRAP_AS_ARRAY);
csvFactory.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
CsvMapper mapper = new CsvMapper(csvFactory);
mapper.enable(CsvParser.Feature.TRIM_SPACES);
// mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY);
mapper.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
// mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY,
// true);
CsvSchema schema = CsvSchema.builder().setUseHeader(false).build();
verifyCSV(testInput3, 1, 2, 5, mapper, schema);
try (Reader inputReader = Files.newBufferedReader(testInput3, StandardCharsets.UTF_8)) {
CSVSorter.runSorter(inputReader, testOutput, 1, schema, CSVSorter.getComparator(1, 0), true);
}
verifyCSV(testOutput, 1, 2, 5, mapper, schema);
}
示例4: testRunSorterFirstColumnThenSecond
import com.fasterxml.jackson.dataformat.csv.CsvMapper; //导入方法依赖的package包/类
@Test
public final void testRunSorterFirstColumnThenSecond() throws Exception {
CsvFactory csvFactory = new CsvFactory();
csvFactory.enable(CsvParser.Feature.TRIM_SPACES);
// csvFactory.enable(CsvParser.Feature.WRAP_AS_ARRAY);
csvFactory.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
CsvMapper mapper = new CsvMapper(csvFactory);
mapper.enable(CsvParser.Feature.TRIM_SPACES);
// mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY);
mapper.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
// mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY,
// true);
CsvSchema schema = CsvSchema.builder().setUseHeader(false).build();
verifyCSV(testInput3, 1, 2, 5, mapper, schema);
try (Reader inputReader = Files.newBufferedReader(testInput3, StandardCharsets.UTF_8)) {
CSVSorter.runSorter(inputReader, testOutput, 1, schema, CSVSorter.getComparator(0, 1), true);
}
verifyCSV(testOutput, 1, 2, 5, mapper, schema);
}
示例5: testRunSorterTSV
import com.fasterxml.jackson.dataformat.csv.CsvMapper; //导入方法依赖的package包/类
@Test
public final void testRunSorterTSV() throws Exception {
CsvFactory csvFactory = new CsvFactory();
csvFactory.enable(CsvParser.Feature.TRIM_SPACES);
// csvFactory.enable(CsvParser.Feature.WRAP_AS_ARRAY);
csvFactory.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
CsvMapper mapper = new CsvMapper(csvFactory);
mapper.enable(CsvParser.Feature.TRIM_SPACES);
// mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY);
mapper.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
// mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY,
// true);
CsvSchema schema = CsvSchema.builder().setUseHeader(false).setColumnSeparator('\t').build();
verifyCSV(testInput4, 1, 2, 5, mapper, schema);
try (Reader inputReader = Files.newBufferedReader(testInput4, StandardCharsets.UTF_8)) {
CSVSorter.runSorter(inputReader, testOutput, 1, schema, CSVSorter.getComparator(0, 1), true);
}
verifyCSV(testOutput, 1, 2, 5, mapper, schema);
}
示例6: testRunSorterTSVMultipleHeaderLines
import com.fasterxml.jackson.dataformat.csv.CsvMapper; //导入方法依赖的package包/类
@Test
public final void testRunSorterTSVMultipleHeaderLines() throws Exception {
CsvFactory csvFactory = new CsvFactory();
csvFactory.enable(CsvParser.Feature.TRIM_SPACES);
// csvFactory.enable(CsvParser.Feature.WRAP_AS_ARRAY);
csvFactory.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
CsvMapper mapper = new CsvMapper(csvFactory);
mapper.enable(CsvParser.Feature.TRIM_SPACES);
// mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY);
mapper.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
// mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY,
// true);
CsvSchema schema = CsvSchema.builder().setUseHeader(false).setColumnSeparator('\t').build();
verifyCSV(testInput5, 10, 2, 5, mapper, schema);
try (Reader inputReader = Files.newBufferedReader(testInput5, StandardCharsets.UTF_8)) {
CSVSorter.runSorter(inputReader, testOutput, 10, schema, CSVSorter.getComparator(0, 1), true);
}
verifyCSV(testOutput, 10, 2, 5, mapper, schema);
}
示例7: main
import com.fasterxml.jackson.dataformat.csv.CsvMapper; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
CsvParam csvParam = new CsvParam();
csvParam.setUp();
CsvMapper csvMapper = new CsvMapper();
csvMapper.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
CsvSchema bootstrapSchema = CsvSchema.emptySchema().withHeader();
try(Reader reader = csvParam.getReader()) {
MappingIterator<City> iterator = csvMapper.readerFor(City.class).with(bootstrapSchema).readValues(reader);
while (iterator.hasNext()) {
System.out.println(iterator.next());
}
}
}
示例8: getSafeSortingMapper
import com.fasterxml.jackson.dataformat.csv.CsvMapper; //导入方法依赖的package包/类
public static CsvMapper getSafeSortingMapper() {
CsvFactory csvFactory = new CsvFactory();
csvFactory.enable(CsvParser.Feature.TRIM_SPACES);
csvFactory.enable(CsvParser.Feature.WRAP_AS_ARRAY);
csvFactory.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
CsvMapper mapper = new CsvMapper(csvFactory);
mapper.enable(CsvParser.Feature.TRIM_SPACES);
mapper.enable(CsvParser.Feature.WRAP_AS_ARRAY);
mapper.configure(JsonParser.Feature.ALLOW_YAML_COMMENTS, true);
// mapper.configure(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY,
// true);
return mapper;
}
示例9: setUp
import com.fasterxml.jackson.dataformat.csv.CsvMapper; //导入方法依赖的package包/类
@Setup
public void setUp() {
csvMapperToStringArray = new CsvMapper();
csvMapperToStringArray.enable(com.fasterxml.jackson.dataformat.csv.CsvParser.Feature.WRAP_AS_ARRAY);
CsvMapper csvMapperToCity = new CsvMapper();
csvMapperToCity.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
CsvSchema bootstrapSchema = CsvSchema.emptySchema().withHeader();
cityReader = csvMapperToCity.readerFor(City.class).with(bootstrapSchema);
}