View | Details | Raw Unified | Return to bug 61244
Collapse All | Expand All

(-)src/java/org/apache/poi/hssf/usermodel/HSSFCell.java (-17 lines)
Lines 53-59 Link Here
53
import org.apache.poi.ss.util.CellRangeAddress;
53
import org.apache.poi.ss.util.CellRangeAddress;
54
import org.apache.poi.ss.util.CellReference;
54
import org.apache.poi.ss.util.CellReference;
55
import org.apache.poi.ss.util.NumberToTextConverter;
55
import org.apache.poi.ss.util.NumberToTextConverter;
56
import org.apache.poi.util.Internal;
57
import org.apache.poi.util.LocaleUtil;
56
import org.apache.poi.util.LocaleUtil;
58
57
59
/**
58
/**
Lines 1145-1169 Link Here
1145
1144
1146
    /**
1145
    /**
1147
     * Only valid for formula cells
1146
     * Only valid for formula cells
1148
     * 
1149
     * Will return {@link CellType} in a future version of POI.
1150
     * For forwards compatibility, do not hard-code cell type literals in your code.
1151
     * 
1152
     * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
1147
     * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
1153
     *     {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
1148
     *     {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
1154
     * on the cached value of the formula
1149
     * on the cached value of the formula
1155
     * @deprecated 3.15. Will return a {@link CellType} enum in the future.
1156
     */
1157
    @Override
1158
    public int getCachedFormulaResultType() {
1159
        return getCachedFormulaResultTypeEnum().getCode();
1160
    }
1161
1162
    /**
1163
     * Only valid for formula cells
1164
     * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
1165
     *     {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
1166
     * on the cached value of the formula
1167
     * @since POI 3.15 beta 3
1150
     * @since POI 3.15 beta 3
1168
     * Will be deleted when we make the CellType enum transition. See bug 59791.
1151
     * Will be deleted when we make the CellType enum transition. See bug 59791.
1169
     */
1152
     */
(-)src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationCell.java (-11 lines)
Lines 94-110 Link Here
94
		return _cell.getRichStringCellValue().getString();
94
		return _cell.getRichStringCellValue().getString();
95
	}
95
	}
96
	/**
96
	/**
97
	 * Will return {@link CellType} in a future version of POI.
98
	 * For forwards compatibility, do not hard-code cell type literals in your code.
99
	 *
100
	 * @return cell type of cached formula result
101
	 * @deprecated 3.15. Will return a {@link CellType} enum in the future.
102
	 */
103
	@Override
104
	public int getCachedFormulaResultType() {
105
		return _cell.getCachedFormulaResultType();
106
	}
107
	/**
108
	 * @since POI 3.15 beta 3
97
	 * @since POI 3.15 beta 3
109
	 * @deprecated POI 3.15 beta 3.
98
	 * @deprecated POI 3.15 beta 3.
110
	 * Will be deleted when we make the CellType enum transition. See bug 59791.
99
	 * Will be deleted when we make the CellType enum transition. See bug 59791.
(-)src/java/org/apache/poi/ss/formula/BaseFormulaEvaluator.java (-21 lines)
Lines 142-168 Link Here
142
    }
142
    }
143
143
144
    protected abstract CellValue evaluateFormulaCellValue(Cell cell);
144
    protected abstract CellValue evaluateFormulaCellValue(Cell cell);
145
146
    /**
147
     * If cell contains formula, it evaluates the formula, and saves the result of the formula. The
148
     * cell remains as a formula cell. If the cell does not contain formula, this method returns -1
149
     * and leaves the cell unchanged.
150
     *
151
     * Note that the type of the <em>formula result</em> is returned, so you know what kind of
152
     * cached formula result is also stored with  the formula.
153
     * <pre>
154
     * int evaluatedCellType = evaluator.evaluateFormulaCell(cell);
155
     * </pre>
156
     * Be aware that your cell will hold both the formula, and the result. If you want the cell
157
     * replaced with the result of the formula, use {@link #evaluateInCell(org.apache.poi.ss.usermodel.Cell)}
158
     * @param cell The cell to evaluate
159
     * @return -1 for non-formula cells, or the type of the <em>formula result</em>
160
     * @deprecated 3.15. Will return a {@link CellType} enum in the future.
161
     */
162
    @Override
163
    public int evaluateFormulaCell(Cell cell) {
164
        return evaluateFormulaCellEnum(cell).getCode();
165
    }
166
    
145
    
