Search in sources :

Example 6 with Optional

use of org.supercsv.cellprocessor.Optional 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)

Aggregations

Optional (org.supercsv.cellprocessor.Optional)6 CellProcessor (org.supercsv.cellprocessor.ift.CellProcessor)4 InputStreamReader (java.io.InputStreamReader)2 NotNull (org.supercsv.cellprocessor.constraint.NotNull)2 CsvMapReader (org.supercsv.io.CsvMapReader)2 ICsvMapReader (org.supercsv.io.ICsvMapReader)2 AwsAccountDetailDto (com.vmware.photon.controller.model.adapters.aws.dto.AwsAccountDetailDto)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Field (org.apache.apex.malhar.contrib.parser.DelimitedSchema.Field)1 LocalDateTime (org.joda.time.LocalDateTime)1 Language (org.opensextant.data.Language)1 FmtDate (org.supercsv.cellprocessor.FmtDate)1 ParseChar (org.supercsv.cellprocessor.ParseChar)1 ParseDate (org.supercsv.cellprocessor.ParseDate)1 ParseDouble (org.supercsv.cellprocessor.ParseDouble)1 ParseInt (org.supercsv.cellprocessor.ParseInt)1