Bug 63294 - Add CellType enum variant of FormulaRecord.getCachedResultType()
Summary: Add CellType enum variant of FormulaRecord.getCachedResultType()
Status: NEW
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 4.0.0-FINAL
Hardware: PC Mac OS X 10.1
: P2 enhancement (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-27 18:33 UTC by Shawn Smith
Modified: 2019-03-27 18:33 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shawn Smith 2019-03-27 18:33:18 UTC
CellType.getCode() has been deprecated since POI 3.15.  But it's still used in org.apache.poi.hssf.record.FormulaRecord and OldFormulaRecord:

public final class FormulaRecord extends CellRecord implements Cloneable {
    ...
    public int getCachedResultType() {
        if (specialCachedValue == null) {
            return CellType.NUMERIC.getCode();
        }
        return specialCachedValue.getValueType();
    }
    ...
}

It would be nice to have a variant of the getCachedResultType() method that returns 'CellType' instead of 'int' so I can remove code that calls deprecated 'CellType.forInt(code)'.

For example:

FormulaRecord fr = ...;
//noinspection deprecation
switch (CellType.forInt(fr.getCachedResultType())) {
    case BOOLEAN:
        emit(fr.getCachedBooleanValue(), fr);
        break;
    case NUMERIC:
        emit(getFormattedValue(fr.getValue(), fr), fr);
        break;
    ...
}