use of org.apache.poi.hssf.record.BoolErrRecord in project poi by apache.
the class HSSFCell method convertCellValueToBoolean.
/**
* Chooses a new boolean value for the cell when its type is changing.<p/>
*
* Usually the caller is calling setCellType() with the intention of calling
* setCellValue(boolean) straight afterwards. This method only exists to give
* the cell a somewhat reasonable value until the setCellValue() call (if at all).
* TODO - perhaps a method like setCellTypeAndValue(int, Object) should be introduced to avoid this
*/
private boolean convertCellValueToBoolean() {
switch(_cellType) {
case BOOLEAN:
return ((BoolErrRecord) _record).getBooleanValue();
case STRING:
int sstIndex = ((LabelSSTRecord) _record).getSSTIndex();
String text = _book.getWorkbook().getSSTString(sstIndex).getString();
return Boolean.valueOf(text).booleanValue();
case NUMERIC:
return ((NumberRecord) _record).getValue() != 0;
case FORMULA:
// use cached formula result if it's the right type:
FormulaRecord fr = ((FormulaRecordAggregate) _record).getFormulaRecord();
checkFormulaCachedValueType(CellType.BOOLEAN, fr);
return fr.getCachedBooleanValue();
// These choices are not well justified.
case ERROR:
case BLANK:
return false;
}
throw new RuntimeException("Unexpected cell type (" + _cellType + ")");
}
Aggregations