com.fasterxml.jackson.dataformat.csv.CsvGenerator Java Examples
The following examples show how to use
com.fasterxml.jackson.dataformat.csv.CsvGenerator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SystemController.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 6 votes |
@RequestMapping( value = { "/uid", "/id" }, method = RequestMethod.GET, produces = { "application/csv" } ) public void getUidCsv( @RequestParam( required = false, defaultValue = "1" ) Integer limit, HttpServletResponse response ) throws IOException, InvalidTypeException { limit = Math.min( limit, 10000 ); CsvGenerator csvGenerator = CSV_FACTORY.createGenerator( response.getOutputStream() ); CsvSchema.Builder schemaBuilder = CsvSchema.builder() .addColumn( "uid" ) .setUseHeader( true ); csvGenerator.setSchema( schemaBuilder.build() ); for ( int i = 0; i < limit; i++ ) { csvGenerator.writeStartObject(); csvGenerator.writeStringField( "uid", CodeGenerator.generateUid() ); csvGenerator.writeEndObject(); } csvGenerator.flush(); }
Example #2
Source File: OffsetSerDe.java From mirus with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static OffsetSerDe csvOffsetSerDe() { CsvMapper csvMapper = new CsvMapper().configure(CsvGenerator.Feature.STRICT_CHECK_FOR_QUOTING, true); CsvSchema schema = csvMapper.schemaFor(OffsetInfo.class).withLineSeparator(""); return new OffsetSerDe( csvMapper.writer(schema), csvMapper.reader(schema).forType(OffsetInfo.class)); }
Example #3
Source File: CsvXContentGenerator.java From elasticsearch-rest-command with The Unlicense | 5 votes |
public CsvXContentGenerator(CsvGenerator generator) { this.generator = generator; if (generator instanceof GeneratorBase) { base = (GeneratorBase) generator; } else { base = null; } }