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

org.simpleflatmapper.poi.impl.PoiIntegerGetter Maven / Gradle / Ivy

There is a newer version: 9.0.2
Show newest version
package org.simpleflatmapper.poi.impl;


import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.simpleflatmapper.reflect.Getter;
import org.simpleflatmapper.reflect.primitive.IntGetter;

public class PoiIntegerGetter implements Getter, IntGetter {

    private final int index;

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy