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

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

Go to download

Java library to map flat record - ResultSet, csv - to java object with minimum configuration and low footprint.

The newest version!
package org.sfm.poi.impl;


import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.sfm.reflect.Getter;
import org.sfm.reflect.primitive.LongGetter;

public class PoiLongGetter implements Getter, LongGetter {

    private final int index;

    public PoiLongGetter(int index) {
        this.index = index;
    }

    @Override
    public Long get(Row target) throws Exception {
        final Cell cell = target.getCell(index);
        if (cell != null) {
            return (long)cell.getNumericCellValue();
        } else {
            return null;
        }
    }

    @Override
    public long getLong(Row target) throws Exception {
        final Cell cell = target.getCell(index);
        if (cell != null) {
            return (long)cell.getNumericCellValue();
        } else {
            return 0;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy