package org.simantics.excel.poi.parser; import org.apache.poi.ss.usermodel.Row; public class CellContentDataResolver extends CellStringDataResolver { int column; int element; String separator; boolean cut = true; public CellContentDataResolver(int column, int element, String separator) { super(column); this.column = column; this.element = element; this.separator = separator; } public CellContentDataResolver(int column, int element, String separator, boolean cut) { super(column); this.column = column; this.element = element; this.separator = separator; this.cut = cut; } // @Override // public Double getDouble(Row row) { // String s = getSubString(row); // if (s != null) { // return Double.parseDouble(s); // } // return null; // } @Override public String getValue(Row row) { if (row == null) return null; return getSubString(row); } protected String getSubString(Row row) { String s = getCellStringValue(getCell(row, column)); if (cut) { String vals[] = s.split(separator); if (vals.length > element) { return vals[element]; } } else { int index = -1; for (int i = 0; i < element; i++) { index = s.indexOf(separator,index+1); if (index == -1) return null; } return s.substring(index+1); } return null; } }