All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sfm.poi.impl.CsvColumnKeyRowKeySourceGetter Maven / Gradle / Ivy

package org.sfm.poi.impl;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.sfm.csv.CsvColumnKey;
import org.sfm.map.context.KeySourceGetter;

import java.sql.SQLException;

public class CsvColumnKeyRowKeySourceGetter implements KeySourceGetter {
    @Override
    public Object getValue(CsvColumnKey key, Row source) throws SQLException {
        final Cell cell = source.getCell(key.getIndex());
        if (cell != null) {
            switch (cell.getCellType()) {
                case Cell.CELL_TYPE_BLANK:
                    return null;
                case Cell.CELL_TYPE_BOOLEAN:
                    return cell.getBooleanCellValue();
                case Cell.CELL_TYPE_NUMERIC:
                    return cell.getNumericCellValue();
                default:
                    return cell.getStringCellValue();
            }
        }
        return null;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy