Search in sources :

Example 1 with ParseLong

use of org.supercsv.cellprocessor.ParseLong in project apex-malhar by apache.

the class AbstractCsvParser method initialise.

// Initialise the properties and processors.
public void initialise(String[] properties, CellProcessor[] processors) {
    for (int i = 0; i < getFields().size(); i++) {
        FIELD_TYPE type = getFields().get(i).type;
        properties[i] = getFields().get(i).name;
        if (type == FIELD_TYPE.DOUBLE) {
            processors[i] = new Optional(new ParseDouble());
        } else if (type == FIELD_TYPE.INTEGER) {
            processors[i] = new Optional(new ParseInt());
        } else if (type == FIELD_TYPE.FLOAT) {
            processors[i] = new Optional(new ParseDouble());
        } else if (type == FIELD_TYPE.LONG) {
            processors[i] = new Optional(new ParseLong());
        } else if (type == FIELD_TYPE.SHORT) {
            processors[i] = new Optional(new ParseInt());
        } else if (type == FIELD_TYPE.STRING) {
            processors[i] = new Optional();
        } else if (type == FIELD_TYPE.CHARACTER) {
            processors[i] = new Optional(new ParseChar());
        } else if (type == FIELD_TYPE.BOOLEAN) {
            processors[i] = new Optional(new ParseChar());
        } else if (type == FIELD_TYPE.DATE) {
            processors[i] = new Optional(new ParseDate("dd/MM/yyyy"));
        }
    }
}
Also used : Optional(org.supercsv.cellprocessor.Optional) ParseLong(org.supercsv.cellprocessor.ParseLong) ParseDate(org.supercsv.cellprocessor.ParseDate) ParseDouble(org.supercsv.cellprocessor.ParseDouble) ParseInt(org.supercsv.cellprocessor.ParseInt) ParseChar(org.supercsv.cellprocessor.ParseChar)

Aggregations

Optional (org.supercsv.cellprocessor.Optional)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 ParseLong (org.supercsv.cellprocessor.ParseLong)1