From 5582593ad1f8712c7804e1d83bd5aea836ceb522 Mon Sep 17 00:00:00 2001 From: Javen O'Neal Date: Mon, 4 Jul 2016 11:54:20 +0000 Subject: [PATCH] bug 59791: getCellType and getCachedFormulaResultType should return an integer for backwards compatibility git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751256 13f79535-47bb-0310-9956-ffa450edef68 --- .../usermodel/examples/HSSFReadWrite.java | 2 +- .../apache/poi/hssf/view/SVSheetTable.java | 2 +- .../poi/hssf/view/SVTableCellEditor.java | 2 +- .../poi/hssf/view/SVTableCellRenderer.java | 2 +- .../poi/ss/examples/ExcelComparator.java | 6 +- .../src/org/apache/poi/ss/examples/ToCSV.java | 2 +- .../apache/poi/ss/examples/html/ToHtml.java | 4 +- .../poi/hssf/extractor/ExcelExtractor.java | 8 +- .../apache/poi/hssf/usermodel/HSSFCell.java | 41 +++++++++- .../hssf/usermodel/HSSFEvaluationCell.java | 33 +++++++- .../hssf/usermodel/HSSFFormulaEvaluator.java | 10 +-- .../poi/hssf/usermodel/HSSFOptimiser.java | 2 +- .../apache/poi/hssf/usermodel/HSSFRow.java | 2 +- .../org/apache/poi/ss/format/CellFormat.java | 8 +- .../poi/ss/formula/EvaluationCache.java | 4 +- .../apache/poi/ss/formula/EvaluationCell.java | 24 +++++- .../poi/ss/formula/SheetRefEvaluator.java | 2 +- .../poi/ss/formula/WorkbookEvaluator.java | 8 +- .../eval/forked/ForkedEvaluationCell.java | 47 +++++++++-- .../formula/eval/forked/ForkedEvaluator.java | 4 +- .../org/apache/poi/ss/usermodel/Cell.java | 41 ++++++++-- .../poi/ss/usermodel/DataFormatter.java | 2 +- .../org/apache/poi/ss/util/SheetUtil.java | 6 +- .../apache/poi/ss/util/cellwalk/CellWalk.java | 2 +- .../xssf/extractor/XSSFExcelExtractor.java | 10 +-- .../poi/xssf/extractor/XSSFExportToXml.java | 4 +- .../apache/poi/xssf/streaming/SXSSFCell.java | 66 +++++++++++----- .../xssf/streaming/SXSSFEvaluationCell.java | 33 +++++++- .../xssf/streaming/SXSSFFormulaEvaluator.java | 2 +- .../apache/poi/xssf/streaming/SXSSFRow.java | 2 +- .../poi/xssf/streaming/SheetDataWriter.java | 4 +- .../usermodel/BaseXSSFFormulaEvaluator.java | 8 +- .../apache/poi/xssf/usermodel/XSSFCell.java | 78 +++++++++++++------ .../xssf/usermodel/XSSFEvaluationCell.java | 33 +++++++- .../apache/poi/xssf/usermodel/XSSFRow.java | 6 +- .../usermodel/helpers/XSSFFormulaUtils.java | 2 +- .../poi/xssf/model/TestCalculationChain.java | 6 +- .../usermodel/TestFormulaEvaluatorOnXSSF.java | 8 +- .../TestMultiSheetFormulaEvaluatorOnXSSF.java | 16 ++-- .../poi/xssf/usermodel/TestXSSFBugs.java | 28 +++---- .../poi/xssf/usermodel/TestXSSFCell.java | 24 +++--- .../usermodel/TestXSSFFormulaEvaluation.java | 10 +-- .../xssf/usermodel/TestXSSFFormulaParser.java | 2 +- .../xssf/usermodel/TestXSSFPivotTable.java | 2 +- .../poi/xssf/usermodel/TestXSSFRow.java | 2 +- .../poi/xssf/usermodel/TestXSSFSheet.java | 70 ++++++++--------- .../usermodel/TestXSSFSheetShiftRows.java | 2 +- .../converter/AbstractExcelConverter.java | 4 +- .../hssf/converter/ExcelToFoConverter.java | 8 +- .../hssf/converter/ExcelToHtmlConverter.java | 8 +- .../org/apache/poi/hssf/model/TestRVA.java | 2 +- .../poi/hssf/usermodel/TestBug42464.java | 2 +- .../apache/poi/hssf/usermodel/TestBugs.java | 42 +++++----- .../poi/hssf/usermodel/TestCellStyle.java | 2 +- .../TestExternalReferenceChange.java | 2 +- .../usermodel/TestFormulaEvaluatorBugs.java | 2 +- .../usermodel/TestFormulaEvaluatorDocs.java | 16 ++-- .../poi/hssf/usermodel/TestHSSFCell.java | 2 +- .../hssf/usermodel/TestHSSFDataFormatter.java | 2 +- .../usermodel/TestHSSFFormulaEvaluator.java | 16 ++-- .../poi/hssf/usermodel/TestWorkbook.java | 2 +- .../poi/ss/formula/TestMissingWorkbook.java | 14 ++-- .../poi/ss/formula/TestWorkbookEvaluator.java | 16 ++-- .../poi/ss/formula/atp/TestRandBetween.java | 10 +-- ...TestYearFracCalculatorFromSpreadsheet.java | 2 +- .../eval/TestFormulasFromSpreadsheet.java | 10 +-- .../ss/formula/eval/TestMultiSheetEval.java | 16 ++-- .../BaseTestFunctionsFromSpreadsheet.java | 18 ++--- .../ss/formula/functions/TestCountFuncs.java | 8 +- .../poi/ss/formula/functions/TestNper.java | 4 +- .../ss/usermodel/BaseTestBugzillaIssues.java | 24 +++--- .../apache/poi/ss/usermodel/BaseTestCell.java | 78 +++++++++---------- .../apache/poi/ss/usermodel/BaseTestRow.java | 42 +++++----- .../BaseTestSheetAutosizeColumn.java | 2 +- .../BaseTestSheetUpdateArrayFormulas.java | 32 ++++---- .../apache/poi/ss/util/TestSheetBuilder.java | 8 +- 76 files changed, 661 insertions(+), 415 deletions(-) diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java index 6470fe923b..2f67f7f0e5 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/HSSFReadWrite.java @@ -185,7 +185,7 @@ public final class HSSFReadWrite { HSSFCell cell = row.getCell(c); String value = null; - switch (cell.getCellType()) { + switch (cell.getCellTypeEnum()) { case FORMULA: value = "FORMULA value=" + cell.getCellFormula(); diff --git a/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java b/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java index b33d8cba10..8f95e03fbe 100644 --- a/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java +++ b/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java @@ -142,7 +142,7 @@ public class SVSheetTable extends JTable { HSSFCell cell = (HSSFCell) getValueAt(row, col); String formula = ""; if (cell != null) { - if (cell.getCellType() == CellType.FORMULA) { + if (cell.getCellTypeEnum() == CellType.FORMULA) { formula = cell.getCellFormula(); } else { formula = cell.toString(); diff --git a/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java b/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java index c4a2d1dd08..56d3e58a7d 100644 --- a/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java +++ b/src/examples/src/org/apache/poi/hssf/view/SVTableCellEditor.java @@ -151,7 +151,7 @@ public class SVTableCellEditor extends AbstractCellEditor implements TableCellEd //Set the value that is rendered for the cell - switch (cell.getCellType()) { + switch (cell.getCellTypeEnum()) { case BLANK: editor.setText(""); break; diff --git a/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java b/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java index e77a18196c..6f05b09783 100644 --- a/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java +++ b/src/examples/src/org/apache/poi/hssf/view/SVTableCellRenderer.java @@ -165,7 +165,7 @@ public class SVTableCellRenderer extends JLabel isBorderSet=true; //Set the value that is rendered for the cell - switch (c.getCellType()) { + switch (c.getCellTypeEnum()) { case BLANK: setValue(""); break; diff --git a/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java b/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java index 0a35eaa116..dce4b0196e 100644 --- a/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java +++ b/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java @@ -179,7 +179,7 @@ public class ExcelComparator { private void compareDataInCell(Locator loc1, Locator loc2) { if (isCellTypeMatches(loc1, loc2)) { - final CellType loc1cellType = loc1.cell.getCellType(); + final CellType loc1cellType = loc1.cell.getCellTypeEnum(); switch(loc1cellType) { case BLANK: case STRING: @@ -581,8 +581,8 @@ public class ExcelComparator { * Checks if cell type matches. */ private boolean isCellTypeMatches(Locator loc1, Locator loc2) { - CellType type1 = loc1.cell.getCellType(); - CellType type2 = loc2.cell.getCellType(); + CellType type1 = loc1.cell.getCellTypeEnum(); + CellType type2 = loc2.cell.getCellTypeEnum(); if (type1 == type2) return true; addMessage(loc1, loc2, "Cell Data-Type does not Match in :: ", diff --git a/src/examples/src/org/apache/poi/ss/examples/ToCSV.java b/src/examples/src/org/apache/poi/ss/examples/ToCSV.java index 616f838706..e8bca901f8 100644 --- a/src/examples/src/org/apache/poi/ss/examples/ToCSV.java +++ b/src/examples/src/org/apache/poi/ss/examples/ToCSV.java @@ -542,7 +542,7 @@ public class ToCSV { csvLine.add(""); } else { - if(cell.getCellType() != CellType.FORMULA) { + if(cell.getCellTypeEnum() != CellType.FORMULA) { csvLine.add(this.formatter.formatCellValue(cell)); } else { diff --git a/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java b/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java index 3f2ef7ea09..59cf4180f1 100644 --- a/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java +++ b/src/examples/src/org/apache/poi/ss/examples/html/ToHtml.java @@ -336,9 +336,9 @@ public class ToHtml { } private static CellType ultimateCellType(Cell c) { - CellType type = c.getCellType(); + CellType type = c.getCellTypeEnum(); if (type == CellType.FORMULA) - type = c.getCachedFormulaResultType(); + type = c.getCachedFormulaResultTypeEnum(); return type; } diff --git a/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java b/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java index 09ecb8322d..c4eb047312 100644 --- a/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java +++ b/src/java/org/apache/poi/hssf/extractor/ExcelExtractor.java @@ -321,7 +321,7 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p // Only output if requested outputContents = _includeBlankCells; } else { - switch(cell.getCellType()) { + switch(cell.getCellTypeEnum()) { case STRING: text.append(cell.getRichStringCellValue().getString()); break; @@ -338,7 +338,7 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p if(!_shouldEvaluateFormulas) { text.append(cell.getCellFormula()); } else { - switch(cell.getCachedFormulaResultType()) { + switch(cell.getCachedFormulaResultTypeEnum()) { case STRING: HSSFRichTextString str = cell.getRichStringCellValue(); if(str != null && str.length() > 0) { @@ -359,13 +359,13 @@ public class ExcelExtractor extends POIOLE2TextExtractor implements org.apache.p text.append(ErrorEval.getText(cell.getErrorCellValue())); break; default: - throw new IllegalStateException("Unexpected cell cached formula result type: " + cell.getCachedFormulaResultType()); + throw new IllegalStateException("Unexpected cell cached formula result type: " + cell.getCachedFormulaResultTypeEnum()); } } break; default: - throw new RuntimeException("Unexpected cell type (" + cell.getCellType() + ")"); + throw new RuntimeException("Unexpected cell type (" + cell.getCellTypeEnum() + ")"); } // Output the comment, if requested and exists diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java index 003a93ae1c..314612fa68 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java @@ -53,6 +53,7 @@ import org.apache.poi.ss.util.CellAddress; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellReference; import org.apache.poi.ss.util.NumberToTextConverter; +import org.apache.poi.util.Internal; import org.apache.poi.util.LocaleUtil; /** @@ -442,9 +443,23 @@ public class HSSFCell implements Cell { /** * get the cells type (numeric, formula or string) + * + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + */ + @Override + public int getCellType() + { + return getCellTypeEnum().getCode(); + } + + /** + * get the cells type (numeric, formula or string) + * @deprecated POI 3.15 beta 3 */ + @Internal @Override - public CellType getCellType() + public CellType getCellTypeEnum() { return _cellType; } @@ -995,7 +1010,7 @@ public class HSSFCell implements Cell { * Errors are displayed as #ERR<errIdx> */ public String toString() { - switch (getCellType()) { + switch (getCellTypeEnum()) { case BLANK: return ""; case BOOLEAN: @@ -1015,7 +1030,7 @@ public class HSSFCell implements Cell { case STRING: return getStringCellValue(); default: - return "Unknown Cell Type: " + getCellType(); + return "Unknown Cell Type: " + getCellTypeEnum(); } } @@ -1128,13 +1143,31 @@ public class HSSFCell implements Cell { } } + /** + * Only valid for formula cells + * + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + * + * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING}, + * {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending + * on the cached value of the formula + */ + @Override + public int getCachedFormulaResultType() { + return getCachedFormulaResultTypeEnum().getCode(); + } + /** * Only valid for formula cells * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING}, * {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending * on the cached value of the formula + * @deprecated POI 3.15 beta 3 */ - public CellType getCachedFormulaResultType() { + @Internal + @Override + public CellType getCachedFormulaResultTypeEnum() { if (_cellType != CellType.FORMULA) { throw new IllegalStateException("Only formula cells have cached results"); } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationCell.java b/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationCell.java index dc51b7d9e4..6cb3f2b6f4 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationCell.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFEvaluationCell.java @@ -20,6 +20,7 @@ package org.apache.poi.hssf.usermodel; import org.apache.poi.ss.formula.EvaluationCell; import org.apache.poi.ss.formula.EvaluationSheet; import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.util.Internal; /** * HSSF wrapper for a cell under evaluation */ @@ -49,10 +50,22 @@ final class HSSFEvaluationCell implements EvaluationCell { public boolean getBooleanCellValue() { return _cell.getBooleanCellValue(); } + /** + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + * + * @return cell type + */ @Override - public CellType getCellType() { + public int getCellType() { return _cell.getCellType(); } + /** @deprecated POI 3.15 beta 3 */ + @Internal + @Override + public CellType getCellTypeEnum() { + return _cell.getCellTypeEnum(); + } @Override public int getColumnIndex() { return _cell.getColumnIndex(); @@ -76,9 +89,21 @@ final class HSSFEvaluationCell implements EvaluationCell { @Override public String getStringCellValue() { return _cell.getRichStringCellValue().getString(); - } + } + /** + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + * + * @return cell type of cached formula result + */ + @Override + public int getCachedFormulaResultType() { + return _cell.getCachedFormulaResultType(); + } + /** @deprecated POI 3.15 beta 3 */ + @Internal @Override - public CellType getCachedFormulaResultType() { - return _cell.getCachedFormulaResultType(); + public CellType getCachedFormulaResultTypeEnum() { + return _cell.getCachedFormulaResultTypeEnum(); } } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java b/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java index 6582c3810c..7aa8f892ba 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java @@ -177,7 +177,7 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator return null; } - switch (cell.getCellType()) { + switch (cell.getCellTypeEnum()) { case BOOLEAN: return CellValue.valueOf(cell.getBooleanCellValue()); case ERROR: @@ -191,7 +191,7 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator case BLANK: return null; default: - throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")"); + throw new IllegalStateException("Bad cell type (" + cell.getCellTypeEnum() + ")"); } } @@ -214,7 +214,7 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator */ @Override public CellType evaluateFormulaCell(Cell cell) { - if (cell == null || cell.getCellType() != CellType.FORMULA) { + if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) { return CellType._UNINITIALIZED; } CellValue cv = evaluateFormulaCellValue(cell); @@ -244,7 +244,7 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator return null; } HSSFCell result = (HSSFCell) cell; - if (cell.getCellType() == CellType.FORMULA) { + if (cell.getCellTypeEnum() == CellType.FORMULA) { CellValue cv = evaluateFormulaCellValue(cell); setCellValue(cell, cv); setCellType(cell, cv); // cell will no longer be a formula cell @@ -330,7 +330,7 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator for(Row r : sheet) { for (Cell c : r) { - if (c.getCellType() == CellType.FORMULA) { + if (c.getCellTypeEnum() == CellType.FORMULA) { evaluator.evaluateFormulaCell(c); } } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java b/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java index 347300d5f4..d28b7fd7ea 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java @@ -142,7 +142,7 @@ public class HSSFOptimiser { HSSFSheet s = workbook.getSheetAt(sheetNum); for (Row row : s) { for (Cell cell : row) { - if(cell.getCellType() == CellType.STRING) { + if(cell.getCellTypeEnum() == CellType.STRING) { HSSFRichTextString rtr = (HSSFRichTextString)cell.getRichStringCellValue(); UnicodeString u = rtr.getRawUnicodeString(); diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java index f67de61271..427779d2f4 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java @@ -388,7 +388,7 @@ public final class HSSFRow implements Row, Comparable { case RETURN_NULL_AND_BLANK: return cell; case RETURN_BLANK_AS_NULL: - boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK); + boolean isBlank = (cell != null && cell.getCellTypeEnum() == CellType.BLANK); return (isBlank) ? null : cell; case CREATE_NULL_AS_BLANK: return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell; diff --git a/src/java/org/apache/poi/ss/format/CellFormat.java b/src/java/org/apache/poi/ss/format/CellFormat.java index 5775fd3b2e..d284f46e21 100644 --- a/src/java/org/apache/poi/ss/format/CellFormat.java +++ b/src/java/org/apache/poi/ss/format/CellFormat.java @@ -411,17 +411,17 @@ public class CellFormat { /** * Returns the ultimate cell type, following the results of formulas. If * the cell is a {@link CellType#FORMULA}, this returns the result of - * {@link Cell#getCachedFormulaResultType()}. Otherwise this returns the - * result of {@link Cell#getCellType()}. + * {@link Cell#getCachedFormulaResultTypeEnum()}. Otherwise this returns the + * result of {@link Cell#getCellTypeEnum()}. * * @param cell The cell. * * @return The ultimate type of this cell. */ public static CellType ultimateType(Cell cell) { - CellType type = cell.getCellType(); + CellType type = cell.getCellTypeEnum(); if (type == CellType.FORMULA) - return cell.getCachedFormulaResultType(); + return cell.getCachedFormulaResultTypeEnum(); else return type; } diff --git a/src/java/org/apache/poi/ss/formula/EvaluationCache.java b/src/java/org/apache/poi/ss/formula/EvaluationCache.java index ff655f36bb..cd68db3977 100644 --- a/src/java/org/apache/poi/ss/formula/EvaluationCache.java +++ b/src/java/org/apache/poi/ss/formula/EvaluationCache.java @@ -56,7 +56,7 @@ final class EvaluationCache { Loc loc = new Loc(bookIndex, sheetIndex, rowIndex, columnIndex); PlainValueCellCacheEntry pcce = _plainCellCache.get(loc); - if (cell.getCellType() == CellType.FORMULA) { + if (cell.getCellTypeEnum() == CellType.FORMULA) { if (fcce == null) { fcce = new FormulaCellCacheEntry(); if (pcce == null) { @@ -197,7 +197,7 @@ final class EvaluationCache { } public void notifyDeleteCell(int bookIndex, int sheetIndex, EvaluationCell cell) { - if (cell.getCellType() == CellType.FORMULA) { + if (cell.getCellTypeEnum() == CellType.FORMULA) { FormulaCellCacheEntry fcce = _formulaCellCache.remove(cell); if (fcce == null) { // formula cell has not been evaluated yet diff --git a/src/java/org/apache/poi/ss/formula/EvaluationCell.java b/src/java/org/apache/poi/ss/formula/EvaluationCell.java index b5a051fec0..e4378a4df0 100644 --- a/src/java/org/apache/poi/ss/formula/EvaluationCell.java +++ b/src/java/org/apache/poi/ss/formula/EvaluationCell.java @@ -30,19 +30,35 @@ import org.apache.poi.ss.usermodel.CellType; public interface EvaluationCell { /** * @return an Object that identifies the underlying cell, - * suitable for use as a key in a {@link java.util.HashMap} + * suitable for use as a key in a {@link java.util.HashMap} */ Object getIdentityKey(); EvaluationSheet getSheet(); int getRowIndex(); int getColumnIndex(); - CellType getCellType(); + /** + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + * + * @return cell type + */ + int getCellType(); + /** @deprecated POI 3.15 beta 3 */ + CellType getCellTypeEnum(); double getNumericCellValue(); String getStringCellValue(); boolean getBooleanCellValue(); int getErrorCellValue(); - - CellType getCachedFormulaResultType(); + + /** + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + * + * @return cell type of cached formula result + */ + int getCachedFormulaResultType(); + /** @deprecated POI 3.15 beta 3 */ + CellType getCachedFormulaResultTypeEnum(); } diff --git a/src/java/org/apache/poi/ss/formula/SheetRefEvaluator.java b/src/java/org/apache/poi/ss/formula/SheetRefEvaluator.java index c9b408fa51..cc27e66c48 100644 --- a/src/java/org/apache/poi/ss/formula/SheetRefEvaluator.java +++ b/src/java/org/apache/poi/ss/formula/SheetRefEvaluator.java @@ -62,7 +62,7 @@ final class SheetRefEvaluator { public boolean isSubTotal(int rowIndex, int columnIndex){ boolean subtotal = false; EvaluationCell cell = getSheet().getCell(rowIndex, columnIndex); - if(cell != null && cell.getCellType() == CellType.FORMULA){ + if(cell != null && cell.getCellTypeEnum() == CellType.FORMULA){ EvaluationWorkbook wb = _bookEvaluator.getWorkbook(); for(Ptg ptg : wb.getFormulaTokens(cell)){ if(ptg instanceof FuncVarPtg){ diff --git a/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java b/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java index 127fbe520e..d1e7d8b226 100644 --- a/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java +++ b/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java @@ -276,7 +276,7 @@ public final class WorkbookEvaluator { // avoid tracking dependencies to cells that have constant definition boolean shouldCellDependencyBeRecorded = _stabilityClassifier == null ? true : !_stabilityClassifier.isCellFinal(sheetIndex, rowIndex, columnIndex); - if (srcCell == null || srcCell.getCellType() != CellType.FORMULA) { + if (srcCell == null || srcCell.getCellTypeEnum() != CellType.FORMULA) { ValueEval result = getValueFromNonFormulaCell(srcCell); if (shouldCellDependencyBeRecorded) { tracker.acceptPlainValueDependency(_workbookIx, sheetIndex, rowIndex, columnIndex, result); @@ -314,7 +314,7 @@ public final class WorkbookEvaluator { } catch (RuntimeException re) { if (re.getCause() instanceof WorkbookNotFoundException && _ignoreMissingWorkbooks) { logInfo(re.getCause().getMessage() + " - Continuing with cached value!"); - switch(srcCell.getCachedFormulaResultType()) { + switch(srcCell.getCachedFormulaResultTypeEnum()) { case NUMERIC: result = new NumberEval(srcCell.getNumericCellValue()); break; @@ -332,7 +332,7 @@ public final class WorkbookEvaluator { break; case FORMULA: default: - throw new RuntimeException("Unexpected cell type '" + srcCell.getCellType()+"' found!"); + throw new RuntimeException("Unexpected cell type '" + srcCell.getCellTypeEnum()+"' found!"); } } else { throw re; @@ -385,7 +385,7 @@ public final class WorkbookEvaluator { if (cell == null) { return BlankEval.instance; } - CellType cellType = cell.getCellType(); + CellType cellType = cell.getCellTypeEnum(); switch (cellType) { case NUMERIC: return new NumberEval(cell.getNumericCellValue()); diff --git a/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java b/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java index efab4912b0..8149774142 100644 --- a/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java +++ b/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationCell.java @@ -17,16 +17,17 @@ package org.apache.poi.ss.formula.eval.forked; +import org.apache.poi.ss.formula.EvaluationCell; +import org.apache.poi.ss.formula.EvaluationSheet; import org.apache.poi.ss.formula.eval.BlankEval; import org.apache.poi.ss.formula.eval.BoolEval; import org.apache.poi.ss.formula.eval.ErrorEval; import org.apache.poi.ss.formula.eval.NumberEval; import org.apache.poi.ss.formula.eval.StringEval; import org.apache.poi.ss.formula.eval.ValueEval; -import org.apache.poi.ss.formula.EvaluationCell; -import org.apache.poi.ss.formula.EvaluationSheet; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.util.Internal; /** * Represents a cell being used for forked evaluation that has had a value set different from the @@ -52,6 +53,7 @@ final class ForkedEvaluationCell implements EvaluationCell { setValue(BlankEval.instance); // followed by a proper call to setValue() } + @Override public Object getIdentityKey() { return _masterCell.getIdentityKey(); } @@ -101,36 +103,69 @@ final class ForkedEvaluationCell implements EvaluationCell { throw new RuntimeException("Wrong data type (" + _cellType + ")"); } } - public CellType getCellType() { + /** + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + * + * @return cell type + */ + @Override + public int getCellType() { + return _cellType.getCode(); + } + /** @deprecated POI 3.15 beta 3 */ + @Internal + @Override + public CellType getCellTypeEnum() { return _cellType; } + @Override public boolean getBooleanCellValue() { checkCellType(CellType.BOOLEAN); return _booleanValue; } + @Override public int getErrorCellValue() { checkCellType(CellType.ERROR); return _errorValue; } + @Override public double getNumericCellValue() { checkCellType(CellType.NUMERIC); return _numberValue; } + @Override public String getStringCellValue() { checkCellType(CellType.STRING); return _stringValue; } + @Override public EvaluationSheet getSheet() { return _sheet; } + @Override public int getRowIndex() { return _masterCell.getRowIndex(); } + @Override public int getColumnIndex() { return _masterCell.getColumnIndex(); } - public CellType getCachedFormulaResultType() { - return _masterCell.getCachedFormulaResultType(); - } + /** + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + * + * @return cell type of cached formula result + */ + @Override + public int getCachedFormulaResultType() { + return _masterCell.getCachedFormulaResultType(); + } + /** @deprecated POI 3.15 beta 3. */ + @Internal + @Override + public CellType getCachedFormulaResultTypeEnum() { + return _masterCell.getCachedFormulaResultTypeEnum(); + } } diff --git a/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluator.java b/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluator.java index abbf3a3011..c8beb37d1d 100644 --- a/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluator.java +++ b/src/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluator.java @@ -112,7 +112,7 @@ public final class ForkedEvaluator { public ValueEval evaluate(String sheetName, int rowIndex, int columnIndex) { EvaluationCell cell = _sewb.getEvaluationCell(sheetName, rowIndex, columnIndex); - switch (cell.getCellType()) { + switch (cell.getCellTypeEnum()) { case BOOLEAN: return BoolEval.valueOf(cell.getBooleanCellValue()); case ERROR: @@ -126,7 +126,7 @@ public final class ForkedEvaluator { case BLANK: return null; default: - throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")"); + throw new IllegalStateException("Bad cell type (" + cell.getCellTypeEnum() + ")"); } } /** diff --git a/src/java/org/apache/poi/ss/usermodel/Cell.java b/src/java/org/apache/poi/ss/usermodel/Cell.java index 0191b159dd..c6421b3b47 100644 --- a/src/java/org/apache/poi/ss/usermodel/Cell.java +++ b/src/java/org/apache/poi/ss/usermodel/Cell.java @@ -23,6 +23,7 @@ import java.util.Date; import org.apache.poi.ss.formula.FormulaParseException; import org.apache.poi.ss.util.CellAddress; import org.apache.poi.ss.util.CellRangeAddress; +import org.apache.poi.util.Internal; /** * High level representation of a cell in a row of a spreadsheet. @@ -153,18 +154,44 @@ public interface Cell { /** * Return the cell type. + * + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. * * @return the cell type */ - CellType getCellType(); + int getCellType(); + + /** + * Return the cell type. + * + * @return the cell type + * @deprecated POI 3.15 beta 3 + */ + @Internal + CellType getCellTypeEnum(); + + /** + * Only valid for formula cells + * + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + * + * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING}, + * {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending + * on the cached value of the formula + */ + int getCachedFormulaResultType(); /** * Only valid for formula cells * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING}, * {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending * on the cached value of the formula + * @deprecated POI 3.15 beta 3 */ - CellType getCachedFormulaResultType(); + @Internal + CellType getCachedFormulaResultTypeEnum(); /** * Set a numeric value for the cell @@ -248,7 +275,7 @@ public interface Cell { * Return a formula for the cell, for example, SUM(C4:E4) * * @return a formula for the cell - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not {@link CellType#FORMULA} + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not {@link CellType#FORMULA} */ String getCellFormula(); @@ -259,7 +286,7 @@ public interface Cell { * For formulas or error cells we return the precalculated value; *

