Search in sources :

Example 1 with BeanWriterProcessor

use of com.univocity.parsers.common.processor.BeanWriterProcessor in project powsybl-core by powsybl.

the class IeeeCdfWriter method writeRecords.

private static <T> void writeRecords(Writer writer, List<T> beans, Class<T> aClass) {
    FixedWidthWriterSettings settings = new FixedWidthWriterSettings();
    settings.setWriteLineSeparatorAfterRecord(true);
    BeanWriterProcessor<T> processor = new BeanWriterProcessor<>(aClass);
    settings.setRowWriterProcessor(processor);
    new FixedWidthWriter(writer, settings).processRecords(beans);
}
Also used : FixedWidthWriterSettings(com.univocity.parsers.fixed.FixedWidthWriterSettings) BeanWriterProcessor(com.univocity.parsers.common.processor.BeanWriterProcessor) FixedWidthWriter(com.univocity.parsers.fixed.FixedWidthWriter)

Example 2 with BeanWriterProcessor

use of com.univocity.parsers.common.processor.BeanWriterProcessor in project powsybl-core by powsybl.

the class AbstractRecordGroup method settingsForCsvWriter.

CsvWriterSettings settingsForCsvWriter(String[] headers, String[] quotedFields, Context context) {
    BeanWriterProcessor<T> processor = new BeanWriterProcessor<>(psseTypeClass());
    CsvWriterSettings settings = new CsvWriterSettings();
    settings.quoteFields(quotedFields);
    settings.setHeaders(headers);
    settings.getFormat().setQuote(context.getFileFormat().getQuote());
    settings.getFormat().setDelimiter(context.getDelimiter());
    settings.setIgnoreLeadingWhitespaces(false);
    settings.setIgnoreTrailingWhitespaces(false);
    settings.setRowWriterProcessor(processor);
    return settings;
}
Also used : LEGACY_TEXT(com.powsybl.psse.model.io.FileFormat.LEGACY_TEXT) BeanWriterProcessor(com.univocity.parsers.common.processor.BeanWriterProcessor) CsvWriterSettings(com.univocity.parsers.csv.CsvWriterSettings)

Aggregations

BeanWriterProcessor (com.univocity.parsers.common.processor.BeanWriterProcessor)2 LEGACY_TEXT (com.powsybl.psse.model.io.FileFormat.LEGACY_TEXT)1 CsvWriterSettings (com.univocity.parsers.csv.CsvWriterSettings)1 FixedWidthWriter (com.univocity.parsers.fixed.FixedWidthWriter)1 FixedWidthWriterSettings (com.univocity.parsers.fixed.FixedWidthWriterSettings)1