org.sfm.poi.impl.PoiLongGetter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of simpleFlatMapper Show documentation
Show all versions of simpleFlatMapper Show documentation
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;
}
}
}