* @return the value of the cell as a number - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING} + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is {@link CellType#STRING} * @exception NumberFormatException if the cell value isn't a parsable double. * @see DataFormatter for turning this number into a string similar to that which Excel would render this number as. */ @@ -271,7 +298,7 @@ public interface Cell { * For strings we throw an exception. For blank cells we return a null. *

* @return the value of the cell as a date - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING} + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is {@link CellType#STRING} * @exception NumberFormatException if the cell value isn't a parsable double. * @see DataFormatter for formatting this date into a string similar to how excel does. */ @@ -323,7 +350,7 @@ public interface Cell { * For strings, numbers, and errors, we throw an exception. For blank cells we return a false. *

* @return the value of the cell as a boolean - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} * is not {@link CellType#BOOLEAN}, {@link CellType#BLANK} or {@link CellType#FORMULA} */ boolean getBooleanCellValue(); @@ -336,7 +363,7 @@ public interface Cell { *

* * @return the value of the cell as an error code - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't {@link CellType#ERROR} + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't {@link CellType#ERROR} * @see FormulaError for error codes */ byte getErrorCellValue(); diff --git a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java index 225652f852..84f19bfe42 100644 --- a/src/java/org/apache/poi/ss/usermodel/DataFormatter.java +++ b/src/java/org/apache/poi/ss/usermodel/DataFormatter.java @@ -879,7 +879,7 @@ public class DataFormatter implements Observer { return ""; } - CellType cellType = cell.getCellType(); + CellType cellType = cell.getCellTypeEnum(); if (cellType == CellType.FORMULA) { if (evaluator == null) { return cell.getCellFormula(); diff --git a/src/java/org/apache/poi/ss/util/SheetUtil.java b/src/java/org/apache/poi/ss/util/SheetUtil.java index 291ab549e6..2032753a0d 100644 --- a/src/java/org/apache/poi/ss/util/SheetUtil.java +++ b/src/java/org/apache/poi/ss/util/SheetUtil.java @@ -81,7 +81,7 @@ public class SheetUtil { public void evaluateAll() {} public CellType evaluateFormulaCell(Cell cell) { - return cell.getCachedFormulaResultType(); + return cell.getCachedFormulaResultTypeEnum(); } }; @@ -120,11 +120,11 @@ public class SheetUtil { } CellStyle style = cell.getCellStyle(); - CellType cellType = cell.getCellType(); + CellType cellType = cell.getCellTypeEnum(); // for formula cells we compute the cell width for the cached formula result if (cellType == CellType.FORMULA) - cellType = cell.getCachedFormulaResultType(); + cellType = cell.getCachedFormulaResultTypeEnum(); Font font = wb.getFontAt(style.getFontIndex()); diff --git a/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java b/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java index c72048ec26..b6fbbb3ffa 100644 --- a/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java +++ b/src/java/org/apache/poi/ss/util/cellwalk/CellWalk.java @@ -101,7 +101,7 @@ public class CellWalk { } private boolean isEmpty(Cell cell) { - return (cell.getCellType() == CellType.BLANK); + return (cell.getCellTypeEnum() == CellType.BLANK); } /** diff --git a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java index 719dd636e5..192d60d71b 100644 --- a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java +++ b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExcelExtractor.java @@ -162,19 +162,19 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor Cell cell = ri.next(); // Is it a formula one? - if(cell.getCellType() == CellType.FORMULA) { + if(cell.getCellTypeEnum() == CellType.FORMULA) { if (formulasNotResults) { String contents = cell.getCellFormula(); checkMaxTextSize(text, contents); text.append(contents); } else { - if (cell.getCachedFormulaResultType() == CellType.STRING) { + if (cell.getCachedFormulaResultTypeEnum() == CellType.STRING) { handleStringCell(text, cell); } else { handleNonStringCell(text, cell, formatter); } } - } else if(cell.getCellType() == CellType.STRING) { + } else if(cell.getCellTypeEnum() == CellType.STRING) { handleStringCell(text, cell); } else { handleNonStringCell(text, cell, formatter); @@ -236,9 +236,9 @@ public class XSSFExcelExtractor extends POIXMLTextExtractor } private void handleNonStringCell(StringBuffer text, Cell cell, DataFormatter formatter) { - CellType type = cell.getCellType(); + CellType type = cell.getCellTypeEnum(); if (type == CellType.FORMULA) { - type = cell.getCachedFormulaResultType(); + type = cell.getCachedFormulaResultTypeEnum(); } if (type == CellType.NUMERIC) { diff --git a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java index f9d3c876f1..abba81430f 100644 --- a/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java +++ b/src/ooxml/java/org/apache/poi/xssf/extractor/XSSFExportToXml.java @@ -278,13 +278,13 @@ public class XSSFExportToXml implements Comparator{ private void mapCellOnNode(XSSFCell cell, Node node, STXmlDataType.Enum outputDataType) { String value =""; - switch (cell.getCellType()) { + switch (cell.getCellTypeEnum()) { case STRING: value = cell.getStringCellValue(); break; case BOOLEAN: value += cell.getBooleanCellValue(); break; case ERROR: value = cell.getErrorCellString(); break; case FORMULA: - if (cell.getCachedFormulaResultType() == CellType.STRING) { + if (cell.getCachedFormulaResultTypeEnum() == CellType.STRING) { value = cell.getStringCellValue(); } else { if (DateUtil.isCellDateFormatted(cell)) { diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java index 5a6ac555e0..284d85ab86 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java @@ -38,6 +38,7 @@ import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.util.CellAddress; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellReference; +import org.apache.poi.util.Internal; import org.apache.poi.util.LocaleUtil; import org.apache.poi.util.NotImplemented; import org.apache.poi.util.POILogFactory; @@ -150,7 +151,20 @@ public class SXSSFCell implements Cell { * @return the cell type */ @Override - public CellType getCellType() + public int getCellType() + { + return getCellTypeEnum().getCode(); + } + + /** + * Return the cell type. + * + * @return the cell type + * @deprecated POI 3.15 beta 3 + */ + @Internal + @Override + public CellType getCellTypeEnum() { return _value.getType(); } @@ -162,7 +176,21 @@ public class SXSSFCell implements Cell { * on the cached value of the formula */ @Override - public CellType getCachedFormulaResultType() + public int getCachedFormulaResultType() + { + return getCachedFormulaResultTypeEnum().getCode(); + } + + /** + * Only valid for formula cells + * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING}, + * {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending + * on the cached value of the formula + * @deprecated POI 3.15 beta 3. + */ + @Internal + @Override + public CellType getCachedFormulaResultTypeEnum() { if (_value.getType() != CellType.FORMULA) { throw new IllegalStateException("Only formula cells have cached results"); @@ -330,7 +358,7 @@ public class SXSSFCell implements Cell { * Return a formula for the cell, for example, SUM(C4:E4) * * @return a formula for the cell - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not CellType.FORMULA + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not CellType.FORMULA */ @Override public String getCellFormula() @@ -347,14 +375,14 @@ public class SXSSFCell implements Cell { * For formulas or error cells we return the precalculated value; *

* @return the value of the cell as a number - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is CellType.STRING + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is CellType.STRING * @exception NumberFormatException if the cell value isn't a parsable double. * @see org.apache.poi.ss.usermodel.DataFormatter for turning this number into a string similar to that which Excel would render this number as. */ @Override public double getNumericCellValue() { - CellType cellType = getCellType(); + CellType cellType = getCellTypeEnum(); switch(cellType) { case BLANK: @@ -379,14 +407,14 @@ public class SXSSFCell implements Cell { * For strings we throw an exception. For blank cells we return a null. *

* @return the value of the cell as a date - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is CellType.STRING + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is CellType.STRING * @exception NumberFormatException if the cell value isn't a parsable double. * @see org.apache.poi.ss.usermodel.DataFormatter for formatting this date into a string similar to how excel does. */ @Override public Date getDateCellValue() { - CellType cellType = getCellType(); + CellType cellType = getCellTypeEnum(); if (cellType == CellType.BLANK) { return null; @@ -408,8 +436,8 @@ public class SXSSFCell implements Cell { @Override public RichTextString getRichStringCellValue() { - CellType cellType = getCellType(); - if(getCellType() != CellType.STRING) + CellType cellType = getCellTypeEnum(); + if(getCellTypeEnum() != CellType.STRING) throw typeMismatch(CellType.STRING, cellType, false); StringValue sval = (StringValue)_value; @@ -433,7 +461,7 @@ public class SXSSFCell implements Cell { @Override public String getStringCellValue() { - CellType cellType = getCellType(); + CellType cellType = getCellTypeEnum(); switch(cellType) { case BLANK: @@ -499,13 +527,13 @@ public class SXSSFCell implements Cell { * For strings, numbers, and errors, we throw an exception. For blank cells we return a false. *

* @return the value of the cell as a boolean - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} * is not CellType.BOOLEAN, CellType.BLANK or CellType.FORMULA */ @Override public boolean getBooleanCellValue() { - CellType cellType = getCellType(); + CellType cellType = getCellTypeEnum(); switch(cellType) { case BLANK: @@ -534,13 +562,13 @@ public class SXSSFCell implements Cell { *

* * @return the value of the cell as an error code - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't CellType.ERROR + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't CellType.ERROR * @see org.apache.poi.ss.usermodel.FormulaError for error codes */ @Override public byte getErrorCellValue() { - CellType cellType = getCellType(); + CellType cellType = getCellTypeEnum(); switch(cellType) { case BLANK: @@ -714,7 +742,7 @@ public class SXSSFCell implements Cell { */ @Override public String toString() { - switch (getCellType()) { + switch (getCellTypeEnum()) { case BLANK: return ""; case BOOLEAN: @@ -733,7 +761,7 @@ public class SXSSFCell implements Cell { case STRING: return getRichStringCellValue().toString(); default: - return "Unknown Cell Type: " + getCellType(); + return "Unknown Cell Type: " + getCellTypeEnum(); } } @@ -959,10 +987,10 @@ public class SXSSFCell implements Cell { } private boolean convertCellValueToBoolean() { - CellType cellType = getCellType(); + CellType cellType = getCellTypeEnum(); if (cellType == CellType.FORMULA) { - cellType = getCachedFormulaResultType(); + cellType = getCachedFormulaResultTypeEnum(); } switch (cellType) { @@ -982,7 +1010,7 @@ public class SXSSFCell implements Cell { } private String convertCellValueToString() { - CellType cellType = getCellType(); + CellType cellType = getCellTypeEnum(); return convertCellValueToString(cellType); } private String convertCellValueToString(CellType cellType) { diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationCell.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationCell.java index e5e18ceac0..73af9aa74e 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFEvaluationCell.java @@ -20,6 +20,7 @@ package org.apache.poi.xssf.streaming; import org.apache.poi.ss.formula.EvaluationCell; import org.apache.poi.ss.formula.EvaluationSheet; import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.util.Internal; /** * SXSSF wrapper for a cell under evaluation @@ -51,10 +52,22 @@ final class SXSSFEvaluationCell implements EvaluationCell { public boolean getBooleanCellValue() { return _cell.getBooleanCellValue(); } + /** + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + * + * @return cell type + */ @Override - public CellType getCellType() { + public int getCellType() { return _cell.getCellType(); } + /** @deprecated POI 3.15 beta 3 */ + @Internal + @Override + public CellType getCellTypeEnum() { + return _cell.getCellTypeEnum(); + } @Override public int getColumnIndex() { return _cell.getColumnIndex(); @@ -78,9 +91,21 @@ final class SXSSFEvaluationCell implements EvaluationCell { @Override public String getStringCellValue() { return _cell.getRichStringCellValue().getString(); - } + } + /** + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + * + * @return cell type of cached formula result + */ + @Override + public int getCachedFormulaResultType() { + return _cell.getCachedFormulaResultType(); + } + /** @deprecated POI 3.15 beta 3 */ + @Internal @Override - public CellType getCachedFormulaResultType() { - return _cell.getCachedFormulaResultType(); + public CellType getCachedFormulaResultTypeEnum() { + return _cell.getCachedFormulaResultTypeEnum(); } } diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java index 965534f34b..52b7342dd5 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFFormulaEvaluator.java @@ -121,7 +121,7 @@ public final class SXSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator { // Evaluate what we have for (Row r : sheet) { for (Cell c : r) { - if (c.getCellType() == CellType.FORMULA) { + if (c.getCellTypeEnum() == CellType.FORMULA) { eval.evaluateFormulaCell(c); } } diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java index a1eb965663..7aaacdd9b0 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFRow.java @@ -268,7 +268,7 @@ public class SXSSFRow implements Row, Comparable case RETURN_NULL_AND_BLANK: return cell; case RETURN_BLANK_AS_NULL: - boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK); + boolean isBlank = (cell != null && cell.getCellTypeEnum() == CellType.BLANK); return (isBlank) ? null : cell; case CREATE_NULL_AS_BLANK: return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell; diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java index 455254aa6b..4bd0c6bad9 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java @@ -202,7 +202,7 @@ public class SheetDataWriter { // APIs _out.write(" s=\"" + (cellStyle.getIndex() & 0xffff) + "\""); } - CellType cellType = cell.getCellType(); + CellType cellType = cell.getCellTypeEnum(); switch (cellType) { case BLANK: { _out.write(">"); @@ -213,7 +213,7 @@ public class SheetDataWriter { _out.write(""); outputQuotedString(cell.getCellFormula()); _out.write(""); - switch (cell.getCachedFormulaResultType()) { + switch (cell.getCachedFormulaResultTypeEnum()) { case NUMERIC: double nval = cell.getNumericCellValue(); if (!Double.isNaN(nval)) { diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java index 6d337f4465..4b54ee9f1a 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/BaseXSSFFormulaEvaluator.java @@ -75,7 +75,7 @@ public abstract class BaseXSSFFormulaEvaluator implements FormulaEvaluator, Work return null; } - switch (cell.getCellType()) { + switch (cell.getCellTypeEnum()) { case BOOLEAN: return CellValue.valueOf(cell.getBooleanCellValue()); case ERROR: @@ -89,7 +89,7 @@ public abstract class BaseXSSFFormulaEvaluator implements FormulaEvaluator, Work case BLANK: return null; default: - throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")"); + throw new IllegalStateException("Bad cell type (" + cell.getCellTypeEnum() + ")"); } } @@ -113,7 +113,7 @@ public abstract class BaseXSSFFormulaEvaluator implements FormulaEvaluator, Work * @return The type of the formula result (the cell's type remains as CellType.FORMULA however) */ public CellType evaluateFormulaCell(Cell cell) { - if (cell == null || cell.getCellType() != CellType.FORMULA) { + if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) { return CellType._UNINITIALIZED; } CellValue cv = evaluateFormulaCellValue(cell); @@ -131,7 +131,7 @@ public abstract class BaseXSSFFormulaEvaluator implements FormulaEvaluator, Work */ protected void doEvaluateInCell(Cell cell) { if (cell == null) return; - if (cell.getCellType() == CellType.FORMULA) { + if (cell.getCellTypeEnum() == CellType.FORMULA) { CellValue cv = evaluateFormulaCellValue(cell); setCellType(cell, cv); // cell will no longer be a formula cell setCellValue(cell, cv); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java index 25d8cc8324..850f398d16 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java @@ -138,11 +138,11 @@ public final class XSSFCell implements Cell { // Copy cell value (cell type is updated implicitly) if (policy.isCopyCellValue()) { if (srcCell != null) { - CellType copyCellType = srcCell.getCellType(); + CellType copyCellType = srcCell.getCellTypeEnum(); if (copyCellType == CellType.FORMULA && !policy.isCopyCellFormula()) { // Copy formula result as value // FIXME: Cached value may be stale - copyCellType = srcCell.getCachedFormulaResultType(); + copyCellType = srcCell.getCachedFormulaResultTypeEnum(); } switch (copyCellType) { case NUMERIC: @@ -171,7 +171,7 @@ public final class XSSFCell implements Cell { break; default: - throw new IllegalArgumentException("Invalid cell type " + srcCell.getCellType()); + throw new IllegalArgumentException("Invalid cell type " + srcCell.getCellTypeEnum()); } } else { //srcCell is null setBlank(); @@ -249,12 +249,12 @@ public final class XSSFCell implements Cell { * For strings, numbers, and errors, we throw an exception. For blank cells we return a false. *

* @return the value of the cell as a boolean - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} * is not {@link CellType#BOOLEAN}, {@link CellType#BLANK} or {@link CellType#FORMULA} */ @Override public boolean getBooleanCellValue() { - CellType cellType = getCellType(); + CellType cellType = getCellTypeEnum(); switch(cellType) { case BLANK: return false; @@ -288,13 +288,13 @@ public final class XSSFCell implements Cell { * For formulas or error cells we return the precalculated value; *

* @return the value of the cell as a number - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING} + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is {@link CellType#STRING} * @exception NumberFormatException if the cell value isn't a parsable double. * @see DataFormatter for turning this number into a string similar to that which Excel would render this number as. */ @Override public double getNumericCellValue() { - CellType cellType = getCellType(); + CellType cellType = getCellTypeEnum(); switch(cellType) { case BLANK: return 0.0; @@ -366,7 +366,7 @@ public final class XSSFCell implements Cell { */ @Override public XSSFRichTextString getRichStringCellValue() { - CellType cellType = getCellType(); + CellType cellType = getCellTypeEnum(); XSSFRichTextString rt; switch (cellType) { case BLANK: @@ -445,7 +445,7 @@ public final class XSSFCell implements Cell { throw new IllegalArgumentException("The maximum length of cell contents (text) is 32,767 characters"); } - CellType cellType = getCellType(); + CellType cellType = getCellTypeEnum(); switch (cellType){ case FORMULA: _cell.setV(str.getString()); @@ -470,7 +470,7 @@ public final class XSSFCell implements Cell { * Return a formula for the cell, for example, SUM(C4:E4) * * @return a formula for the cell - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not {@link CellType#FORMULA} + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not {@link CellType#FORMULA} */ @Override public String getCellFormula() { @@ -483,10 +483,10 @@ public final class XSSFCell implements Cell { * * @param fpb evaluation workbook for reuse, if available, or null to create a new one as needed * @return a formula for the cell - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not {@link CellType#FORMULA} + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not {@link CellType#FORMULA} */ protected String getCellFormula(XSSFEvaluationWorkbook fpb) { - CellType cellType = getCellType(); + CellType cellType = getCellTypeEnum(); if(cellType != CellType.FORMULA) throw typeMismatch(CellType.FORMULA, cellType, false); CTCellFormula f = _cell.getF(); @@ -660,27 +660,59 @@ public final class XSSFCell implements Cell { } return false; } + + /** + * Return the cell type. + * + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + * + * @return the cell type + */ + @Override + public int getCellType() { + return getCellTypeEnum().getCode(); + } /** * Return the cell type. * * @return the cell type + * @deprecated POI 3.15 beta 3 */ + @Internal @Override - public CellType getCellType() { + public CellType getCellTypeEnum() { if (isFormulaCell()) return CellType.FORMULA; return getBaseCellType(true); } + /** + * Only valid for formula cells + * + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + * + * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING}, + * {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending + * on the cached value of the formula + */ + @Override + public int getCachedFormulaResultType() { + return getCachedFormulaResultTypeEnum().getCode(); + } + /** * Only valid for formula cells * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING}, * {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending * on the cached value of the formula + * @deprecated POI 3.15 beta 3 */ + @Internal @Override - public CellType getCachedFormulaResultType() { + public CellType getCachedFormulaResultTypeEnum() { if (! isFormulaCell()) { throw new IllegalStateException("Only formula cells have cached results"); } @@ -722,13 +754,13 @@ public final class XSSFCell implements Cell { * For strings we throw an exception. For blank cells we return a null. *

* @return the value of the cell as a date - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is {@link CellType#STRING} + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is {@link CellType#STRING} * @exception NumberFormatException if the cell value isn't a parsable double. * @see DataFormatter for formatting this date into a string similar to how excel does. */ @Override public Date getDateCellValue() { - if (getCellType() == CellType.BLANK) { + if (getCellTypeEnum() == CellType.BLANK) { return null; } @@ -787,7 +819,7 @@ public final class XSSFCell implements Cell { * Returns the error message, such as #VALUE! * * @return the error message such as #VALUE! - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't {@link CellType#ERROR} + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't {@link CellType#ERROR} * @see FormulaError */ public String getErrorCellString() { @@ -804,7 +836,7 @@ public final class XSSFCell implements Cell { *

* * @return the value of the cell as an error code - * @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't {@link CellType #ERROR} + * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't {@link CellType #ERROR} * @see FormulaError */ @Override @@ -899,7 +931,7 @@ public final class XSSFCell implements Cell { */ @Override public void setCellType(CellType cellType) { - CellType prevType = getCellType(); + CellType prevType = getCellTypeEnum(); if(isPartOfArrayFormulaGroup()){ notifyArrayFormulaChanging(); @@ -962,7 +994,7 @@ public final class XSSFCell implements Cell { */ @Override public String toString() { - switch (getCellType()) { + switch (getCellTypeEnum()) { case NUMERIC: if (DateUtil.isCellDateFormatted(this)) { DateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy", LocaleUtil.getUserLocale()); @@ -981,7 +1013,7 @@ public final class XSSFCell implements Cell { case ERROR: return ErrorEval.getText(getErrorCellValue()); default: - return "Unknown Cell Type: " + getCellType(); + return "Unknown Cell Type: " + getCellTypeEnum(); } } @@ -1133,7 +1165,7 @@ public final class XSSFCell implements Cell { * TODO - perhaps a method like setCellTypeAndValue(int, Object) should be introduced to avoid this */ private boolean convertCellValueToBoolean() { - CellType cellType = getCellType(); + CellType cellType = getCellTypeEnum(); if (cellType == CellType.FORMULA) { cellType = getBaseCellType(false); @@ -1161,7 +1193,7 @@ public final class XSSFCell implements Cell { } private String convertCellValueToString() { - CellType cellType = getCellType(); + CellType cellType = getCellTypeEnum(); switch (cellType) { case BLANK: diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java index 40b44001ab..25a0cf2839 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java @@ -20,6 +20,7 @@ package org.apache.poi.xssf.usermodel; import org.apache.poi.ss.formula.EvaluationCell; import org.apache.poi.ss.formula.EvaluationSheet; import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.util.Internal; /** * XSSF wrapper for a cell under evaluation @@ -52,10 +53,22 @@ final class XSSFEvaluationCell implements EvaluationCell { public boolean getBooleanCellValue() { return _cell.getBooleanCellValue(); } +/** + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + * + * @return cell type + */ @Override - public CellType getCellType() { + public int getCellType() { return _cell.getCellType(); } + /** @deprecated POI 3.15 beta 3 */ + @Internal + @Override + public CellType getCellTypeEnum() { + return _cell.getCellTypeEnum(); + } @Override public int getColumnIndex() { return _cell.getColumnIndex(); @@ -79,9 +92,21 @@ final class XSSFEvaluationCell implements EvaluationCell { @Override public String getStringCellValue() { return _cell.getRichStringCellValue().getString(); - } + } + /** + * Will return {@link CellType} in a future version of POI. + * For forwards compatibility, do not hard-code cell type literals in your code. + * + * @return cell type of cached formula result + */ + @Override + public int getCachedFormulaResultType() { + return _cell.getCachedFormulaResultType(); + } + /** @deprecated POI 3.15 beta 3 */ + @Internal @Override - public CellType getCachedFormulaResultType() { - return _cell.getCachedFormulaResultType(); + public CellType getCachedFormulaResultTypeEnum() { + return _cell.getCachedFormulaResultTypeEnum(); } } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java index 8196abfb45..e936ed554d 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java @@ -276,7 +276,7 @@ public class XSSFRow implements Row, Comparable { case RETURN_NULL_AND_BLANK: return cell; case RETURN_BLANK_AS_NULL: - boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK); + boolean isBlank = (cell != null && cell.getCellTypeEnum() == CellType.BLANK); return (isBlank) ? null : cell; case CREATE_NULL_AS_BLANK: return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell; @@ -496,7 +496,7 @@ public class XSSFRow implements Row, Comparable { if(xcell.isPartOfArrayFormulaGroup()) { xcell.notifyArrayFormulaChanging(); } - if(cell.getCellType() == CellType.FORMULA) { + if(cell.getCellTypeEnum() == CellType.FORMULA) { _sheet.getWorkbook().onDeleteFormula(xcell); } // Performance optimization for bug 57840: explicit boxing is slightly faster than auto-unboxing, though may use more memory @@ -636,7 +636,7 @@ public class XSSFRow implements Row, Comparable { else { for (final Cell c : srcRow){ final XSSFCell srcCell = (XSSFCell)c; - final XSSFCell destCell = createCell(srcCell.getColumnIndex(), srcCell.getCellType()); + final XSSFCell destCell = createCell(srcCell.getColumnIndex(), srcCell.getCellTypeEnum()); destCell.copyCellFrom(srcCell, policy); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java index 107e205b98..1d146c09c6 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/XSSFFormulaUtils.java @@ -77,7 +77,7 @@ public final class XSSFFormulaUtils { for (Sheet sh : _wb) { for (Row row : sh) { for (Cell cell : row) { - if (cell.getCellType() == CellType.FORMULA) { + if (cell.getCellTypeEnum() == CellType.FORMULA) { updateFormula((XSSFCell) cell, oldName, newName); } } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java b/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java index 42cf2714a5..d2fd60f3ea 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java @@ -42,7 +42,7 @@ public final class TestCalculationChain extends TestCase { XSSFSheet sheet = wb.getSheet("Test"); XSSFCell cell = sheet.getRow(0).getCell(4); - assertEquals(CellType.FORMULA, cell.getCellType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); cell.setCellFormula(null); //the count of items is less by one @@ -53,9 +53,9 @@ public final class TestCalculationChain extends TestCase { assertEquals(10, c.getI()); assertEquals("C1", c.getR()); - assertEquals(CellType.STRING, cell.getCellType()); + assertEquals(CellType.STRING, cell.getCellTypeEnum()); cell.setCellValue("ABC"); - assertEquals(CellType.STRING, cell.getCellType()); + assertEquals(CellType.STRING, cell.getCellTypeEnum()); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java index 23f4ae3912..4cbc7c4e61 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java @@ -190,7 +190,7 @@ public final class TestFormulaEvaluatorOnXSSF { for (short colnum=SS.COLUMN_INDEX_FIRST_TEST_VALUE; colnum < endcolnum; colnum++) { Cell c = formulasRow.getCell(colnum); assumeNotNull(c); - assumeTrue(c.getCellType() == CellType.FORMULA); + assumeTrue(c.getCellTypeEnum() == CellType.FORMULA); ignoredFormulaTestCase(c.getCellFormula()); CellValue actValue = evaluator.evaluate(c); @@ -202,7 +202,7 @@ public final class TestFormulaEvaluatorOnXSSF { assertNotNull(msg + " - Bad setup data expected value is null", expValue); assertNotNull(msg + " - actual value was null", actValue); - final CellType expectedCellType = expValue.getCellType(); + final CellType expectedCellType = expValue.getCellTypeEnum(); switch (expectedCellType) { case BLANK: assertEquals(msg, CellType.BLANK, actValue.getCellType()); @@ -264,10 +264,10 @@ public final class TestFormulaEvaluatorOnXSSF { logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name"); return null; } - if(cell.getCellType() == CellType.BLANK) { + if(cell.getCellTypeEnum() == CellType.BLANK) { return null; } - if(cell.getCellType() == CellType.STRING) { + if(cell.getCellTypeEnum() == CellType.STRING) { return cell.getRichStringCellValue().getString(); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java index a237cefe60..f33d96e637 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java @@ -176,7 +176,7 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF { Cell c = r.getCell(SS.COLUMN_INDEX_ACTUAL_VALUE); assumeNotNull(c); - assumeTrue(c.getCellType() == CellType.FORMULA); + assumeTrue(c.getCellTypeEnum() == CellType.FORMULA); CellValue actValue = evaluator.evaluate(c); @@ -185,7 +185,7 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF { assertNotNull(msg + " - actual value was null", actValue); - final CellType expectedCellType = expValue.getCellType(); + final CellType expectedCellType = expValue.getCellTypeEnum(); switch (expectedCellType) { case BLANK: assertEquals(msg, CellType.BLANK, actValue.getCellType()); @@ -231,15 +231,15 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF { logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name"); return null; } - if(cell.getCellType() == CellType.BLANK) { + if(cell.getCellTypeEnum() == CellType.BLANK) { return null; } - if(cell.getCellType() == CellType.STRING) { + if(cell.getCellTypeEnum() == CellType.STRING) { return cell.getRichStringCellValue().getString(); } fail("Bad cell type for 'function name' column: (" - + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")"); + + cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")"); return ""; } /** @@ -255,15 +255,15 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF { logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_TEST_NAME + ", can't figure out test name"); return null; } - if(cell.getCellType() == CellType.BLANK) { + if(cell.getCellTypeEnum() == CellType.BLANK) { return null; } - if(cell.getCellType() == CellType.STRING) { + if(cell.getCellTypeEnum() == CellType.STRING) { return cell.getRichStringCellValue().getString(); } fail("Bad cell type for 'test name' column: (" - + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")"); + + cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")"); return ""; } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 02253a64eb..8965810250 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -300,7 +300,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { Sheet s = wb.getSheetAt(i); for(Row r : s) { for(Cell c : r) { - if(c.getCellType() == CellType.FORMULA) { + if(c.getCellTypeEnum() == CellType.FORMULA) { CellValue cv = eval.evaluate(c); if(cv.getCellType() == CellType.NUMERIC) { @@ -424,7 +424,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { cell = sheet.getRow(0).getCell(0); assertEquals("#REF!*#REF!", cell.getCellFormula()); - assertEquals(CellType.ERROR, evaluator.evaluateInCell(cell).getCellType()); + assertEquals(CellType.ERROR, evaluator.evaluateInCell(cell).getCellTypeEnum()); assertEquals("#REF!", FormulaError.forInt(cell.getErrorCellValue()).getString()); Name nm1 = wb.getName("sale_1"); @@ -436,7 +436,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { cell = sheet.getRow(1).getCell(0); assertEquals("sale_1*sale_2", cell.getCellFormula()); - assertEquals(CellType.ERROR, evaluator.evaluateInCell(cell).getCellType()); + assertEquals(CellType.ERROR, evaluator.evaluateInCell(cell).getCellTypeEnum()); assertEquals("#REF!", FormulaError.forInt(cell.getErrorCellValue()).getString()); wb.close(); @@ -642,7 +642,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { Sheet sheet = wb.getSheetAt(0); for(Row row : sheet){ for(Cell cell : row){ - if(cell.getCellType() == CellType.FORMULA){ + if(cell.getCellTypeEnum() == CellType.FORMULA){ formulaEvaluator.evaluateInCell(cell); // caused NPE on some cells } } @@ -1696,7 +1696,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { // Get wrong cell by row 8 & column 7 Cell cell = sheet.getRow(8).getCell(7); - assertEquals(CellType.NUMERIC, cell.getCellType()); + assertEquals(CellType.NUMERIC, cell.getCellTypeEnum()); // Check the value - will be zero as it is assertEquals(0.0, cell.getNumericCellValue(), 0.001); @@ -2182,7 +2182,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { Sheet sheet = wb.getSheet("Sheet1"); Cell cell = sheet.getRow(5).getCell(4); - assertEquals(CellType.FORMULA, cell.getCellType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("E4+E5", cell.getCellFormula()); CellValue value = evaluator.evaluate(cell); @@ -2541,7 +2541,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { if(cell == null){ cell = row.createCell(cellnum); } else { - if(cell.getCellType() == CellType.FORMULA) { + if(cell.getCellTypeEnum() == CellType.FORMULA) { cell.setCellFormula(null); cell.getCellStyle().setDataFormat((short) 0); } @@ -2607,13 +2607,13 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { } private void assertFormula(Workbook wb, Cell intF, String expectedFormula, String expectedResultOrNull) { - assertEquals(CellType.FORMULA, intF.getCellType()); + assertEquals(CellType.FORMULA, intF.getCellTypeEnum()); if (null == expectedResultOrNull) { - assertEquals(CellType.ERROR, intF.getCachedFormulaResultType()); + assertEquals(CellType.ERROR, intF.getCachedFormulaResultTypeEnum()); expectedResultOrNull = "#VALUE!"; } else { - assertEquals(CellType.NUMERIC, intF.getCachedFormulaResultType()); + assertEquals(CellType.NUMERIC, intF.getCachedFormulaResultTypeEnum()); } assertEquals(expectedFormula, intF.getCellFormula()); @@ -2654,7 +2654,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { Sheet sheet = wb.getSheet("Sheet1"); for(Row aRow : sheet) { Cell cell = aRow.getCell(1); - if(cell.getCellType() == CellType.FORMULA) { + if(cell.getCellTypeEnum() == CellType.FORMULA) { String formula = cell.getCellFormula(); //System.out.println("formula: " + formula); assertNotNull(formula); @@ -2958,14 +2958,14 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { row = worksheet.getRow(2); cell = row.getCell(1); - assertEquals(CellType.BLANK, cell.getCellType()); + assertEquals(CellType.BLANK, cell.getCellTypeEnum()); assertEquals(CellType._UNINITIALIZED, evaluator.evaluateFormulaCell(cell)); // A3 row = worksheet.getRow(2); cell = row.getCell(0); - assertEquals(CellType.FORMULA, cell.getCellType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("IF(ISBLANK(B3),\"\",B3)", cell.getCellFormula()); assertEquals(CellType.STRING, evaluator.evaluateFormulaCell(cell)); CellValue value = evaluator.evaluate(cell); @@ -2975,7 +2975,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { row = worksheet.getRow(4); cell = row.getCell(0); - assertEquals(CellType.FORMULA, cell.getCellType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("COUNTBLANK(A1:A4)", cell.getCellFormula()); assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(cell)); value = evaluator.evaluate(cell); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java index 8c6951de18..ab7406eed4 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java @@ -134,13 +134,13 @@ public final class TestXSSFCell extends BaseTestXCell { assertNull(str.getString()); cell_0.setCellValue(str); assertEquals(0, sst.getCount()); - assertEquals(CellType.BLANK, cell_0.getCellType()); + assertEquals(CellType.BLANK, cell_0.getCellTypeEnum()); //case 2. cell.setCellValue((String)null); Cell cell_1 = row.createCell(1); cell_1.setCellValue((String)null); assertEquals(0, sst.getCount()); - assertEquals(CellType.BLANK, cell_1.getCellType()); + assertEquals(CellType.BLANK, cell_1.getCellTypeEnum()); wb.close(); } @@ -152,7 +152,7 @@ public final class TestXSSFCell extends BaseTestXCell { CTCell ctCell = cell.getCTCell(); //low-level bean holding cell's xml cell.setCellFormula("A2"); - assertEquals(CellType.FORMULA, cell.getCellType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("A2", cell.getCellFormula()); //the value is not set and cell's type='N' which means blank assertEquals(STCellType.N, ctCell.getT()); @@ -160,7 +160,7 @@ public final class TestXSSFCell extends BaseTestXCell { //set cached formula value cell.setCellValue("t='str'"); //we are still of 'formula' type - assertEquals(CellType.FORMULA, cell.getCellType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("A2", cell.getCellFormula()); //cached formula value is set and cell's type='STR' assertEquals(STCellType.STR, ctCell.getT()); @@ -168,14 +168,14 @@ public final class TestXSSFCell extends BaseTestXCell { //now remove the formula, the cached formula result remains cell.setCellFormula(null); - assertEquals(CellType.STRING, cell.getCellType()); + assertEquals(CellType.STRING, cell.getCellTypeEnum()); assertEquals(STCellType.STR, ctCell.getT()); //the line below failed prior to fix of Bug #47889 assertEquals("t='str'", cell.getStringCellValue()); //revert to a blank cell cell.setCellValue((String)null); - assertEquals(CellType.BLANK, cell.getCellType()); + assertEquals(CellType.BLANK, cell.getCellTypeEnum()); assertEquals(STCellType.N, ctCell.getT()); assertEquals("", cell.getStringCellValue()); } finally { @@ -195,7 +195,7 @@ public final class TestXSSFCell extends BaseTestXCell { //try a string cell cell = sh.getRow(0).getCell(0); - assertEquals(CellType.STRING, cell.getCellType()); + assertEquals(CellType.STRING, cell.getCellTypeEnum()); assertEquals("a", cell.getStringCellValue()); assertEquals("a", cell.toString()); //Gnumeric produces spreadsheets without styles @@ -204,7 +204,7 @@ public final class TestXSSFCell extends BaseTestXCell { //try a numeric cell cell = sh.getRow(1).getCell(0); - assertEquals(CellType.NUMERIC, cell.getCellType()); + assertEquals(CellType.NUMERIC, cell.getCellTypeEnum()); assertEquals(1.0, cell.getNumericCellValue(), 0); assertEquals("1.0", cell.toString()); //Gnumeric produces spreadsheets without styles @@ -514,7 +514,7 @@ public final class TestXSSFCell extends BaseTestXCell { final CellCopyPolicy policy = new CellCopyPolicy(); destCell.copyCellFrom(srcCell, policy); - assertEquals(CellType.FORMULA, destCell.getCellType()); + assertEquals(CellType.FORMULA, destCell.getCellTypeEnum()); assertEquals("2+3", destCell.getCellFormula()); assertEquals(srcCell.getCellStyle(), destCell.getCellStyle()); } @@ -526,7 +526,7 @@ public final class TestXSSFCell extends BaseTestXCell { // Paste values only final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellFormula(false).build(); destCell.copyCellFrom(srcCell, policy); - assertEquals(CellType.NUMERIC, destCell.getCellType()); + assertEquals(CellType.NUMERIC, destCell.getCellTypeEnum()); } @Test @@ -553,8 +553,8 @@ public final class TestXSSFCell extends BaseTestXCell { assertEquals(srcCell.getCellStyle(), destCell.getCellStyle()); // Old cell value should not have been overwritten - assertNotEquals(CellType.BLANK, destCell.getCellType()); - assertEquals(CellType.BOOLEAN, destCell.getCellType()); + assertNotEquals(CellType.BLANK, destCell.getCellTypeEnum()); + assertEquals(CellType.BOOLEAN, destCell.getCellTypeEnum()); assertEquals(true, destCell.getBooleanCellValue()); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java index 28cc7f79a3..566944d18d 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaEvaluation.java @@ -576,9 +576,9 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { wb.getCreationHelper().createFormulaEvaluator().evaluateAll(); - assertEquals(CellType.ERROR, getCell(sheet, 0,0).getCachedFormulaResultType()); + assertEquals(CellType.ERROR, getCell(sheet, 0,0).getCachedFormulaResultTypeEnum()); assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0,0).getErrorCellValue()); - assertEquals(CellType.ERROR, getCell(sheet, 0,1).getCachedFormulaResultType()); + assertEquals(CellType.ERROR, getCell(sheet, 0,1).getCachedFormulaResultTypeEnum()); assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0,1).getErrorCellValue()); wb.close(); @@ -597,11 +597,11 @@ public final class TestXSSFFormulaEvaluation extends BaseTestFormulaEvaluator { wb.getCreationHelper().createFormulaEvaluator().evaluateAll(); - assertEquals(CellType.ERROR, getCell(sheet, 0, 0).getCachedFormulaResultType()); + assertEquals(CellType.ERROR, getCell(sheet, 0, 0).getCachedFormulaResultTypeEnum()); assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0, 0).getErrorCellValue()); - assertEquals(CellType.ERROR, getCell(sheet, 1, 0).getCachedFormulaResultType()); + assertEquals(CellType.ERROR, getCell(sheet, 1, 0).getCachedFormulaResultTypeEnum()); assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 1, 0).getErrorCellValue()); - assertEquals(CellType.ERROR, getCell(sheet, 0, 3).getCachedFormulaResultType()); + assertEquals(CellType.ERROR, getCell(sheet, 0, 3).getCachedFormulaResultTypeEnum()); assertEquals(FormulaError.VALUE.getCode(), getCell(sheet, 0, 3).getErrorCellValue()); wb.close(); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java index 6a02c5162f..38dc38b7ed 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFormulaParser.java @@ -486,7 +486,7 @@ public final class TestXSSFFormulaParser { for (Row row : xsheet) { for (Cell cell : row) { - if (cell.getCellType() == CellType.FORMULA) { + if (cell.getCellTypeEnum() == CellType.FORMULA) { try { evaluator.evaluateFormulaCell(cell); } catch (Exception e) { diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java index fd815e9e03..55fe4a4fa5 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFPivotTable.java @@ -317,7 +317,7 @@ public class TestXSSFPivotTable extends TestCase { */ public void testAddDataColumnWithOffsetData() { offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1); - assertEquals(CellType.NUMERIC, offsetOuterCell.getCellType()); + assertEquals(CellType.NUMERIC, offsetOuterCell.getCellTypeEnum()); offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 0); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java index 9db9171e1e..6b49d81c98 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFRow.java @@ -183,7 +183,7 @@ public final class TestXSSFRow extends BaseTestXRow { assertSame("existing references to externObserverRow are still valid", externObserverRow, sheet2.getRow(0)); // Make sure copyRowFrom actually copied row (this is tested elsewhere) - assertEquals(CellType.STRING, destRow.getCell(0).getCellType()); + assertEquals(CellType.STRING, destRow.getCell(0).getCellTypeEnum()); assertEquals("hello", destRow.getCell(0).getStringCellValue()); // We don't want #REF! errors if we copy a row that contains cells that are referred to by other cells outside of copied region diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java index f8681fd002..a9b0d1f0b5 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheet.java @@ -1484,44 +1484,44 @@ public final class TestXSSFSheet extends BaseTestXSheet { // Blank cell = CellUtil.getCell(destRow, col++); - assertEquals("[Blank] C7 cell type", CellType.BLANK, cell.getCellType()); + assertEquals("[Blank] C7 cell type", CellType.BLANK, cell.getCellTypeEnum()); // Error cell = CellUtil.getCell(destRow, col++); - assertEquals("[Error] D7 cell type", CellType.ERROR, cell.getCellType()); + assertEquals("[Error] D7 cell type", CellType.ERROR, cell.getCellTypeEnum()); final FormulaError error = FormulaError.forInt(cell.getErrorCellValue()); assertEquals("[Error] D7 cell value", FormulaError.NA, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here // Date cell = CellUtil.getCell(destRow, col++); - assertEquals("[Date] E7 cell type", CellType.NUMERIC, cell.getCellType()); + assertEquals("[Date] E7 cell type", CellType.NUMERIC, cell.getCellTypeEnum()); final Date date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 1).getTime(); assertEquals("[Date] E7 cell value", date, cell.getDateCellValue()); // Boolean cell = CellUtil.getCell(destRow, col++); - assertEquals("[Boolean] F7 cell type", CellType.BOOLEAN, cell.getCellType()); + assertEquals("[Boolean] F7 cell type", CellType.BOOLEAN, cell.getCellTypeEnum()); assertEquals("[Boolean] F7 cell value", true, cell.getBooleanCellValue()); // String cell = CellUtil.getCell(destRow, col++); - assertEquals("[String] G7 cell type", CellType.STRING, cell.getCellType()); + assertEquals("[String] G7 cell type", CellType.STRING, cell.getCellTypeEnum()); assertEquals("[String] G7 cell value", "Hello", cell.getStringCellValue()); // Int cell = CellUtil.getCell(destRow, col++); - assertEquals("[Int] H7 cell type", CellType.NUMERIC, cell.getCellType()); + assertEquals("[Int] H7 cell type", CellType.NUMERIC, cell.getCellTypeEnum()); assertEquals("[Int] H7 cell value", 15, (int) cell.getNumericCellValue()); // Float cell = CellUtil.getCell(destRow, col++); - assertEquals("[Float] I7 cell type", CellType.NUMERIC, cell.getCellType()); + assertEquals("[Float] I7 cell type", CellType.NUMERIC, cell.getCellTypeEnum()); assertEquals("[Float] I7 cell value", 12.5, cell.getNumericCellValue(), FLOAT_PRECISION); // Cell Formula cell = CellUtil.getCell(destRow, col++); assertEquals("J7", new CellReference(cell).formatAsString()); - assertEquals("[Cell Formula] J7 cell type", CellType.FORMULA, cell.getCellType()); + assertEquals("[Cell Formula] J7 cell type", CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("[Cell Formula] J7 cell formula", "5+2", cell.getCellFormula()); System.out.println("Cell formula evaluation currently unsupported"); @@ -1530,21 +1530,21 @@ public final class TestXSSFSheet extends BaseTestXSheet { cell = CellUtil.getCell(destRow, col++); assertEquals("K7", new CellReference(cell).formatAsString()); assertEquals("[Cell Formula with Reference] K7 cell type", - CellType.FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("[Cell Formula with Reference] K7 cell formula", "J7+H$2", cell.getCellFormula()); // Cell Formula with Reference spanning multiple rows cell = CellUtil.getCell(destRow, col++); assertEquals("[Cell Formula with Reference spanning multiple rows] L7 cell type", - CellType.FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("[Cell Formula with Reference spanning multiple rows] L7 cell formula", "G7&\" \"&G8", cell.getCellFormula()); // Cell Formula with Reference spanning multiple rows cell = CellUtil.getCell(destRow, col++); assertEquals("[Cell Formula with Area Reference] M7 cell type", - CellType.FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("[Cell Formula with Area Reference] M7 cell formula", "SUM(H7:I8)", cell.getCellFormula()); @@ -1559,7 +1559,7 @@ public final class TestXSSFSheet extends BaseTestXSheet { // Data Format cell = CellUtil.getCell(destRow, col++); - assertEquals("[Data Format] O7 cell type;", CellType.NUMERIC, cell.getCellType()); + assertEquals("[Data Format] O7 cell type;", CellType.NUMERIC, cell.getCellTypeEnum()); assertEquals("[Data Format] O7 cell value", 100.20, cell.getNumericCellValue(), FLOAT_PRECISION); //FIXME: currently fails final String moneyFormat = "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)"; @@ -1638,83 +1638,83 @@ public final class TestXSSFSheet extends BaseTestXSheet { // Blank col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[Blank] C10 cell type", CellType.BLANK, cell.getCellType()); + assertEquals("[Blank] C10 cell type", CellType.BLANK, cell.getCellTypeEnum()); cell = CellUtil.getCell(destRow2, col); - assertEquals("[Blank] C11 cell type", CellType.BLANK, cell.getCellType()); + assertEquals("[Blank] C11 cell type", CellType.BLANK, cell.getCellTypeEnum()); // Error col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[Error] D10 cell type", CellType.ERROR, cell.getCellType()); + assertEquals("[Error] D10 cell type", CellType.ERROR, cell.getCellTypeEnum()); FormulaError error = FormulaError.forInt(cell.getErrorCellValue()); assertEquals("[Error] D10 cell value", FormulaError.NA, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here cell = CellUtil.getCell(destRow2, col); - assertEquals("[Error] D11 cell type", CellType.ERROR, cell.getCellType()); + assertEquals("[Error] D11 cell type", CellType.ERROR, cell.getCellTypeEnum()); error = FormulaError.forInt(cell.getErrorCellValue()); assertEquals("[Error] D11 cell value", FormulaError.NAME, error); //FIXME: XSSFCell and HSSFCell expose different interfaces. getErrorCellString would be helpful here // Date col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[Date] E10 cell type", CellType.NUMERIC, cell.getCellType()); + assertEquals("[Date] E10 cell type", CellType.NUMERIC, cell.getCellTypeEnum()); Date date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 1).getTime(); assertEquals("[Date] E10 cell value", date, cell.getDateCellValue()); cell = CellUtil.getCell(destRow2, col); - assertEquals("[Date] E11 cell type", CellType.NUMERIC, cell.getCellType()); + assertEquals("[Date] E11 cell type", CellType.NUMERIC, cell.getCellTypeEnum()); date = LocaleUtil.getLocaleCalendar(2000, Calendar.JANUARY, 2).getTime(); assertEquals("[Date] E11 cell value", date, cell.getDateCellValue()); // Boolean col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[Boolean] F10 cell type", CellType.BOOLEAN, cell.getCellType()); + assertEquals("[Boolean] F10 cell type", CellType.BOOLEAN, cell.getCellTypeEnum()); assertEquals("[Boolean] F10 cell value", true, cell.getBooleanCellValue()); cell = CellUtil.getCell(destRow2, col); - assertEquals("[Boolean] F11 cell type", CellType.BOOLEAN, cell.getCellType()); + assertEquals("[Boolean] F11 cell type", CellType.BOOLEAN, cell.getCellTypeEnum()); assertEquals("[Boolean] F11 cell value", false, cell.getBooleanCellValue()); // String col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[String] G10 cell type", CellType.STRING, cell.getCellType()); + assertEquals("[String] G10 cell type", CellType.STRING, cell.getCellTypeEnum()); assertEquals("[String] G10 cell value", "Hello", cell.getStringCellValue()); cell = CellUtil.getCell(destRow2, col); - assertEquals("[String] G11 cell type", CellType.STRING, cell.getCellType()); + assertEquals("[String] G11 cell type", CellType.STRING, cell.getCellTypeEnum()); assertEquals("[String] G11 cell value", "World", cell.getStringCellValue()); // Int col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[Int] H10 cell type", CellType.NUMERIC, cell.getCellType()); + assertEquals("[Int] H10 cell type", CellType.NUMERIC, cell.getCellTypeEnum()); assertEquals("[Int] H10 cell value", 15, (int) cell.getNumericCellValue()); cell = CellUtil.getCell(destRow2, col); - assertEquals("[Int] H11 cell type", CellType.NUMERIC, cell.getCellType()); + assertEquals("[Int] H11 cell type", CellType.NUMERIC, cell.getCellTypeEnum()); assertEquals("[Int] H11 cell value", 42, (int) cell.getNumericCellValue()); // Float col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[Float] I10 cell type", CellType.NUMERIC, cell.getCellType()); + assertEquals("[Float] I10 cell type", CellType.NUMERIC, cell.getCellTypeEnum()); assertEquals("[Float] I10 cell value", 12.5, cell.getNumericCellValue(), FLOAT_PRECISION); cell = CellUtil.getCell(destRow2, col); - assertEquals("[Float] I11 cell type", CellType.NUMERIC, cell.getCellType()); + assertEquals("[Float] I11 cell type", CellType.NUMERIC, cell.getCellTypeEnum()); assertEquals("[Float] I11 cell value", 5.5, cell.getNumericCellValue(), FLOAT_PRECISION); // Cell Formula col++; cell = CellUtil.getCell(destRow1, col); - assertEquals("[Cell Formula] J10 cell type", CellType.FORMULA, cell.getCellType()); + assertEquals("[Cell Formula] J10 cell type", CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("[Cell Formula] J10 cell formula", "5+2", cell.getCellFormula()); cell = CellUtil.getCell(destRow2, col); - assertEquals("[Cell Formula] J11 cell type", CellType.FORMULA, cell.getCellType()); + assertEquals("[Cell Formula] J11 cell type", CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("[Cell Formula] J11 cell formula", "6+18", cell.getCellFormula()); // Cell Formula with Reference @@ -1722,25 +1722,25 @@ public final class TestXSSFSheet extends BaseTestXSheet { // Formula row references should be adjusted by destRowNum-srcRowNum cell = CellUtil.getCell(destRow1, col); assertEquals("[Cell Formula with Reference] K10 cell type", - CellType.FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("[Cell Formula with Reference] K10 cell formula", "J10+H$2", cell.getCellFormula()); cell = CellUtil.getCell(destRow2, col); - assertEquals("[Cell Formula with Reference] K11 cell type", CellType.FORMULA, cell.getCellType()); + assertEquals("[Cell Formula with Reference] K11 cell type", CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("[Cell Formula with Reference] K11 cell formula", "J11+H$2", cell.getCellFormula()); // Cell Formula with Reference spanning multiple rows col++; cell = CellUtil.getCell(destRow1, col); assertEquals("[Cell Formula with Reference spanning multiple rows] L10 cell type", - CellType.FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("[Cell Formula with Reference spanning multiple rows] L10 cell formula", "G10&\" \"&G11", cell.getCellFormula()); cell = CellUtil.getCell(destRow2, col); assertEquals("[Cell Formula with Reference spanning multiple rows] L11 cell type", - CellType.FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("[Cell Formula with Reference spanning multiple rows] L11 cell formula", "G11&\" \"&G12", cell.getCellFormula()); @@ -1748,13 +1748,13 @@ public final class TestXSSFSheet extends BaseTestXSheet { col++; cell = CellUtil.getCell(destRow1, col); assertEquals("[Cell Formula with Area Reference] M10 cell type", - CellType.FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("[Cell Formula with Area Reference] M10 cell formula", "SUM(H10:I11)", cell.getCellFormula()); cell = CellUtil.getCell(destRow2, col); assertEquals("[Cell Formula with Area Reference] M11 cell type", - CellType.FORMULA, cell.getCellType()); + CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("[Cell Formula with Area Reference] M11 cell formula", "SUM($H$3:I10)", cell.getCellFormula()); //Also acceptable: SUM($H10:I$3), but this AreaReference isn't in ascending order @@ -1776,7 +1776,7 @@ public final class TestXSSFSheet extends BaseTestXSheet { // Data Format col++; cell = CellUtil.getCell(destRow2, col); - assertEquals("[Data Format] O10 cell type", CellType.NUMERIC, cell.getCellType()); + assertEquals("[Data Format] O10 cell type", CellType.NUMERIC, cell.getCellTypeEnum()); assertEquals("[Data Format] O10 cell value", 100.20, cell.getNumericCellValue(), FLOAT_PRECISION); final String moneyFormat = "\"$\"#,##0.00_);[Red]\\(\"$\"#,##0.00\\)"; assertEquals("[Data Format] O10 cell data format", moneyFormat, cell.getCellStyle().getDataFormatString()); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java index 24f9e37b29..8e508860a0 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFSheetShiftRows.java @@ -117,7 +117,7 @@ public final class TestXSSFSheetShiftRows extends BaseTestSheetShiftRows { return; } Cell readCell = readRow.getCell(0); - if(readCell.getCellType() == CellType.NUMERIC) { + if(readCell.getCellTypeEnum() == CellType.NUMERIC) { assertEquals(expect, Double.toString(readCell.getNumericCellValue())); } else { assertEquals(expect, readCell.getStringCellValue()); diff --git a/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelConverter.java b/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelConverter.java index 62f3d14231..a3d1624111 100644 --- a/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelConverter.java +++ b/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelConverter.java @@ -121,14 +121,14 @@ public abstract class AbstractExcelConverter protected boolean isTextEmpty( HSSFCell cell ) { final String value; - switch ( cell.getCellType() ) + switch ( cell.getCellTypeEnum() ) { case STRING: // XXX: enrich value = cell.getRichStringCellValue().getString(); break; case FORMULA: - switch ( cell.getCachedFormulaResultType() ) + switch ( cell.getCachedFormulaResultTypeEnum() ) { case STRING: HSSFRichTextString str = cell.getRichStringCellValue(); diff --git a/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java b/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java index 7119718964..1c32edabe8 100644 --- a/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java +++ b/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java @@ -207,14 +207,14 @@ public class ExcelToFoConverter extends AbstractExcelConverter final HSSFCellStyle cellStyle = cell.getCellStyle(); String value; - switch ( cell.getCellType() ) + switch ( cell.getCellTypeEnum() ) { case STRING: // XXX: enrich value = cell.getRichStringCellValue().getString(); break; case FORMULA: - switch ( cell.getCachedFormulaResultType() ) + switch ( cell.getCachedFormulaResultTypeEnum() ) { case STRING: HSSFRichTextString str = cell.getRichStringCellValue(); @@ -243,7 +243,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter logger.log( POILogger.WARN, "Unexpected cell cachedFormulaResultType (" - + cell.getCachedFormulaResultType() + ")" ); + + cell.getCachedFormulaResultTypeEnum() + ")" ); value = ExcelToHtmlUtils.EMPTY; break; } @@ -262,7 +262,7 @@ public class ExcelToFoConverter extends AbstractExcelConverter break; default: logger.log( POILogger.WARN, - "Unexpected cell type (" + cell.getCellType() + ")" ); + "Unexpected cell type (" + cell.getCellTypeEnum() + ")" ); return true; } diff --git a/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java b/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java index b34b2ed8e3..54dc4d3196 100644 --- a/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java +++ b/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java @@ -294,14 +294,14 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter final HSSFCellStyle cellStyle = cell.getCellStyle(); String value; - switch ( cell.getCellType() ) + switch ( cell.getCellTypeEnum() ) { case STRING: // XXX: enrich value = cell.getRichStringCellValue().getString(); break; case FORMULA: - switch ( cell.getCachedFormulaResultType() ) + switch ( cell.getCachedFormulaResultTypeEnum() ) { case STRING: HSSFRichTextString str = cell.getRichStringCellValue(); @@ -330,7 +330,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter logger.log( POILogger.WARN, "Unexpected cell cachedFormulaResultType (" - + cell.getCachedFormulaResultType() + ")" ); + + cell.getCachedFormulaResultTypeEnum() + ")" ); value = ExcelToHtmlUtils.EMPTY; break; } @@ -349,7 +349,7 @@ public class ExcelToHtmlConverter extends AbstractExcelConverter break; default: logger.log( POILogger.WARN, - "Unexpected cell type (" + cell.getCellType() + ")" ); + "Unexpected cell type (" + cell.getCellTypeEnum() + ")" ); return true; } diff --git a/src/testcases/org/apache/poi/hssf/model/TestRVA.java b/src/testcases/org/apache/poi/hssf/model/TestRVA.java index 48d0066cf0..4869d87d61 100644 --- a/src/testcases/org/apache/poi/hssf/model/TestRVA.java +++ b/src/testcases/org/apache/poi/hssf/model/TestRVA.java @@ -80,7 +80,7 @@ public final class TestRVA { break; } HSSFCell cell = row.getCell(0); - if (cell == null || cell.getCellType() == CellType.BLANK) { + if (cell == null || cell.getCellTypeEnum() == CellType.BLANK) { break; } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java index f0f95261a7..cbfc6d9b88 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBug42464.java @@ -68,7 +68,7 @@ public final class TestBug42464 { Iterator it = row.cellIterator(); while(it.hasNext()) { HSSFCell cell = (HSSFCell)it.next(); - if(cell.getCellType() != CellType.FORMULA) { + if(cell.getCellTypeEnum() != CellType.FORMULA) { continue; } FormulaRecordAggregate record = (FormulaRecordAggregate) cell.getCellValueRecord(); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index d588115b65..1d450a2e04 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -469,7 +469,7 @@ public final class TestBugs extends BaseTestBugzillaIssues { HSSFRow row = sheet.getRow(i); if (row != null) { HSSFCell cell = row .getCell(0); - assertEquals(CellType.STRING, cell.getCellType()); + assertEquals(CellType.STRING, cell.getCellTypeEnum()); count++; } } @@ -1167,13 +1167,13 @@ public final class TestBugs extends BaseTestBugzillaIssues { } private static void confirmCachedValue(double expectedValue, HSSFCell cell) { - assertEquals(CellType.FORMULA, cell.getCellType()); - assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); + assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum()); assertEquals(expectedValue, cell.getNumericCellValue(), 0.0); } private static void confirmCachedValue(String expectedValue, HSSFCell cell) { - assertEquals(CellType.FORMULA, cell.getCellType()); - assertEquals(CellType.STRING, cell.getCachedFormulaResultType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); + assertEquals(CellType.STRING, cell.getCachedFormulaResultTypeEnum()); assertEquals(expectedValue, cell.getRichStringCellValue().getString()); } @@ -1288,7 +1288,7 @@ public final class TestBugs extends BaseTestBugzillaIssues { s = wb.getSheet("OneVariable Table Completed"); r = s.getRow(3); c = r.getCell(4); - assertEquals(CellType.FORMULA, c.getCellType()); + assertEquals(CellType.FORMULA, c.getCellTypeEnum()); // TODO - check the formula once tables and // arrays are properly supported @@ -1298,7 +1298,7 @@ public final class TestBugs extends BaseTestBugzillaIssues { s = wb.getSheet("TwoVariable Table Example"); r = s.getRow(3); c = r.getCell(4); - assertEquals(CellType.FORMULA, c.getCellType()); + assertEquals(CellType.FORMULA, c.getCellTypeEnum()); // TODO - check the formula once tables and // arrays are properly supported @@ -1824,26 +1824,26 @@ public final class TestBugs extends BaseTestBugzillaIssues { HSSFRow row; row = s.getRow(0); - assertEquals(CellType.NUMERIC, row.getCell(1).getCellType()); + assertEquals(CellType.NUMERIC, row.getCell(1).getCellTypeEnum()); assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); row = s.getRow(1); - assertEquals(CellType.FORMULA, row.getCell(1).getCellType()); + assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum()); assertEquals("B1", row.getCell(1).getCellFormula()); assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); row = s.getRow(2); - assertEquals(CellType.FORMULA, row.getCell(1).getCellType()); + assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum()); assertEquals("Sheet1!B1", row.getCell(1).getCellFormula()); assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); row = s.getRow(3); - assertEquals(CellType.FORMULA, row.getCell(1).getCellType()); + assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum()); assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula()); assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); row = s.getRow(4); - assertEquals(CellType.FORMULA, row.getCell(1).getCellType()); + assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum()); assertEquals("'[$http://gagravarr.org/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula()); assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); @@ -1864,21 +1864,21 @@ public final class TestBugs extends BaseTestBugzillaIssues { s = wb2.getSheetAt(0); row = s.getRow(0); - assertEquals(CellType.NUMERIC, row.getCell(1).getCellType()); + assertEquals(CellType.NUMERIC, row.getCell(1).getCellTypeEnum()); assertEquals(112.0, row.getCell(1).getNumericCellValue(),0); row = s.getRow(1); - assertEquals(CellType.FORMULA, row.getCell(1).getCellType()); + assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum()); assertEquals("B1", row.getCell(1).getCellFormula()); assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); row = s.getRow(2); - assertEquals(CellType.FORMULA, row.getCell(1).getCellType()); + assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum()); assertEquals("Sheet1!B1", row.getCell(1).getCellFormula()); assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); row = s.getRow(3); - assertEquals(CellType.FORMULA, row.getCell(1).getCellType()); + assertEquals(CellType.FORMULA, row.getCell(1).getCellTypeEnum()); assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula()); assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0); @@ -2755,13 +2755,13 @@ public final class TestBugs extends BaseTestBugzillaIssues { } private void assertFormula(Workbook wb, Cell intF, String expectedFormula, String expectedResultOrNull) { - assertEquals(CellType.FORMULA, intF.getCellType()); + assertEquals(CellType.FORMULA, intF.getCellTypeEnum()); if (null == expectedResultOrNull) { - assertEquals(CellType.ERROR, intF.getCachedFormulaResultType()); + assertEquals(CellType.ERROR, intF.getCachedFormulaResultTypeEnum()); expectedResultOrNull = "#VALUE!"; } else { - assertEquals(CellType.NUMERIC, intF.getCachedFormulaResultType()); + assertEquals(CellType.NUMERIC, intF.getCachedFormulaResultTypeEnum()); } assertEquals(expectedFormula, intF.getCellFormula()); @@ -2987,12 +2987,12 @@ public final class TestBugs extends BaseTestBugzillaIssues { Sheet sheet = wb.getSheetAt(0); Row row = sheet.getRow(0); Cell cell = row.getCell(0); - assertEquals(CellType.FORMULA, cell.getCellType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("IF(TRUE,\"\",\"\")", cell.getCellFormula()); assertEquals("", cell.getStringCellValue()); cell.setCellType(CellType.STRING); - assertEquals(CellType.BLANK, cell.getCellType()); + assertEquals(CellType.BLANK, cell.getCellTypeEnum()); try { assertNull(cell.getCellFormula()); fail("Should throw an exception here"); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java b/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java index e5aad2afc4..7e6d8a3bcf 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java @@ -436,7 +436,7 @@ public final class TestCellStyle extends TestCase { Cell cell = row.getCell(idxCell); cell.getCellStyle().getDataFormatString(); - if (cell.getCellType() == CellType.NUMERIC) { + if (cell.getCellTypeEnum() == CellType.NUMERIC) { boolean isDate = HSSFDateUtil.isCellDateFormatted(cell); if (idxCell > 0 && isDate) { fail("cell " + idxCell + " is not a date: " + idxCell.toString()); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestExternalReferenceChange.java b/src/testcases/org/apache/poi/hssf/usermodel/TestExternalReferenceChange.java index 86d59d8c74..9e3d4c33a5 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestExternalReferenceChange.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestExternalReferenceChange.java @@ -51,7 +51,7 @@ public class TestExternalReferenceChange extends TestCase { HSSFSheet lSheet = mainWorkbook.getSheetAt(0); HSSFCell lA1Cell = lSheet.getRow(0).getCell(0); - assertEquals(CellType.FORMULA, lA1Cell.getCellType()); + assertEquals(CellType.FORMULA, lA1Cell.getCellTypeEnum()); HSSFFormulaEvaluator lMainWorkbookEvaluator = new HSSFFormulaEvaluator(mainWorkbook); HSSFFormulaEvaluator lSourceEvaluator = new HSSFFormulaEvaluator(sourceWorkbook); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java index 82124ffc80..d1a3333663 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorBugs.java @@ -566,7 +566,7 @@ public final class TestFormulaEvaluatorBugs { } } private Ptg[] getPtgs(HSSFCell cell) { - assertEquals(CellType.FORMULA, cell.getCellType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); assertEquals(FormulaRecordAggregate.class, cell.getCellValueRecord().getClass()); FormulaRecordAggregate agg = (FormulaRecordAggregate)cell.getCellValueRecord(); FormulaRecord rec = agg.getFormulaRecord(); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java index 902884653d..1e30e7eb86 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulaEvaluatorDocs.java @@ -77,7 +77,7 @@ public final class TestFormulaEvaluatorDocs extends TestCase { for(Iterator cit = r.cellIterator(); cit.hasNext();) { HSSFCell c = (HSSFCell)cit.next(); - if(c.getCellType() == CellType.FORMULA) { + if(c.getCellTypeEnum() == CellType.FORMULA) { evaluator.evaluateFormulaCell(c); // For testing - all should be numeric @@ -90,15 +90,15 @@ public final class TestFormulaEvaluatorDocs extends TestCase { // Check now as expected assertEquals(55.7, wb.getSheetAt(0).getRow(0).getCell(2).getNumericCellValue(), 0); assertEquals("SUM(A1:B1)", wb.getSheetAt(0).getRow(0).getCell(2).getCellFormula()); - assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(0).getCell(2).getCellType()); + assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(0).getCell(2).getCellTypeEnum()); assertEquals(-4.6, wb.getSheetAt(0).getRow(1).getCell(2).getNumericCellValue(), 0); assertEquals("SUM(A2:B2)", wb.getSheetAt(0).getRow(1).getCell(2).getCellFormula()); - assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(1).getCell(2).getCellType()); + assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(1).getCell(2).getCellTypeEnum()); assertEquals(22.3, wb.getSheetAt(1).getRow(0).getCell(0).getNumericCellValue(), 0); assertEquals("'S1'!A1", wb.getSheetAt(1).getRow(0).getCell(0).getCellFormula()); - assertEquals(CellType.FORMULA, wb.getSheetAt(1).getRow(0).getCell(0).getCellType()); + assertEquals(CellType.FORMULA, wb.getSheetAt(1).getRow(0).getCell(0).getCellTypeEnum()); // Now do the alternate call, which zaps the formulas @@ -112,7 +112,7 @@ public final class TestFormulaEvaluatorDocs extends TestCase { for(Iterator cit = r.cellIterator(); cit.hasNext();) { HSSFCell c = (HSSFCell)cit.next(); - if(c.getCellType() == CellType.FORMULA) { + if(c.getCellTypeEnum() == CellType.FORMULA) { evaluator.evaluateInCell(c); } } @@ -120,12 +120,12 @@ public final class TestFormulaEvaluatorDocs extends TestCase { } assertEquals(55.7, wb.getSheetAt(0).getRow(0).getCell(2).getNumericCellValue(), 0); - assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(0).getCell(2).getCellType()); + assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(0).getCell(2).getCellTypeEnum()); assertEquals(-4.6, wb.getSheetAt(0).getRow(1).getCell(2).getNumericCellValue(), 0); - assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(1).getCell(2).getCellType()); + assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(1).getCell(2).getCellTypeEnum()); assertEquals(22.3, wb.getSheetAt(1).getRow(0).getCell(0).getNumericCellValue(), 0); - assertEquals(CellType.NUMERIC, wb.getSheetAt(1).getRow(0).getCell(0).getCellType()); + assertEquals(CellType.NUMERIC, wb.getSheetAt(1).getRow(0).getCell(0).getCellTypeEnum()); } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java index ed27a21f9e..fd3b1a66de 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java @@ -415,7 +415,7 @@ public final class TestHSSFCell extends BaseTestCell { assertEquals(wb.getWorkbook(), cell.getBoundWorkbook()); try { - cell.getCachedFormulaResultType(); + cell.getCachedFormulaResultTypeEnum(); fail("Should catch exception"); } catch (IllegalStateException e) { // expected here diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java index 69842b4d4d..50d320a966 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFDataFormatter.java @@ -384,7 +384,7 @@ public final class TestHSSFDataFormatter { HSSFRow row = sheet.getRow(0); HSSFCell cellA1 = row.getCell(0); - assertEquals(CellType.NUMERIC, cellA1.getCellType()); + assertEquals(CellType.NUMERIC, cellA1.getCellTypeEnum()); assertEquals(2345.0, cellA1.getNumericCellValue(), 0.0001); assertEquals("@", cellA1.getCellStyle().getDataFormatString()); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java index 4b1e0677e0..95e6e19fc5 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFFormulaEvaluator.java @@ -199,8 +199,8 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator { // VLookup on a name in another file cell = wb1.getSheetAt(0).getRow(1).getCell(2); - assertEquals(CellType.FORMULA, cell.getCellType()); - assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); + assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum()); assertEquals(12.30, cell.getNumericCellValue(), 0.0001); // WARNING - this is wrong! // The file name should be showing, but bug #45970 is fixed @@ -210,8 +210,8 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator { // Simple reference to a name in another file cell = wb1.getSheetAt(0).getRow(1).getCell(4); - assertEquals(CellType.FORMULA, cell.getCellType()); - assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); + assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum()); assertEquals(36.90, cell.getNumericCellValue(), 0.0001); // TODO Correct this! // The file name should be shown too, see bug #56742 @@ -237,14 +237,14 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator { // Re-check VLOOKUP one cell = wb1.getSheetAt(0).getRow(1).getCell(2); - assertEquals(CellType.FORMULA, cell.getCellType()); - assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); + assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum()); assertEquals(12.30, cell.getNumericCellValue(), 0.0001); // Re-check ref one cell = wb1.getSheetAt(0).getRow(1).getCell(4); - assertEquals(CellType.FORMULA, cell.getCellType()); - assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); + assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum()); assertEquals(36.90, cell.getNumericCellValue(), 0.0001); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java index 405347a9bc..b95c576a99 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java @@ -392,7 +392,7 @@ public final class TestWorkbook { HSSFSheet s = wb.getSheetAt(0); HSSFCell c = s.getRow(0).getCell(0); - assertEquals(CellType.NUMERIC, c.getCellType()); + assertEquals(CellType.NUMERIC, c.getCellTypeEnum()); wb.close(); } diff --git a/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java b/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java index 004097c822..b6a9dd6994 100644 --- a/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java +++ b/src/testcases/org/apache/poi/ss/formula/TestMissingWorkbook.java @@ -67,7 +67,7 @@ public class TestMissingWorkbook extends TestCase { Row lARow = lSheet.getRow(0); Cell lA1Cell = lARow.getCell(0); - assertEquals(CellType.FORMULA, lA1Cell.getCellType()); + assertEquals(CellType.FORMULA, lA1Cell.getCellTypeEnum()); try { evaluator.evaluateFormulaCell(lA1Cell); fail("Missing external workbook reference exception expected!"); @@ -82,9 +82,9 @@ public class TestMissingWorkbook extends TestCase { Cell lB1Cell = lSheet.getRow(1).getCell(0); Cell lC1Cell = lSheet.getRow(2).getCell(0); - assertEquals(CellType.FORMULA, lA1Cell.getCellType()); - assertEquals(CellType.FORMULA, lB1Cell.getCellType()); - assertEquals(CellType.FORMULA, lC1Cell.getCellType()); + assertEquals(CellType.FORMULA, lA1Cell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, lB1Cell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, lC1Cell.getCellTypeEnum()); // Check cached values assertEquals(10.0d, lA1Cell.getNumericCellValue(), 0.00001d); @@ -111,9 +111,9 @@ public class TestMissingWorkbook extends TestCase { Cell lB1Cell = lSheet.getRow(1).getCell(0); Cell lC1Cell = lSheet.getRow(2).getCell(0); - assertEquals(CellType.FORMULA, lA1Cell.getCellType()); - assertEquals(CellType.FORMULA, lB1Cell.getCellType()); - assertEquals(CellType.FORMULA, lC1Cell.getCellType()); + assertEquals(CellType.FORMULA, lA1Cell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, lB1Cell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, lC1Cell.getCellTypeEnum()); FormulaEvaluator lMainWorkbookEvaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator(); FormulaEvaluator lSourceEvaluator = sourceWorkbook.getCreationHelper().createFormulaEvaluator(); diff --git a/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java b/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java index 18f79f1a69..30f7c6fd49 100644 --- a/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java +++ b/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java @@ -365,7 +365,7 @@ public class TestWorkbookEvaluator { CellValue result = eval.evaluate(D1); // Call should not modify the contents - assertEquals(CellType.FORMULA, D1.getCellType()); + assertEquals(CellType.FORMULA, D1.getCellTypeEnum()); assertEquals(expectedFormula, D1.getCellFormula()); assertEquals(CellType.NUMERIC, result.getCellType()); @@ -514,10 +514,10 @@ public class TestWorkbookEvaluator { CellType resultCellType = eval.evaluateFormulaCell(D1); // Call should modify the contents, but leave the formula intact - assertEquals(CellType.FORMULA, D1.getCellType()); + assertEquals(CellType.FORMULA, D1.getCellTypeEnum()); assertEquals(expectedFormula, D1.getCellFormula()); assertEquals(CellType.NUMERIC, resultCellType); - assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultType()); + assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultTypeEnum()); assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON); testIFEqualsFormulaEvaluation_teardown(wb); @@ -537,7 +537,7 @@ public class TestWorkbookEvaluator { D1.getCellFormula(); fail("cell formula should be overwritten with formula result"); } catch (final IllegalStateException expected) { } - assertEquals(CellType.NUMERIC, D1.getCellType()); + assertEquals(CellType.NUMERIC, D1.getCellTypeEnum()); assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON); testIFEqualsFormulaEvaluation_teardown(wb); @@ -552,10 +552,10 @@ public class TestWorkbookEvaluator { eval.evaluateAll(); // Call should modify the contents - assertEquals(CellType.FORMULA, D1.getCellType()); + assertEquals(CellType.FORMULA, D1.getCellTypeEnum()); assertEquals(expectedFormula, D1.getCellFormula()); - assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultType()); + assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultTypeEnum()); assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON); testIFEqualsFormulaEvaluation_teardown(wb); @@ -569,11 +569,11 @@ public class TestWorkbookEvaluator { HSSFFormulaEvaluator.evaluateAllFormulaCells(wb); // Call should modify the contents - assertEquals(CellType.FORMULA, D1.getCellType()); + assertEquals(CellType.FORMULA, D1.getCellTypeEnum()); // whitespace gets deleted because formula is parsed and re-rendered assertEquals(expectedFormula, D1.getCellFormula()); - assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultType()); + assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultTypeEnum()); assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON); testIFEqualsFormulaEvaluation_teardown(wb); diff --git a/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java b/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java index 802b7d8b33..1ddf81ef52 100644 --- a/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java +++ b/src/testcases/org/apache/poi/ss/formula/atp/TestRandBetween.java @@ -131,7 +131,7 @@ public class TestRandBetween extends TestCase { formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)"); evaluator.clearAllCachedResultValues(); evaluator.evaluateFormulaCell(formulaCell); - assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType()); + assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum()); assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue()); @@ -141,7 +141,7 @@ public class TestRandBetween extends TestCase { formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)"); evaluator.clearAllCachedResultValues(); evaluator.evaluateFormulaCell(formulaCell); - assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType()); + assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum()); assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue()); // Check case where both inputs are of wrong type @@ -150,7 +150,7 @@ public class TestRandBetween extends TestCase { formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)"); evaluator.clearAllCachedResultValues(); evaluator.evaluateFormulaCell(formulaCell); - assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType()); + assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum()); assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue()); } @@ -166,14 +166,14 @@ public class TestRandBetween extends TestCase { formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)"); evaluator.clearAllCachedResultValues(); evaluator.evaluateFormulaCell(formulaCell); - assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType()); + assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum()); assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue()); bottomValueCell.setCellValue(1); topValueCell.setCellType(CellType.BLANK); formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)"); evaluator.clearAllCachedResultValues(); evaluator.evaluateFormulaCell(formulaCell); - assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType()); + assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultTypeEnum()); assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue()); } diff --git a/src/testcases/org/apache/poi/ss/formula/atp/TestYearFracCalculatorFromSpreadsheet.java b/src/testcases/org/apache/poi/ss/formula/atp/TestYearFracCalculatorFromSpreadsheet.java index f52d0728e6..f683e5dbf7 100644 --- a/src/testcases/org/apache/poi/ss/formula/atp/TestYearFracCalculatorFromSpreadsheet.java +++ b/src/testcases/org/apache/poi/ss/formula/atp/TestYearFracCalculatorFromSpreadsheet.java @@ -63,7 +63,7 @@ public final class TestYearFracCalculatorFromSpreadsheet { HSSFRow row = (HSSFRow) rowIterator.next(); HSSFCell cell = row.getCell(SS.YEARFRAC_FORMULA_COLUMN); - if (cell == null || cell.getCellType() != CellType.FORMULA) { + if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) { continue; } processRow(row, cell, formulaEvaluator); diff --git a/src/testcases/org/apache/poi/ss/formula/eval/TestFormulasFromSpreadsheet.java b/src/testcases/org/apache/poi/ss/formula/eval/TestFormulasFromSpreadsheet.java index 8457a07d94..fb3b6a9288 100644 --- a/src/testcases/org/apache/poi/ss/formula/eval/TestFormulasFromSpreadsheet.java +++ b/src/testcases/org/apache/poi/ss/formula/eval/TestFormulasFromSpreadsheet.java @@ -174,7 +174,7 @@ public final class TestFormulasFromSpreadsheet { // iterate across the row for all the evaluation cases for (int colnum=SS.COLUMN_INDEX_FIRST_TEST_VALUE; colnum < endcolnum; colnum++) { Cell c = formulasRow.getCell(colnum); - if (c == null || c.getCellType() != CellType.FORMULA) { + if (c == null || c.getCellTypeEnum() != CellType.FORMULA) { continue; } @@ -187,7 +187,7 @@ public final class TestFormulasFromSpreadsheet { assertNotNull(msg + " - Bad setup data expected value is null", expValue); assertNotNull(msg + " - actual value was null", actValue); - final CellType cellType = expValue.getCellType(); + final CellType cellType = expValue.getCellTypeEnum(); switch (cellType) { case BLANK: assertEquals(msg, CellType.BLANK, actValue.getCellType()); @@ -228,14 +228,14 @@ public final class TestFormulasFromSpreadsheet { System.err.println("Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name"); return null; } - if(cell.getCellType() == CellType.BLANK) { + if(cell.getCellTypeEnum() == CellType.BLANK) { return null; } - if(cell.getCellType() == CellType.STRING) { + if(cell.getCellTypeEnum() == CellType.STRING) { return cell.getRichStringCellValue().getString(); } throw new AssertionFailedError("Bad cell type for 'function name' column: (" - + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")"); + + cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")"); } } diff --git a/src/testcases/org/apache/poi/ss/formula/eval/TestMultiSheetEval.java b/src/testcases/org/apache/poi/ss/formula/eval/TestMultiSheetEval.java index bb9b6a85ba..429f5616e3 100644 --- a/src/testcases/org/apache/poi/ss/formula/eval/TestMultiSheetEval.java +++ b/src/testcases/org/apache/poi/ss/formula/eval/TestMultiSheetEval.java @@ -106,7 +106,7 @@ public final class TestMultiSheetEval extends TestCase { throw new AssertionFailedError(msg + " - actual value was null"); } - final CellType cellType = expected.getCellType(); + final CellType cellType = expected.getCellTypeEnum(); switch (cellType) { case BLANK: @@ -231,7 +231,7 @@ public final class TestMultiSheetEval extends TestCase { int result = Result.NO_EVALUATIONS_FOUND; // so far Cell c = formulasRow.getCell(SS.COLUMN_INDEX_ACTUAL_VALUE); - if (c == null || c.getCellType() != CellType.FORMULA) { + if (c == null || c.getCellTypeEnum() != CellType.FORMULA) { return result; } @@ -300,15 +300,15 @@ public final class TestMultiSheetEval extends TestCase { System.err.println("Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name"); return null; } - if(cell.getCellType() == CellType.BLANK) { + if(cell.getCellTypeEnum() == CellType.BLANK) { return null; } - if(cell.getCellType() == CellType.STRING) { + if(cell.getCellTypeEnum() == CellType.STRING) { return cell.getRichStringCellValue().getString(); } throw new AssertionFailedError("Bad cell type for 'function name' column: (" - + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")"); + + cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")"); } /** * @return null if cell is missing, empty or blank @@ -323,15 +323,15 @@ public final class TestMultiSheetEval extends TestCase { System.err.println("Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_TEST_NAME + ", can't figure out test name"); return null; } - if(cell.getCellType() == CellType.BLANK) { + if(cell.getCellTypeEnum() == CellType.BLANK) { return null; } - if(cell.getCellType() == CellType.STRING) { + if(cell.getCellTypeEnum() == CellType.STRING) { return cell.getRichStringCellValue().getString(); } throw new AssertionFailedError("Bad cell type for 'test name' column: (" - + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")"); + + cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")"); } } diff --git a/src/testcases/org/apache/poi/ss/formula/functions/BaseTestFunctionsFromSpreadsheet.java b/src/testcases/org/apache/poi/ss/formula/functions/BaseTestFunctionsFromSpreadsheet.java index 4fed4d48f9..8c40581e4a 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/BaseTestFunctionsFromSpreadsheet.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/BaseTestFunctionsFromSpreadsheet.java @@ -123,7 +123,7 @@ public abstract class BaseTestFunctionsFromSpreadsheet { currentGroupComment = newMarkerValue; } HSSFCell evalCell = r.getCell(SS.COLUMN_INDEX_EVALUATION); - if (evalCell == null || evalCell.getCellType() != CellType.FORMULA) { + if (evalCell == null || evalCell.getCellTypeEnum() != CellType.FORMULA) { continue; } String rowComment = getCellTextValue(r, SS.COLUMN_ROW_COMMENT, "row comment"); @@ -153,7 +153,7 @@ public abstract class BaseTestFunctionsFromSpreadsheet { assertNotNull(msg + " - Bad setup data expected value is null", expectedCell); assertNotNull(msg + " - actual value was null", actualValue); - if (expectedCell.getCellType() == CellType.ERROR) { + if (expectedCell.getCellTypeEnum() == CellType.ERROR) { int expectedErrorCode = expectedCell.getErrorCellValue(); assertEquals(msg, CellType.ERROR, actualValue.getCellType()); assertEquals(msg, ErrorEval.getText(expectedErrorCode), actualValue.formatAsString()); @@ -167,9 +167,9 @@ public abstract class BaseTestFunctionsFromSpreadsheet { assertNotEquals(msg, formatValue(expectedCell), ErrorEval.getText(actualValue.getErrorValue())); // wrong type error - assertEquals(msg, expectedCell.getCellType(), actualValue.getCellType()); + assertEquals(msg, expectedCell.getCellTypeEnum(), actualValue.getCellType()); - final CellType expectedCellType = expectedCell.getCellType(); + final CellType expectedCellType = expectedCell.getCellTypeEnum(); switch (expectedCellType) { case BOOLEAN: assertEquals(msg, expectedCell.getBooleanCellValue(), actualValue.getBooleanValue()); @@ -212,25 +212,25 @@ public abstract class BaseTestFunctionsFromSpreadsheet { if(cell == null) { return null; } - if(cell.getCellType() == CellType.BLANK) { + if(cell.getCellTypeEnum() == CellType.BLANK) { return null; } - if(cell.getCellType() == CellType.STRING) { + if(cell.getCellTypeEnum() == CellType.STRING) { return cell.getRichStringCellValue().getString(); } fail("Bad cell type for '" + columnName + "' column: (" - + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")"); + + cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")"); return ""; } private static String formatValue(HSSFCell expecedCell) { - switch (expecedCell.getCellType()) { + switch (expecedCell.getCellTypeEnum()) { case BLANK: return ""; case BOOLEAN: return Boolean.toString(expecedCell.getBooleanCellValue()); case NUMERIC: return Double.toString(expecedCell.getNumericCellValue()); case STRING: return expecedCell.getRichStringCellValue().getString(); - default: fail("Unexpected cell type of expected value (" + expecedCell.getCellType() + ")"); + default: fail("Unexpected cell type of expected value (" + expecedCell.getCellTypeEnum() + ")"); } return ""; } diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java b/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java index 6dff5eda3c..39b1f28acd 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestCountFuncs.java @@ -505,9 +505,9 @@ public final class TestCountFuncs extends TestCase { for (int rowIx=7; rowIx<=12; rowIx++) { HSSFRow row = sheet1.getRow(rowIx-1); HSSFCell cellA = row.getCell(0); // cell containing a formula with COUNTIF - assertEquals(CellType.FORMULA, cellA.getCellType()); + assertEquals(CellType.FORMULA, cellA.getCellTypeEnum()); HSSFCell cellC = row.getCell(2); // cell with a reference value - assertEquals(CellType.NUMERIC, cellC.getCellType()); + assertEquals(CellType.NUMERIC, cellC.getCellTypeEnum()); CellValue cv = fe.evaluate(cellA); double actualValue = cv.getNumberValue(); @@ -523,9 +523,9 @@ public final class TestCountFuncs extends TestCase { for (int rowIx=9; rowIx<=14; rowIx++) { HSSFRow row = sheet2.getRow(rowIx-1); HSSFCell cellA = row.getCell(0); // cell containing a formula with COUNTIF - assertEquals(CellType.FORMULA, cellA.getCellType()); + assertEquals(CellType.FORMULA, cellA.getCellTypeEnum()); HSSFCell cellC = row.getCell(2); // cell with a reference value - assertEquals(CellType.NUMERIC, cellC.getCellType()); + assertEquals(CellType.NUMERIC, cellC.getCellTypeEnum()); CellValue cv = fe.evaluate(cellA); double actualValue = cv.getNumberValue(); diff --git a/src/testcases/org/apache/poi/ss/formula/functions/TestNper.java b/src/testcases/org/apache/poi/ss/formula/functions/TestNper.java index ec5553d84c..55c2714d0c 100644 --- a/src/testcases/org/apache/poi/ss/formula/functions/TestNper.java +++ b/src/testcases/org/apache/poi/ss/formula/functions/TestNper.java @@ -58,12 +58,12 @@ public final class TestNper { cell.setCellFormula("NPER(12,4500,100000,100000)"); cell.setCellValue(15.0); assertEquals("NPER(12,4500,100000,100000)", cell.getCellFormula()); - assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType()); + assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultTypeEnum()); assertEquals(15.0, cell.getNumericCellValue(), 0.0); HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb); fe.evaluateFormulaCell(cell); - assertEquals(CellType.ERROR, cell.getCachedFormulaResultType()); + assertEquals(CellType.ERROR, cell.getCachedFormulaResultTypeEnum()); assertEquals(FormulaError.NUM.getCode(), cell.getErrorCellValue()); wb.close(); } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java index 68f9873159..f5c3087a96 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java @@ -952,7 +952,7 @@ public abstract class BaseTestBugzillaIssues { assertEquals(1, cArray.length);*/ Cell cell = row.getCell(0); - assertEquals(CellType.FORMULA, cell.getCellType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); } { // overwrite the row @@ -1136,12 +1136,12 @@ public abstract class BaseTestBugzillaIssues { fe.evaluateFormulaCell(cfs); // Now test - assertEquals(CellType.NUMERIC, cn.getCellType()); - assertEquals(CellType.STRING, cs.getCellType()); - assertEquals(CellType.FORMULA, cfn.getCellType()); - assertEquals(CellType.NUMERIC, cfn.getCachedFormulaResultType()); - assertEquals(CellType.FORMULA, cfs.getCellType()); - assertEquals(CellType.STRING, cfs.getCachedFormulaResultType()); + assertEquals(CellType.NUMERIC, cn.getCellTypeEnum()); + assertEquals(CellType.STRING, cs.getCellTypeEnum()); + assertEquals(CellType.FORMULA, cfn.getCellTypeEnum()); + assertEquals(CellType.NUMERIC, cfn.getCachedFormulaResultTypeEnum()); + assertEquals(CellType.FORMULA, cfs.getCellTypeEnum()); + assertEquals(CellType.STRING, cfs.getCachedFormulaResultTypeEnum()); // Different ways of retrieving assertEquals(1.2, cn.getNumericCellValue(), 0); @@ -1383,7 +1383,7 @@ public abstract class BaseTestBugzillaIssues { Sheet s = wb.createSheet(); Cell cell = s.createRow(0).createCell(0); cell.setCellValue((String)null); - assertEquals(CellType.BLANK, cell.getCellType()); + assertEquals(CellType.BLANK, cell.getCellTypeEnum()); _testDataProvider.trackAllColumnsForAutosizing(s); @@ -1554,8 +1554,8 @@ public abstract class BaseTestBugzillaIssues { Cell cell = row.getCell(cellId); System.out.println("Formula:" + cell.getCellFormula()); - if (CellType.FORMULA == cell.getCellType()) { - CellType formulaResultType = cell.getCachedFormulaResultType(); + if (CellType.FORMULA == cell.getCellTypeEnum()) { + CellType formulaResultType = cell.getCachedFormulaResultTypeEnum(); System.out.println("Formula Result Type:" + formulaResultType); } @@ -1569,8 +1569,8 @@ public abstract class BaseTestBugzillaIssues { cell = row.getCell(cellId); System.out.println("Formula:" + cell.getCellFormula()); - if (CellType.FORMULA == cell.getCellType()) { - CellType formulaResultType = cell.getCachedFormulaResultType(); + if (CellType.FORMULA == cell.getCellTypeEnum()) { + CellType formulaResultType = cell.getCachedFormulaResultTypeEnum(); System.out.println("Formula Result Type:" + formulaResultType); } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java index 9570341fd6..4d33aa36c1 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestCell.java @@ -60,13 +60,13 @@ public abstract class BaseTestCell { cell.setCellValue(1.2); assertEquals(1.2, cell.getNumericCellValue(), 0.0001); - assertEquals(CellType.NUMERIC, cell.getCellType()); + assertEquals(CellType.NUMERIC, cell.getCellTypeEnum()); assertProhibitedValueAccess(cell, CellType.BOOLEAN, CellType.STRING, CellType.FORMULA, CellType.ERROR); cell.setCellValue(false); assertEquals(false, cell.getBooleanCellValue()); - assertEquals(CellType.BOOLEAN, cell.getCellType()); + assertEquals(CellType.BOOLEAN, cell.getCellTypeEnum()); cell.setCellValue(true); assertEquals(true, cell.getBooleanCellValue()); assertProhibitedValueAccess(cell, CellType.NUMERIC, CellType.STRING, @@ -75,14 +75,14 @@ public abstract class BaseTestCell { cell.setCellValue(factory.createRichTextString("Foo")); assertEquals("Foo", cell.getRichStringCellValue().getString()); assertEquals("Foo", cell.getStringCellValue()); - assertEquals(CellType.STRING, cell.getCellType()); + assertEquals(CellType.STRING, cell.getCellTypeEnum()); assertProhibitedValueAccess(cell, CellType.NUMERIC, CellType.BOOLEAN, CellType.FORMULA, CellType.ERROR); cell.setCellValue("345"); assertEquals("345", cell.getRichStringCellValue().getString()); assertEquals("345", cell.getStringCellValue()); - assertEquals(CellType.STRING, cell.getCellType()); + assertEquals(CellType.STRING, cell.getCellTypeEnum()); assertProhibitedValueAccess(cell, CellType.NUMERIC, CellType.BOOLEAN, CellType.FORMULA, CellType.ERROR); @@ -90,19 +90,19 @@ public abstract class BaseTestCell { c.setTimeInMillis(123456789); cell.setCellValue(c.getTime()); assertEquals(c.getTime().getTime(), cell.getDateCellValue().getTime()); - assertEquals(CellType.NUMERIC, cell.getCellType()); + assertEquals(CellType.NUMERIC, cell.getCellTypeEnum()); assertProhibitedValueAccess(cell, CellType.BOOLEAN, CellType.STRING, CellType.FORMULA, CellType.ERROR); cell.setCellValue(c); assertEquals(c.getTime().getTime(), cell.getDateCellValue().getTime()); - assertEquals(CellType.NUMERIC, cell.getCellType()); + assertEquals(CellType.NUMERIC, cell.getCellTypeEnum()); assertProhibitedValueAccess(cell, CellType.BOOLEAN, CellType.STRING, CellType.FORMULA, CellType.ERROR); cell.setCellErrorValue(FormulaError.NA.getCode()); assertEquals(FormulaError.NA.getCode(), cell.getErrorCellValue()); - assertEquals(CellType.ERROR, cell.getCellType()); + assertEquals(CellType.ERROR, cell.getCellTypeEnum()); assertProhibitedValueAccess(cell, CellType.NUMERIC, CellType.BOOLEAN, CellType.FORMULA, CellType.STRING); @@ -176,13 +176,13 @@ public abstract class BaseTestCell { c = r.getCell(1); assertEquals(0, c.getRowIndex()); assertEquals(1, c.getColumnIndex()); - assertEquals(CellType.BOOLEAN, c.getCellType()); + assertEquals(CellType.BOOLEAN, c.getCellTypeEnum()); assertEquals("B1 value", true, c.getBooleanCellValue()); c = r.getCell(2); assertEquals(0, c.getRowIndex()); assertEquals(2, c.getColumnIndex()); - assertEquals(CellType.BOOLEAN, c.getCellType()); + assertEquals(CellType.BOOLEAN, c.getCellTypeEnum()); assertEquals("C1 value", false, c.getBooleanCellValue()); wb2.close(); @@ -226,13 +226,13 @@ public abstract class BaseTestCell { c = r.getCell(1); assertEquals(0, c.getRowIndex()); assertEquals(1, c.getColumnIndex()); - assertEquals(CellType.ERROR, c.getCellType()); + assertEquals(CellType.ERROR, c.getCellTypeEnum()); assertEquals("B1 value == #NULL!", FormulaError.NULL.getCode(), c.getErrorCellValue()); c = r.getCell(2); assertEquals(0, c.getRowIndex()); assertEquals(2, c.getColumnIndex()); - assertEquals(CellType.ERROR, c.getCellType()); + assertEquals(CellType.ERROR, c.getCellTypeEnum()); assertEquals("C1 value == #DIV/0!", FormulaError.DIV0.getCode(), c.getErrorCellValue()); wb2.close(); @@ -272,7 +272,7 @@ public abstract class BaseTestCell { r = s.getRow(0); c = r.getCell(0); - assertEquals("Formula Cell at 0,0", CellType.FORMULA, c.getCellType()); + assertEquals("Formula Cell at 0,0", CellType.FORMULA, c.getCellTypeEnum()); cs = c.getCellStyle(); assertNotNull("Formula Cell Style", cs); @@ -347,25 +347,25 @@ public abstract class BaseTestCell { Cell c1 = r.createCell(0); c1.setCellFormula("NA()"); assertEquals(0.0, c1.getNumericCellValue(), 0.0); - assertEquals(CellType.NUMERIC, c1.getCachedFormulaResultType()); + assertEquals(CellType.NUMERIC, c1.getCachedFormulaResultTypeEnum()); c1.setCellValue(10); assertEquals(10.0, c1.getNumericCellValue(), 0.0); - assertEquals(CellType.FORMULA, c1.getCellType()); - assertEquals(CellType.NUMERIC, c1.getCachedFormulaResultType()); + assertEquals(CellType.FORMULA, c1.getCellTypeEnum()); + assertEquals(CellType.NUMERIC, c1.getCachedFormulaResultTypeEnum()); Cell c2 = r.createCell(1); c2.setCellFormula("NA()"); assertEquals(0.0, c2.getNumericCellValue(), 0.0); - assertEquals(CellType.NUMERIC, c2.getCachedFormulaResultType()); + assertEquals(CellType.NUMERIC, c2.getCachedFormulaResultTypeEnum()); c2.setCellValue("I changed!"); assertEquals("I changed!", c2.getStringCellValue()); - assertEquals(CellType.FORMULA, c2.getCellType()); - assertEquals(CellType.STRING, c2.getCachedFormulaResultType()); + assertEquals(CellType.FORMULA, c2.getCellTypeEnum()); + assertEquals(CellType.STRING, c2.getCachedFormulaResultTypeEnum()); //calglin Cell.setCellFormula(null) for a non-formula cell Cell c3 = r.createCell(2); c3.setCellFormula(null); - assertEquals(CellType.BLANK, c3.getCellType()); + assertEquals(CellType.BLANK, c3.getCellTypeEnum()); wb.close(); } @@ -420,11 +420,11 @@ public abstract class BaseTestCell { Cell cell = createACell(wb); cell.setCellValue("TRUE"); - assertEquals(CellType.STRING, cell.getCellType()); + assertEquals(CellType.STRING, cell.getCellTypeEnum()); // test conversion of cell from text to boolean cell.setCellType(CellType.BOOLEAN); - assertEquals(CellType.BOOLEAN, cell.getCellType()); + assertEquals(CellType.BOOLEAN, cell.getCellTypeEnum()); assertEquals(true, cell.getBooleanCellValue()); cell.setCellType(CellType.STRING); assertEquals("TRUE", cell.getRichStringCellValue().getString()); @@ -432,7 +432,7 @@ public abstract class BaseTestCell { // 'false' text to bool and back cell.setCellValue("FALSE"); cell.setCellType(CellType.BOOLEAN); - assertEquals(CellType.BOOLEAN, cell.getCellType()); + assertEquals(CellType.BOOLEAN, cell.getCellTypeEnum()); assertEquals(false, cell.getBooleanCellValue()); cell.setCellType(CellType.STRING); assertEquals("FALSE", cell.getRichStringCellValue().getString()); @@ -589,17 +589,17 @@ public abstract class BaseTestCell { cell = row.createCell(0, CellType.NUMERIC); cell.setCellValue(1.0); - assertEquals(CellType.NUMERIC, cell.getCellType()); + assertEquals(CellType.NUMERIC, cell.getCellTypeEnum()); assertEquals(1.0, cell.getNumericCellValue(), 0.0); cell = row.createCell(1, CellType.NUMERIC); cell.setCellValue(2.0); - assertEquals(CellType.NUMERIC, cell.getCellType()); + assertEquals(CellType.NUMERIC, cell.getCellTypeEnum()); assertEquals(2.0, cell.getNumericCellValue(), 0.0); cell = row.createCell(2, CellType.FORMULA); cell.setCellFormula("SUM(A1:B1)"); - assertEquals(CellType.FORMULA, cell.getCellType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("SUM(A1:B1)", cell.getCellFormula()); //serialize and check again @@ -607,15 +607,15 @@ public abstract class BaseTestCell { wb1.close(); row = wb2.getSheetAt(0).getRow(0); cell = row.getCell(0); - assertEquals(CellType.NUMERIC, cell.getCellType()); + assertEquals(CellType.NUMERIC, cell.getCellTypeEnum()); assertEquals(1.0, cell.getNumericCellValue(), 0.0); cell = row.getCell(1); - assertEquals(CellType.NUMERIC, cell.getCellType()); + assertEquals(CellType.NUMERIC, cell.getCellTypeEnum()); assertEquals(2.0, cell.getNumericCellValue(), 0.0); cell = row.getCell(2); - assertEquals(CellType.FORMULA, cell.getCellType()); + assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); assertEquals("SUM(A1:B1)", cell.getCellFormula()); wb2.close(); } @@ -672,17 +672,17 @@ public abstract class BaseTestCell { Cell cell0 = row.createCell(0); cell0.setCellValue(Double.NaN); - assertEquals("Double.NaN should change cell type to CellType#ERROR", CellType.ERROR, cell0.getCellType()); + assertEquals("Double.NaN should change cell type to CellType#ERROR", CellType.ERROR, cell0.getCellTypeEnum()); assertEquals("Double.NaN should change cell value to #NUM!", FormulaError.NUM, forInt(cell0.getErrorCellValue())); Cell cell1 = row.createCell(1); cell1.setCellValue(Double.POSITIVE_INFINITY); - assertEquals("Double.POSITIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell1.getCellType()); + assertEquals("Double.POSITIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell1.getCellTypeEnum()); assertEquals("Double.POSITIVE_INFINITY should change cell value to #DIV/0!", FormulaError.DIV0, forInt(cell1.getErrorCellValue())); Cell cell2 = row.createCell(2); cell2.setCellValue(Double.NEGATIVE_INFINITY); - assertEquals("Double.NEGATIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell2.getCellType()); + assertEquals("Double.NEGATIVE_INFINITY should change cell type to CellType#ERROR", CellType.ERROR, cell2.getCellTypeEnum()); assertEquals("Double.NEGATIVE_INFINITY should change cell value to #DIV/0!", FormulaError.DIV0, forInt(cell2.getErrorCellValue())); Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1); @@ -690,15 +690,15 @@ public abstract class BaseTestCell { row = wb2.getSheetAt(0).getRow(0); cell0 = row.getCell(0); - assertEquals(CellType.ERROR, cell0.getCellType()); + assertEquals(CellType.ERROR, cell0.getCellTypeEnum()); assertEquals(FormulaError.NUM, forInt(cell0.getErrorCellValue())); cell1 = row.getCell(1); - assertEquals(CellType.ERROR, cell1.getCellType()); + assertEquals(CellType.ERROR, cell1.getCellTypeEnum()); assertEquals(FormulaError.DIV0, forInt(cell1.getErrorCellValue())); cell2 = row.getCell(2); - assertEquals(CellType.ERROR, cell2.getCellType()); + assertEquals(CellType.ERROR, cell2.getCellTypeEnum()); assertEquals(FormulaError.DIV0, forInt(cell2.getErrorCellValue())); wb2.close(); } @@ -899,21 +899,21 @@ public abstract class BaseTestCell { RichTextString nullStr = null; cell.setCellValue(nullStr); assertEquals("", cell.getStringCellValue()); - assertEquals(CellType.BLANK, cell.getCellType()); + assertEquals(CellType.BLANK, cell.getCellTypeEnum()); cell = sheet.createRow(0).createCell(1); cell.setCellValue(1.2d); - assertEquals(CellType.NUMERIC, cell.getCellType()); + assertEquals(CellType.NUMERIC, cell.getCellTypeEnum()); cell.setCellValue(nullStr); assertEquals("", cell.getStringCellValue()); - assertEquals(CellType.BLANK, cell.getCellType()); + assertEquals(CellType.BLANK, cell.getCellTypeEnum()); cell = sheet.createRow(0).createCell(1); cell.setCellValue(wb.getCreationHelper().createRichTextString("Test")); - assertEquals(CellType.STRING, cell.getCellType()); + assertEquals(CellType.STRING, cell.getCellTypeEnum()); cell.setCellValue(nullStr); assertEquals("", cell.getStringCellValue()); - assertEquals(CellType.BLANK, cell.getCellType()); + assertEquals(CellType.BLANK, cell.getCellTypeEnum()); wb.close(); } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java index 27ac4c93a8..2492c20a81 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java @@ -256,36 +256,36 @@ public abstract class BaseTestRow { row.createCell(5).setCellValue(4); // First up, no policy given, uses default - assertEquals(CellType.STRING, row.getCell(0).getCellType()); - assertEquals(CellType.NUMERIC, row.getCell(1).getCellType()); + assertEquals(CellType.STRING, row.getCell(0).getCellTypeEnum()); + assertEquals(CellType.NUMERIC, row.getCell(1).getCellTypeEnum()); assertEquals(null, row.getCell(2)); assertEquals(null, row.getCell(3)); - assertEquals(CellType.BLANK, row.getCell(4).getCellType()); - assertEquals(CellType.NUMERIC, row.getCell(5).getCellType()); + assertEquals(CellType.BLANK, row.getCell(4).getCellTypeEnum()); + assertEquals(CellType.NUMERIC, row.getCell(5).getCellTypeEnum()); // RETURN_NULL_AND_BLANK - same as default - assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType()); - assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType()); + assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellTypeEnum()); + assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellTypeEnum()); assertEquals(null, row.getCell(2, MissingCellPolicy.RETURN_NULL_AND_BLANK)); assertEquals(null, row.getCell(3, MissingCellPolicy.RETURN_NULL_AND_BLANK)); - assertEquals(CellType.BLANK, row.getCell(4, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType()); - assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType()); + assertEquals(CellType.BLANK, row.getCell(4, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellTypeEnum()); + assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellTypeEnum()); // RETURN_BLANK_AS_NULL - nearly the same - assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType()); - assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType()); + assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellTypeEnum()); + assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellTypeEnum()); assertEquals(null, row.getCell(2, MissingCellPolicy.RETURN_BLANK_AS_NULL)); assertEquals(null, row.getCell(3, MissingCellPolicy.RETURN_BLANK_AS_NULL)); assertEquals(null, row.getCell(4, MissingCellPolicy.RETURN_BLANK_AS_NULL)); - assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType()); + assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellTypeEnum()); // CREATE_NULL_AS_BLANK - creates as needed - assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType()); - assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType()); - assertEquals(CellType.BLANK, row.getCell(2, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType()); - assertEquals(CellType.BLANK, row.getCell(3, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType()); - assertEquals(CellType.BLANK, row.getCell(4, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType()); - assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType()); + assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum()); + assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum()); + assertEquals(CellType.BLANK, row.getCell(2, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum()); + assertEquals(CellType.BLANK, row.getCell(3, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum()); + assertEquals(CellType.BLANK, row.getCell(4, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum()); + assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum()); // Check created ones get the right column assertEquals(0, row.getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getColumnIndex()); @@ -300,12 +300,12 @@ public abstract class BaseTestRow { // that that is now used if no policy given workbook.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL); - assertEquals(CellType.STRING, row.getCell(0).getCellType()); - assertEquals(CellType.NUMERIC, row.getCell(1).getCellType()); + assertEquals(CellType.STRING, row.getCell(0).getCellTypeEnum()); + assertEquals(CellType.NUMERIC, row.getCell(1).getCellTypeEnum()); assertEquals(null, row.getCell(2)); assertEquals(null, row.getCell(3)); assertEquals(null, row.getCell(4)); - assertEquals(CellType.NUMERIC, row.getCell(5).getCellType()); + assertEquals(CellType.NUMERIC, row.getCell(5).getCellTypeEnum()); workbook.close(); } @@ -420,7 +420,7 @@ public abstract class BaseTestRow { assertTrue(cell5 == it.next()); assertTrue(it.hasNext()); assertTrue(cell2 == it.next()); - assertEquals(CellType.STRING, cell5.getCellType()); + assertEquals(CellType.STRING, cell5.getCellTypeEnum()); wb.close(); } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java index f587b640a3..543a871ffe 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetAutosizeColumn.java @@ -344,7 +344,7 @@ public abstract class BaseTestSheetAutosizeColumn { Sheet sheet = workbook.getSheetAt(i); for (Row r : sheet) { for (Cell c : r) { - if (c.getCellType() == CellType.FORMULA){ + if (c.getCellTypeEnum() == CellType.FORMULA){ eval.evaluateFormulaCell(c); } } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java index 7bfc606ec3..5e2ad4a8df 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java @@ -133,7 +133,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { for(Cell acell : cells){ assertTrue(acell.isPartOfArrayFormulaGroup()); - assertEquals(CellType.FORMULA, acell.getCellType()); + assertEquals(CellType.FORMULA, acell.getCellTypeEnum()); assertEquals("SUM(A1:A3*B1:B3)", acell.getCellFormula()); //retrieve the range and check it is the same assertEquals(range.formatAsString(), acell.getArrayFormulaRange().formatAsString()); @@ -210,7 +210,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { for(Cell acell : cr){ assertFalse(acell.isPartOfArrayFormulaGroup()); - assertEquals(CellType.BLANK, acell.getCellType()); + assertEquals(CellType.BLANK, acell.getCellTypeEnum()); } // cells C4:C6 are not included in array formula, @@ -279,7 +279,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { CellRange srange = sheet.setArrayFormula("SUM(A4:A6,B4:B6)", CellRangeAddress.valueOf("B5")); Cell scell = srange.getTopLeftCell(); - assertEquals(CellType.FORMULA, scell.getCellType()); + assertEquals(CellType.FORMULA, scell.getCellTypeEnum()); assertEquals(0.0, scell.getNumericCellValue(), 0); scell.setCellValue(1.1); assertEquals(1.1, scell.getNumericCellValue(), 0); @@ -288,7 +288,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { CellRange mrange = sheet.setArrayFormula("A1:A3*B1:B3", CellRangeAddress.valueOf("C1:C3")); for(Cell mcell : mrange){ - assertEquals(CellType.FORMULA, mcell.getCellType()); + assertEquals(CellType.FORMULA, mcell.getCellTypeEnum()); assertEquals(0.0, mcell.getNumericCellValue(), 0); double fmlaResult = 1.2; mcell.setCellValue(fmlaResult); @@ -307,10 +307,10 @@ public abstract class BaseTestSheetUpdateArrayFormulas { CellRange srange = sheet.setArrayFormula("SUM(A4:A6,B4:B6)", CellRangeAddress.valueOf("B5")); Cell scell = srange.getTopLeftCell(); - assertEquals(CellType.FORMULA, scell.getCellType()); + assertEquals(CellType.FORMULA, scell.getCellTypeEnum()); assertEquals(0.0, scell.getNumericCellValue(), 0); scell.setCellType(CellType.STRING); - assertEquals(CellType.STRING, scell.getCellType()); + assertEquals(CellType.STRING, scell.getCellTypeEnum()); scell.setCellValue("string cell"); assertEquals("string cell", scell.getStringCellValue()); @@ -319,7 +319,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { sheet.setArrayFormula("A1:A3*B1:B3", CellRangeAddress.valueOf("C1:C3")); for(Cell mcell : mrange){ try { - assertEquals(CellType.FORMULA, mcell.getCellType()); + assertEquals(CellType.FORMULA, mcell.getCellTypeEnum()); mcell.setCellType(CellType.NUMERIC); fail("expected exception"); } catch (IllegalStateException e){ @@ -329,7 +329,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { } // a failed invocation of Cell.setCellType leaves the cell // in the state that it was in prior to the invocation - assertEquals(CellType.FORMULA, mcell.getCellType()); + assertEquals(CellType.FORMULA, mcell.getCellTypeEnum()); assertTrue(mcell.isPartOfArrayFormulaGroup()); } workbook.close(); @@ -344,13 +344,13 @@ public abstract class BaseTestSheetUpdateArrayFormulas { sheet.setArrayFormula("SUM(A4:A6,B4:B6)", CellRangeAddress.valueOf("B5")); Cell scell = srange.getTopLeftCell(); assertEquals("SUM(A4:A6,B4:B6)", scell.getCellFormula()); - assertEquals(CellType.FORMULA, scell.getCellType()); + assertEquals(CellType.FORMULA, scell.getCellTypeEnum()); assertTrue(scell.isPartOfArrayFormulaGroup()); scell.setCellFormula("SUM(A4,A6)"); //we are now a normal formula cell assertEquals("SUM(A4,A6)", scell.getCellFormula()); assertFalse(scell.isPartOfArrayFormulaGroup()); - assertEquals(CellType.FORMULA, scell.getCellType()); + assertEquals(CellType.FORMULA, scell.getCellTypeEnum()); //check that setting formula result works assertEquals(0.0, scell.getNumericCellValue(), 0); scell.setCellValue(33.0); @@ -396,7 +396,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { //re-create the removed cell scell = srow.createCell(cra.getFirstColumn()); - assertEquals(CellType.BLANK, scell.getCellType()); + assertEquals(CellType.BLANK, scell.getCellTypeEnum()); assertFalse(scell.isPartOfArrayFormulaGroup()); //we cannot remove cells included in a multi-cell array formula @@ -417,7 +417,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { // in the state that it was in prior to the invocation assertSame(mcell, mrow.getCell(columnIndex)); assertTrue(mcell.isPartOfArrayFormulaGroup()); - assertEquals(CellType.FORMULA, mcell.getCellType()); + assertEquals(CellType.FORMULA, mcell.getCellTypeEnum()); } workbook.close(); @@ -433,7 +433,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { CellRange srange = sheet.setArrayFormula("SUM(A4:A6,B4:B6)", cra); Cell scell = srange.getTopLeftCell(); - assertEquals(CellType.FORMULA, scell.getCellType()); + assertEquals(CellType.FORMULA, scell.getCellTypeEnum()); Row srow = scell.getRow(); assertSame(srow, sheet.getRow(cra.getFirstRow())); @@ -442,7 +442,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { //re-create the removed row and cell scell = sheet.createRow(cra.getFirstRow()).createCell(cra.getFirstColumn()); - assertEquals(CellType.BLANK, scell.getCellType()); + assertEquals(CellType.BLANK, scell.getCellTypeEnum()); assertFalse(scell.isPartOfArrayFormulaGroup()); //we cannot remove rows with cells included in a multi-cell array formula @@ -463,7 +463,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { assertSame(mrow, sheet.getRow(mrow.getRowNum())); assertSame(mcell, mrow.getCell(columnIndex)); assertTrue(mcell.isPartOfArrayFormulaGroup()); - assertEquals(CellType.FORMULA, mcell.getCellType()); + assertEquals(CellType.FORMULA, mcell.getCellTypeEnum()); } workbook.close(); @@ -481,7 +481,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { Cell scell = srange.getTopLeftCell(); sheet.addMergedRegion(CellRangeAddress.valueOf("B5:C6")); //we are still an array formula - assertEquals(CellType.FORMULA, scell.getCellType()); + assertEquals(CellType.FORMULA, scell.getCellTypeEnum()); assertTrue(scell.isPartOfArrayFormulaGroup()); assertEquals(1, sheet.getNumMergedRegions()); diff --git a/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java b/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java index 7a668b016d..d081db0fc3 100644 --- a/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java +++ b/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java @@ -50,7 +50,7 @@ public final class TestSheetBuilder extends TestCase { Row firstRow = sheet.getRow(0); Cell firstCell = firstRow.getCell(0); - assertEquals(firstCell.getCellType(), CellType.NUMERIC); + assertEquals(firstCell.getCellTypeEnum(), CellType.NUMERIC); assertEquals(1.0, firstCell.getNumericCellValue(), 0.00001); @@ -59,11 +59,11 @@ public final class TestSheetBuilder extends TestCase { assertNull(secondRow.getCell(2)); Row thirdRow = sheet.getRow(2); - assertEquals(CellType.STRING, thirdRow.getCell(0).getCellType()); + assertEquals(CellType.STRING, thirdRow.getCell(0).getCellTypeEnum()); String cellValue = thirdRow.getCell(0).getStringCellValue(); assertEquals(testData[2][0].toString(), cellValue); - assertEquals(CellType.FORMULA, thirdRow.getCell(2).getCellType()); + assertEquals(CellType.FORMULA, thirdRow.getCell(2).getCellTypeEnum()); assertEquals("A1+B2", thirdRow.getCell(2).getCellFormula()); } @@ -73,7 +73,7 @@ public final class TestSheetBuilder extends TestCase { Cell emptyCell = sheet.getRow(1).getCell(1); assertNotNull(emptyCell); - assertEquals(CellType.BLANK, emptyCell.getCellType()); + assertEquals(CellType.BLANK, emptyCell.getCellTypeEnum()); } public void testSheetName() { -- 2.39.5