Search in sources :

Example 1 with Field

use of org.apache.apex.malhar.contrib.parser.DelimitedSchema.Field in project apex-malhar by apache.

the class DelimitedFSLoader method getProcessor.

/**
 * Returns array of cellprocessors, one for each field
 */
private CellProcessor[] getProcessor(List<Field> fields) {
    CellProcessor[] processor = new CellProcessor[fields.size()];
    int fieldCount = 0;
    for (Field field : fields) {
        processor[fieldCount++] = CellProcessorBuilder.getCellProcessor(field.getType(), field.getConstraints());
    }
    return processor;
}
Also used : Field(org.apache.apex.malhar.contrib.parser.DelimitedSchema.Field) CellProcessor(org.supercsv.cellprocessor.ift.CellProcessor)

Example 2 with Field

use of org.apache.apex.malhar.contrib.parser.DelimitedSchema.Field in project apex-malhar by apache.

the class CsvFormatter method getProcessor.

/**
 * Returns array of cellprocessors, one for each field
 */
private CellProcessor[] getProcessor(List<Field> fields) {
    CellProcessor[] processor = new CellProcessor[fields.size()];
    int fieldCount = 0;
    for (Field field : fields) {
        if (field.getType() == FieldType.DATE) {
            String format = field.getConstraints().get(DelimitedSchema.DATE_FORMAT) == null ? null : (String) field.getConstraints().get(DelimitedSchema.DATE_FORMAT);
            processor[fieldCount++] = new Optional(new FmtDate(format == null ? "dd/MM/yyyy" : format));
        } else {
            processor[fieldCount++] = new Optional();
        }
    }
    return processor;
}
Also used : Field(org.apache.apex.malhar.contrib.parser.DelimitedSchema.Field) Optional(org.supercsv.cellprocessor.Optional) CellProcessor(org.supercsv.cellprocessor.ift.CellProcessor) FmtDate(org.supercsv.cellprocessor.FmtDate)

Example 3 with Field

use of org.apache.apex.malhar.contrib.parser.DelimitedSchema.Field in project apex-malhar by apache.

the class CsvParser method getProcessor.

/**
 * Returns array of cellprocessors, one for each field
 */
private CellProcessor[] getProcessor(List<Field> fields) {
    CellProcessor[] processor = new CellProcessor[fields.size()];
    int fieldCount = 0;
    for (Field field : fields) {
        processor[fieldCount++] = CellProcessorBuilder.getCellProcessor(field.getType(), field.getConstraints());
    }
    return processor;
}
Also used : Field(org.apache.apex.malhar.contrib.parser.DelimitedSchema.Field) CellProcessor(org.supercsv.cellprocessor.ift.CellProcessor)

Aggregations

Field (org.apache.apex.malhar.contrib.parser.DelimitedSchema.Field)3 CellProcessor (org.supercsv.cellprocessor.ift.CellProcessor)3 FmtDate (org.supercsv.cellprocessor.FmtDate)1 Optional (org.supercsv.cellprocessor.Optional)1