167
    /**
146
    /**
168
     * If cell contains formula, it evaluates the formula,
147
     * If cell contains formula, it evaluates the formula,
(-)src/java/org/apache/poi/ss/formula/EvaluationCell.java (-8 lines)
Lines 58-71 Link Here
58
	int getErrorCellValue();
58
	int getErrorCellValue();
59
59
60
	/**
60
	/**
61
	 * Will return {@link CellType} in a future version of POI.
62
	 * For forwards compatibility, do not hard-code cell type literals in your code.
63
	 *
64
	 * @return cell type of cached formula result
65
	 * @deprecated 3.15. Will return a {@link CellType} enum in the future.
66
	 */
67
	int getCachedFormulaResultType();
68
	/**
69
	 * @since POI 3.15 beta 3
61
	 * @since POI 3.15 beta 3
70
	 * @deprecated POI 3.15 beta 3.
62
	 * @deprecated POI 3.15 beta 3.
71
	 * Will be deleted when we make the CellType enum transition. See bug 59791.
63
	 * Will be deleted when we make the CellType enum transition. See bug 59791.
(-)src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java (-11 lines)
Lines 155-171 Link Here
155
		return _masterCell.getColumnIndex();
155
		return _masterCell.getColumnIndex();
156
	}
156
	}
157
	/**
157
	/**
158
	 * Will return {@link CellType} in a future version of POI.
159
	 * For forwards compatibility, do not hard-code cell type literals in your code.
160
	 *
161
	 * @return cell type of cached formula result
162
	 * @deprecated 3.15. Will return a {@link CellType} enum in the future.
163
	 */
164
	@Override
165
	public int getCachedFormulaResultType() {
166
		return _masterCell.getCachedFormulaResultType();
167
	}
168
	/**
169
	 * @since POI 3.15 beta 3
158
	 * @since POI 3.15 beta 3
170
	 * @deprecated POI 3.15 beta 3.
159
	 * @deprecated POI 3.15 beta 3.
171
	 * Will be deleted when we make the CellType enum transition. See bug 59791.
160
	 * Will be deleted when we make the CellType enum transition. See bug 59791.
(-)src/java/org/apache/poi/ss/usermodel/Cell.java (-14 lines)
Lines 188-207 Link Here
188
     */
188
     */
189
    @Removal(version="4.2")
189
    @Removal(version="4.2")
190
    CellType getCellTypeEnum();
190
    CellType getCellTypeEnum();
191
    
192
    /**
193
     * Only valid for formula cells
194
     * 
195
     * Will return {@link CellType} in a future version of POI.
196
     * For forwards compatibility, do not hard-code cell type literals in your code.
197
     * 
198
     * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
199
     *     {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
200
     * on the cached value of the formula
201
     * @deprecated 3.15. Will return a {@link CellType} enum in the future.
202
     */
203
    @Deprecated
204
    int getCachedFormulaResultType();
205
191
206
    /**
192
    /**
207
     * Only valid for formula cells
193
     * Only valid for formula cells
(-)src/java/org/apache/poi/ss/usermodel/FormulaEvaluator.java (-25 lines)
Lines 77-107 Link Here
77
     * @param cell
77
     * @param cell
78
     */
78
     */
79
    CellValue evaluate(Cell cell);
79
    CellValue evaluate(Cell cell);
80
81
82
    /**
83
     * If cell contains formula, it evaluates the formula,
84
     *  and saves the result of the formula. The cell
85
     *  remains as a formula cell.
86
     * Else if cell does not contain formula, this method leaves
87
     *  the cell unchanged.
88
     * Note that the type of the formula result is returned,
89
     *  so you know what kind of value is also stored with
90
     *  the formula.
91
     * <pre>
92
     * int evaluatedCellType = evaluator.evaluateFormulaCell(cell);
93
     * </pre>
94
     * Be aware that your cell will hold both the formula,
95
     *  and the result. If you want the cell replaced with
96
     *  the result of the formula, use {@link #evaluateInCell(Cell)}
97
     * @param cell The cell to evaluate
98
     * @return The type of the formula result, i.e. -1 if the cell is not a formula, 
99
     *      or one of {@link CellType#NUMERIC}, {@link CellType#STRING},
100
     *      {@link CellType#BOOLEAN}, {@link CellType#ERROR}
101
     *      Note: the cell's type remains as CellType.FORMULA however.
102
     * @deprecated 3.15. Will return a {@link CellType} enum in the future
103
     */
104
    int evaluateFormulaCell(Cell cell);
105
    
80
    
106
    /**
81
    /**
107
     * If cell contains formula, it evaluates the formula,
82
     * If cell contains formula, it evaluates the formula,
(-)src/java/org/apache/poi/ss/util/SheetUtil.java (-6 / +1 lines)
Lines 68-74 Link Here
68
     *
68
     *
69
     *  See Bugzilla #50021
69
     *  See Bugzilla #50021
70
     */
70
     */
71
    private static final FormulaEvaluator dummyEvaluator = new FormulaEvaluator(){
71
    private static final FormulaEvaluator dummyEvaluator = new FormulaEvaluator() {
72
        @Override
72
        @Override
73
        public void clearAllCachedResultValues(){}
73
        public void clearAllCachedResultValues(){}
74
        @Override
74
        @Override
Lines 89-99 Link Here
89
        public void setIgnoreMissingWorkbooks(boolean ignore) {}
89
        public void setIgnoreMissingWorkbooks(boolean ignore) {}
90
        @Override
90
        @Override
91
        public void evaluateAll() {}
91
        public void evaluateAll() {}
92
        @Override
93
        public int evaluateFormulaCell(Cell cell) {
94
            //noinspection deprecation
95
            return cell.getCachedFormulaResultType();
96
        }
97
        /** 
92
        /** 
98
         * @since POI 3.15 beta 3
93
         * @since POI 3.15 beta 3
99
         * @deprecated POI 3.15 beta 3. Will be deleted when we make the CellType enum transition. See bug 59791.
94
         * @deprecated POI 3.15 beta 3. Will be deleted when we make the CellType enum transition. See bug 59791.
(-)src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java (-13 lines)
Lines 175-193 Link Here
175
     * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
175
     * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
176
     *     {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
176
     *     {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
177
     * on the cached value of the formula
177
     * on the cached value of the formula
178
     * @deprecated 3.15. Will return a {@link CellType} enum in the future.
179
     */
180
    @Override
181
    public int getCachedFormulaResultType()
182
    {
183
        return getCachedFormulaResultTypeEnum().getCode();
184
    }
185
186
    /**
187
     * Only valid for formula cells
188
     * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
189
     *     {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
190
     * on the cached value of the formula
191
     * @since POI 3.15 beta 3
178
     * @since POI 3.15 beta 3
192
     * Will be deleted when we make the CellType enum transition. See bug 59791.
179
     * Will be deleted when we make the CellType enum transition. See bug 59791.
193
     */
180
     */
(-)src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationCell.java (-10 lines)
Lines 97-112 Link Here
97
        return _cell.getRichStringCellValue().getString();
97
        return _cell.getRichStringCellValue().getString();
98
    }
98
    }
99
    /**
99
    /**
100
     * Will return {@link CellType} in a future version of POI.
101
     * For forwards compatibility, do not hard-code cell type literals in your code.
102
     *
103
     * @return cell type of cached formula result
104
     */
105
    @Override
106
    public int getCachedFormulaResultType() {
107
        return _cell.getCachedFormulaResultType();
108
    }
109
    /**
110
     * @since POI 3.15 beta 3
100
     * @since POI 3.15 beta 3
111
     * @deprecated POI 3.15 beta 3.
101
     * @deprecated POI 3.15 beta 3.
112
     * Will be deleted when we make the CellType enum transition. See bug 59791.
102
     * Will be deleted when we make the CellType enum transition. See bug 59791.
(-)src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java (-18 lines)
Lines 708-731 Link Here
708
708
709
        return getBaseCellType(true);
709
        return getBaseCellType(true);
710
    }
710
    }
711
712
    /**
713
     * Only valid for formula cells
714
     * 
715
     * Will return {@link CellType} in a future version of POI.
716
     * For forwards compatibility, do not hard-code cell type literals in your code.
717
     * 
718
     * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING},
719
     *     {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending
720
     * on the cached value of the formula
721
     * @deprecated 3.15. Will return a {@link CellType} enum in the future.
722
     */
723
    @Deprecated
724
    @Override
725
    @Removal(version="3.17")
726
    public int getCachedFormulaResultType() {
727
        return getCachedFormulaResultTypeEnum().getCode();
728
    }
729
    
711
    
730
    /**
712
    /**
731
     * Only valid for formula cells
713
     * Only valid for formula cells
(-)src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java (-10 lines)
Lines 98-113 Link Here
98
		return _cell.getRichStringCellValue().getString();
98
		return _cell.getRichStringCellValue().getString();
99
	}
99
	}
100
	/**
100
	/**
101
	 * Will return {@link CellType} in a future version of POI.
102
	 * For forwards compatibility, do not hard-code cell type literals in your code.
103
	 *
104
	 * @return cell type of cached formula result
105
	 */
106
	@Override
107
	public int getCachedFormulaResultType() {
108
		return _cell.getCachedFormulaResultType();
109
	}
110
	/**
111
	 * @since POI 3.15 beta 3
101
	 * @since POI 3.15 beta 3
112
	 * @deprecated POI 3.15 beta 3.
102
	 * @deprecated POI 3.15 beta 3.
113
	 * Will be deleted when we make the CellType enum transition. See bug 59791.
103
	 * Will be deleted when we make the CellType enum transition. See bug 59791.

Return to bug 61244