update getCellType to return CellType enum instead of int

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808718 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2017-09-18 13:58:55 +00:00
parent 4a4c428b6b
commit 7dad60e9d4
46 changed files with 181 additions and 181 deletions

View File

@ -188,7 +188,7 @@ public final class HSSFReadWrite {
String value;
if(cell != null) {
switch (cell.getCellTypeEnum()) {
switch (cell.getCellType()) {
case FORMULA:
value = "FORMULA value=" + cell.getCellFormula();
@ -215,7 +215,7 @@ public final class HSSFReadWrite {
break;
default:
value = "UNKNOWN value of type " + cell.getCellTypeEnum();
value = "UNKNOWN value of type " + cell.getCellType();
}
System.out.println("CELL col=" + cell.getColumnIndex() + " VALUE="
+ value);

View File

@ -1012,7 +1012,7 @@ public class HSSFCell implements Cell {
case STRING:
return getStringCellValue();
default:
return "Unknown Cell Type: " + getCellTypeEnum();
return "Unknown Cell Type: " + getCellType();
}
}

View File

@ -388,7 +388,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
case RETURN_NULL_AND_BLANK:
return cell;
case RETURN_BLANK_AS_NULL:
boolean isBlank = (cell != null && cell.getCellTypeEnum() == CellType.BLANK);
boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK);
return (isBlank) ? null : cell;
case CREATE_NULL_AS_BLANK:
return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell;

View File

@ -93,7 +93,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
return null;
}
switch (cell.getCellTypeEnum()) {
switch (cell.getCellType()) {
case BOOLEAN:
return CellValue.valueOf(cell.getBooleanCellValue());
case ERROR:
@ -107,7 +107,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
case BLANK:
return null;
default:
throw new IllegalStateException("Bad cell type (" + cell.getCellTypeEnum() + ")");
throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
}
}
@ -124,7 +124,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
* </pre>
* Be aware that your cell value will be changed to hold the
* result of the formula. If you simply want the formula
* value computed for you, use {@link #evaluateFormulaCellEnum(Cell)}}
* value computed for you, use {@link #evaluateFormulaCell(Cell)}}
* @param cell
* @return the {@code cell} that was passed in, allowing for chained calls
*/
@ -133,7 +133,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
if (cell == null) {
return null;
}
if (cell.getCellTypeEnum() == CellType.FORMULA) {
if (cell.getCellType() == CellType.FORMULA) {
CellValue cv = evaluateFormulaCellValue(cell);
setCellValue(cell, cv);
setCellType(cell, cv); // cell will no longer be a formula cell
@ -153,7 +153,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
* so you know what kind of value is also stored with
* the formula.
* <pre>
* CellType evaluatedCellType = evaluator.evaluateFormulaCellEnum(cell);
* CellType evaluatedCellType = evaluator.evaluateFormulaCell(cell);
* </pre>
* Be aware that your cell will hold both the formula,
* and the result. If you want the cell replaced with
@ -164,13 +164,13 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
*/
@Override
public CellType evaluateFormulaCell(Cell cell) {
if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) {
if (cell == null || cell.getCellType() != CellType.FORMULA) {
return CellType._NONE;
}
CellValue cv = evaluateFormulaCellValue(cell);
// cell remains a formula cell, but the cached value is changed
setCellValue(cell, cv);
return cv.getCellTypeEnum();
return cv.getCellType();
}
/**
@ -183,7 +183,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
* so you know what kind of value is also stored with
* the formula.
* <pre>
* CellType evaluatedCellType = evaluator.evaluateFormulaCellEnum(cell);
* CellType evaluatedCellType = evaluator.evaluateFormulaCell(cell);
* </pre>
* Be aware that your cell will hold both the formula,
* and the result. If you want the cell replaced with
@ -202,7 +202,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
}
protected static void setCellType(Cell cell, CellValue cv) {
CellType cellType = cv.getCellTypeEnum();
CellType cellType = cv.getCellType();
switch (cellType) {
case BOOLEAN:
case ERROR:
@ -224,7 +224,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
protected abstract RichTextString createRichTextString(String str);
protected void setCellValue(Cell cell, CellValue cv) {
CellType cellType = cv.getCellTypeEnum();
CellType cellType = cv.getCellType();
switch (cellType) {
case BOOLEAN:
cell.setCellValue(cv.getBooleanValue());
@ -269,8 +269,8 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook
for(Row r : sheet) {
for (Cell c : r) {
if (c.getCellTypeEnum() == CellType.FORMULA) {
evaluator.evaluateFormulaCellEnum(c);
if (c.getCellType() == CellType.FORMULA) {
evaluator.evaluateFormulaCell(c);
}
}
}

View File

@ -56,7 +56,7 @@ final class EvaluationCache {
Loc loc = new Loc(bookIndex, sheetIndex, rowIndex, columnIndex);
PlainValueCellCacheEntry pcce = _plainCellCache.get(loc);
if (cell.getCellTypeEnum() == CellType.FORMULA) {
if (cell.getCellType() == 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.getCellTypeEnum() == CellType.FORMULA) {
if (cell.getCellType() == CellType.FORMULA) {
FormulaCellCacheEntry fcce = _formulaCellCache.remove(cell);
if (fcce == null) {
// formula cell has not been evaluated yet

View File

@ -47,7 +47,7 @@ package org.apache.poi.ss.formula;
* <li>To retain freedom to change any cell definition at any time, an application may classify all
* cells as 'not final'. This freedom comes at the expense of greater memory consumption.</li>
* <li>For the purpose of these classifications, setting the cached formula result of a cell (for
* example in {@link org.apache.poi.ss.usermodel.FormulaEvaluator#evaluateFormulaCellEnum(org.apache.poi.ss.usermodel.Cell)})
* example in {@link org.apache.poi.ss.usermodel.FormulaEvaluator#evaluateFormulaCell(org.apache.poi.ss.usermodel.Cell)})
* does not constitute changing the definition of the cell.</li>
* <li>Updating cells which have been classified as 'final' will cause the evaluator to behave
* unpredictably (typically ignoring the update).</li>

View File

@ -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.getCellTypeEnum()) {
switch (cell.getCellType()) {
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.getCellTypeEnum() + ")");
throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
}
}
/**

View File

@ -983,7 +983,7 @@ public class DataFormatter implements Observer {
if (evaluator == null) {
return cell.getCellFormula();
}
cellType = evaluator.evaluateFormulaCellEnum(cell);
cellType = evaluator.evaluateFormulaCell(cell);
}
switch (cellType) {
case NUMERIC :

View File

@ -114,7 +114,7 @@ public interface FormulaEvaluator {
* so you know what kind of value is also stored with
* the formula.
* <pre>
* CellType evaluatedCellType = evaluator.evaluateFormulaCellEnum(cell);
* CellType evaluatedCellType = evaluator.evaluateFormulaCell(cell);
* </pre>
* Be aware that your cell will hold both the formula,
* and the result. If you want the cell replaced with
@ -143,7 +143,7 @@ public interface FormulaEvaluator {
* </pre>
* Be aware that your cell value will be changed to hold the
* result of the formula. If you simply want the formula
* value computed for you, use {@link #evaluateFormulaCellEnum(Cell)}
* value computed for you, use {@link #evaluateFormulaCell(Cell)}
* @param cell
*/
Cell evaluateInCell(Cell cell);

View File

@ -69,7 +69,7 @@ public class SheetUtil {
*
* See Bugzilla #50021
*/
private static final FormulaEvaluator dummyEvaluator = new FormulaEvaluator(){
private static final FormulaEvaluator dummyEvaluator = new FormulaEvaluator() {
@Override
public void clearAllCachedResultValues(){}
@Override

View File

@ -101,7 +101,7 @@ public class CellWalk {
}
private boolean isEmpty(Cell cell) {
return (cell.getCellTypeEnum() == CellType.BLANK);
return (cell.getCellType() == CellType.BLANK);
}
/**

View File

@ -106,8 +106,8 @@ public final class SXSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator {
// Evaluate what we have
for (Row r : sheet) {
for (Cell c : r) {
if (c.getCellTypeEnum() == CellType.FORMULA) {
eval.evaluateFormulaCellEnum(c);
if (c.getCellType() == CellType.FORMULA) {
eval.evaluateFormulaCell(c);
}
}
}

View File

@ -252,7 +252,7 @@ public class SheetDataWriter implements Closeable {
// APIs
writeAttribute("s", Integer.toString(cellStyle.getIndex() & 0xffff));
}
CellType cellType = cell.getCellTypeEnum();
CellType cellType = cell.getCellType();
switch (cellType) {
case BLANK: {
_out.write('>');

View File

@ -276,7 +276,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
case RETURN_NULL_AND_BLANK:
return cell;
case RETURN_BLANK_AS_NULL:
boolean isBlank = (cell != null && cell.getCellTypeEnum() == CellType.BLANK);
boolean isBlank = (cell != null && cell.getCellType() == 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<XSSFRow> {
if(xcell.isPartOfArrayFormulaGroup()) {
xcell.notifyArrayFormulaChanging();
}
if(cell.getCellTypeEnum() == CellType.FORMULA) {
if(cell.getCellType() == 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<XSSFRow> {
else {
for (final Cell c : srcRow){
final XSSFCell srcCell = (XSSFCell)c;
final XSSFCell destCell = createCell(srcCell.getColumnIndex(), srcCell.getCellTypeEnum());
final XSSFCell destCell = createCell(srcCell.getColumnIndex(), srcCell.getCellType());
destCell.copyCellFrom(srcCell, policy);
}

View File

@ -113,7 +113,7 @@ public class TestStructuredReferences {
private static void confirm(FormulaEvaluator fe, Cell cell, double expectedResult) {
fe.clearAllCachedResultValues();
CellValue cv = fe.evaluate(cell);
if (cv.getCellTypeEnum() != CellType.NUMERIC) {
if (cv.getCellType() != CellType.NUMERIC) {
fail("expected numeric cell type but got " + cv.formatAsString());
}
assertEquals(expectedResult, cv.getNumberValue(), 0.0);
@ -122,7 +122,7 @@ public class TestStructuredReferences {
private static void confirm(FormulaEvaluator fe, Cell cell, String expectedResult) {
fe.clearAllCachedResultValues();
CellValue cv = fe.evaluate(cell);
if (cv.getCellTypeEnum() != CellType.STRING) {
if (cv.getCellType() != CellType.STRING) {
fail("expected String cell type but got " + cv.formatAsString());
}
assertEquals(expectedResult, cv.getStringValue());

View File

@ -95,7 +95,7 @@ public final class TestProper {
cell11.setCellFormula(formulaText);
evaluator.clearAllCachedResultValues();
CellValue cv = evaluator.evaluate(cell11);
if (cv.getCellTypeEnum() != CellType.STRING) {
if (cv.getCellType() != CellType.STRING) {
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
}
String actualValue = cv.getStringValue();

View File

@ -106,7 +106,7 @@ public final class TestSXSSFFormulaEvaluation {
FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
try {
eval.evaluateFormulaCellEnum(c);
eval.evaluateFormulaCell(c);
fail("Evaluate shouldn't work, as reference outside the window");
} catch(SXSSFFormulaEvaluator.RowFlushedException e) {
// Expected
@ -152,7 +152,7 @@ public final class TestSXSSFFormulaEvaluation {
c.setCellFormula("A1*2");
assertEquals(0, (int)c.getNumericCellValue());
eval.evaluateFormulaCellEnum(c);
eval.evaluateFormulaCell(c);
assertEquals(3, (int)c.getNumericCellValue());
wb.close();
@ -168,12 +168,12 @@ public final class TestSXSSFFormulaEvaluation {
SXSSFCell c = s.createRow(0).createCell(0);
c.setCellFormula("1+2");
assertEquals(0, (int)c.getNumericCellValue());
eval.evaluateFormulaCellEnum(c);
eval.evaluateFormulaCell(c);
assertEquals(3, (int)c.getNumericCellValue());
c = s.createRow(1).createCell(0);
c.setCellFormula("CONCATENATE(\"hello\",\" \",\"world\")");
eval.evaluateFormulaCellEnum(c);
eval.evaluateFormulaCell(c);
assertEquals("hello world", c.getStringCellValue());
wb.close();

View File

@ -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.getCellTypeEnum() == CellType.FORMULA);
assumeTrue(c.getCellType() == CellType.FORMULA);
ignoredFormulaTestCase(c.getCellFormula());
CellValue actValue = evaluator.evaluate(c);
@ -202,17 +202,17 @@ 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.getCellTypeEnum();
final CellType expectedCellType = expValue.getCellType();
switch (expectedCellType) {
case BLANK:
assertEquals(msg, CellType.BLANK, actValue.getCellTypeEnum());
assertEquals(msg, CellType.BLANK, actValue.getCellType());
break;
case BOOLEAN:
assertEquals(msg, CellType.BOOLEAN, actValue.getCellTypeEnum());
assertEquals(msg, CellType.BOOLEAN, actValue.getCellType());
assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue());
break;
case ERROR:
assertEquals(msg, CellType.ERROR, actValue.getCellTypeEnum());
assertEquals(msg, CellType.ERROR, actValue.getCellType());
// if(false) { // TODO: fix ~45 functions which are currently returning incorrect error values
// assertEquals(msg, expValue.getErrorCellValue(), actValue.getErrorValue());
// }
@ -220,14 +220,14 @@ public final class TestFormulaEvaluatorOnXSSF {
case FORMULA: // will never be used, since we will call method after formula evaluation
fail("Cannot expect formula as result of formula evaluation: " + msg);
case NUMERIC:
assertEquals(msg, CellType.NUMERIC, actValue.getCellTypeEnum());
assertEquals(msg, CellType.NUMERIC, actValue.getCellType());
TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR);
// double delta = Math.abs(expValue.getNumericCellValue()-actValue.getNumberValue());
// double pctExpValue = Math.abs(0.00001*expValue.getNumericCellValue());
// assertTrue(msg, delta <= pctExpValue);
break;
case STRING:
assertEquals(msg, CellType.STRING, actValue.getCellTypeEnum());
assertEquals(msg, CellType.STRING, actValue.getCellType());
assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue());
break;
default:
@ -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.getCellTypeEnum() == CellType.BLANK) {
if(cell.getCellType() == CellType.BLANK) {
return null;
}
if(cell.getCellTypeEnum() == CellType.STRING) {
if(cell.getCellType() == CellType.STRING) {
return cell.getRichStringCellValue().getString();
}

View File

@ -666,14 +666,14 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
assertEquals(3.0, c.getNumericCellValue(), 0);
FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
formulaEvaluator.evaluateFormulaCellEnum(c);
formulaEvaluator.evaluateFormulaCell(c);
assertEquals("SUM(\n1,2\n)", c.getCellFormula());
assertEquals(3.0, c.getNumericCellValue(), 0);
// For 51875
Cell b3 = s.getRow(2).getCell(1);
formulaEvaluator.evaluateFormulaCellEnum(b3);
formulaEvaluator.evaluateFormulaCell(b3);
assertEquals("B1+B2", b3.getCellFormula()); // The newline is lost for shared formulas
assertEquals(3.0, b3.getNumericCellValue(), 0);
@ -1375,8 +1375,8 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
// Try evaluating both
XSSFFormulaEvaluator eval = new XSSFFormulaEvaluator(wb);
eval.evaluateFormulaCellEnum(c1);
eval.evaluateFormulaCellEnum(c2);
eval.evaluateFormulaCell(c1);
eval.evaluateFormulaCell(c2);
assertEquals(20.0, c1.getNumericCellValue(), 0);
assertEquals(20.0, c2.getNumericCellValue(), 0);
@ -2935,7 +2935,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
cell = row.getCell(1);
assertEquals(CellType.BLANK, cell.getCellType());
assertEquals(CellType._NONE, evaluator.evaluateFormulaCellEnum(cell));
assertEquals(CellType._NONE, evaluator.evaluateFormulaCell(cell));
// A3
row = worksheet.getRow(2);
@ -2943,7 +2943,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals("IF(ISBLANK(B3),\"\",B3)", cell.getCellFormula());
assertEquals(CellType.STRING, evaluator.evaluateFormulaCellEnum(cell));
assertEquals(CellType.STRING, evaluator.evaluateFormulaCell(cell));
CellValue value = evaluator.evaluate(cell);
assertEquals("", value.getStringValue());
@ -2953,7 +2953,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals("COUNTBLANK(A1:A4)", cell.getCellFormula());
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCellEnum(cell));
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(cell));
value = evaluator.evaluate(cell);
assertEquals(1.0, value.getNumberValue(), 0.1);

View File

@ -135,13 +135,13 @@ public final class TestXSSFCell extends BaseTestXCell {
assertNull(str.getString());
cell_0.setCellValue(str);
assertEquals(0, sst.getCount());
assertEquals(CellType.BLANK, cell_0.getCellTypeEnum());
assertEquals(CellType.BLANK, cell_0.getCellType());
//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.getCellTypeEnum());
assertEquals(CellType.BLANK, cell_1.getCellType());
wb.close();
}
@ -153,7 +153,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.getCellTypeEnum());
assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals("A2", cell.getCellFormula());
//the value is not set and cell's type='N' which means blank
assertEquals(STCellType.N, ctCell.getT());
@ -161,7 +161,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.getCellTypeEnum());
assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals("A2", cell.getCellFormula());
//cached formula value is set and cell's type='STR'
assertEquals(STCellType.STR, ctCell.getT());
@ -169,14 +169,14 @@ public final class TestXSSFCell extends BaseTestXCell {
//now remove the formula, the cached formula result remains
cell.setCellFormula(null);
assertEquals(CellType.STRING, cell.getCellTypeEnum());
assertEquals(CellType.STRING, cell.getCellType());
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.getCellTypeEnum());
assertEquals(CellType.BLANK, cell.getCellType());
assertEquals(STCellType.N, ctCell.getT());
assertEquals("", cell.getStringCellValue());
} finally {
@ -196,7 +196,7 @@ public final class TestXSSFCell extends BaseTestXCell {
//try a string cell
cell = sh.getRow(0).getCell(0);
assertEquals(CellType.STRING, cell.getCellTypeEnum());
assertEquals(CellType.STRING, cell.getCellType());
assertEquals("a", cell.getStringCellValue());
assertEquals("a", cell.toString());
//Gnumeric produces spreadsheets without styles
@ -205,7 +205,7 @@ public final class TestXSSFCell extends BaseTestXCell {
//try a numeric cell
cell = sh.getRow(1).getCell(0);
assertEquals(CellType.NUMERIC, cell.getCellTypeEnum());
assertEquals(CellType.NUMERIC, cell.getCellType());
assertEquals(1.0, cell.getNumericCellValue(), 0);
assertEquals("1.0", cell.toString());
//Gnumeric produces spreadsheets without styles
@ -515,7 +515,7 @@ public final class TestXSSFCell extends BaseTestXCell {
final CellCopyPolicy policy = new CellCopyPolicy();
destCell.copyCellFrom(srcCell, policy);
assertEquals(CellType.FORMULA, destCell.getCellTypeEnum());
assertEquals(CellType.FORMULA, destCell.getCellType());
assertEquals("2+3", destCell.getCellFormula());
assertEquals(srcCell.getCellStyle(), destCell.getCellStyle());
}
@ -527,7 +527,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.getCellTypeEnum());
assertEquals(CellType.NUMERIC, destCell.getCellType());
}
@Test
@ -554,8 +554,8 @@ public final class TestXSSFCell extends BaseTestXCell {
assertEquals(srcCell.getCellStyle(), destCell.getCellStyle());
// Old cell value should not have been overwritten
assertNotEquals(CellType.BLANK, destCell.getCellTypeEnum());
assertEquals(CellType.BOOLEAN, destCell.getCellTypeEnum());
assertNotEquals(CellType.BLANK, destCell.getCellType());
assertEquals(CellType.BOOLEAN, destCell.getCellType());
assertEquals(true, destCell.getBooleanCellValue());
}

View File

@ -488,7 +488,7 @@ public final class TestXSSFFormulaParser {
for (Cell cell : row) {
if (cell.getCellTypeEnum() == CellType.FORMULA) {
try {
evaluator.evaluateFormulaCellEnum(cell);
evaluator.evaluateFormulaCell(cell);
} catch (Exception e) {
CellReference cellRef = new CellReference(cell.getRowIndex(), cell.getColumnIndex());
throw new RuntimeException("error at: " + cellRef, e);

View File

@ -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).getCellTypeEnum());
assertEquals(CellType.STRING, destRow.getCell(0).getCellType());
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

View File

@ -2424,7 +2424,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
// Check the evaluated result
HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb);
eval.evaluateFormulaCellEnum(c);
eval.evaluateFormulaCell(c);
assertEquals(4.0, c.getNumericCellValue(), 0);
wb.close();
}

View File

@ -59,7 +59,7 @@ public class TestExternalReferenceChange extends TestCase {
new String[]{MAIN_WORKBOOK_FILENAME, SOURCE_WORKBOOK_FILENAME},
new HSSFFormulaEvaluator[] {lMainWorkbookEvaluator, lSourceEvaluator});
assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCellEnum(lA1Cell));
assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCell(lA1Cell));
assertEquals(20.0d, lA1Cell.getNumericCellValue(), 0.00001d);

View File

@ -287,7 +287,7 @@ public final class TestFormulaEvaluatorBugs {
HSSFRow r = (HSSFRow)rows.next();
for (Iterator<Cell> cells = r.cellIterator(); cells.hasNext();) {
HSSFCell c = (HSSFCell)cells.next();
eval.evaluateFormulaCellEnum(c);
eval.evaluateFormulaCell(c);
}
}
}
@ -568,7 +568,7 @@ public final class TestFormulaEvaluatorBugs {
}
}
private Ptg[] getPtgs(HSSFCell cell) {
assertEquals(CellType.FORMULA, cell.getCellTypeEnum());
assertEquals(CellType.FORMULA, cell.getCellType());
assertEquals(FormulaRecordAggregate.class, cell.getCellValueRecord().getClass());
FormulaRecordAggregate agg = (FormulaRecordAggregate)cell.getCellValueRecord();
FormulaRecord rec = agg.getFormulaRecord();

View File

@ -73,11 +73,11 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
for(Row r : sheet) {
for(Cell c : r) {
if(c.getCellTypeEnum() == CellType.FORMULA) {
evaluator.evaluateFormulaCellEnum(c);
if(c.getCellType() == CellType.FORMULA) {
evaluator.evaluateFormulaCell(c);
// For testing - all should be numeric
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCellEnum(c));
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(c));
}
}
}
@ -86,15 +86,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).getCellTypeEnum());
assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(0).getCell(2).getCellType());
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).getCellTypeEnum());
assertEquals(CellType.FORMULA, wb.getSheetAt(0).getRow(1).getCell(2).getCellType());
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).getCellTypeEnum());
assertEquals(CellType.FORMULA, wb.getSheetAt(1).getRow(0).getCell(0).getCellType());
// Now do the alternate call, which zaps the formulas
@ -104,7 +104,7 @@ public final class TestFormulaEvaluatorDocs extends TestCase {
for(Row r : sheet) {
for(Cell c : r) {
if(c.getCellTypeEnum() == CellType.FORMULA) {
if(c.getCellType() == CellType.FORMULA) {
evaluator.evaluateInCell(c);
}
}
@ -112,12 +112,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).getCellTypeEnum());
assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(0).getCell(2).getCellType());
assertEquals(-4.6, wb.getSheetAt(0).getRow(1).getCell(2).getNumericCellValue(), 0);
assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(1).getCell(2).getCellTypeEnum());
assertEquals(CellType.NUMERIC, wb.getSheetAt(0).getRow(1).getCell(2).getCellType());
assertEquals(22.3, wb.getSheetAt(1).getRow(0).getCell(0).getNumericCellValue(), 0);
assertEquals(CellType.NUMERIC, wb.getSheetAt(1).getRow(0).getCell(0).getCellTypeEnum());
assertEquals(CellType.NUMERIC, wb.getSheetAt(1).getRow(0).getCell(0).getCellType());
}
}

View File

@ -76,7 +76,7 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
cellA1.setCellErrorValue(FormulaError.NAME.getCode());
fe.evaluateFormulaCellEnum(cellB1);
fe.evaluateFormulaCell(cellB1);
cellA1.setCellValue(2.5);
fe.notifyUpdateCell(cellA1);
@ -227,10 +227,10 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
new HSSFFormulaEvaluator(wb2)
}
);
eval.evaluateFormulaCellEnum(
eval.evaluateFormulaCell(
wb1.getSheetAt(0).getRow(1).getCell(2)
);
eval.evaluateFormulaCellEnum(
eval.evaluateFormulaCell(
wb1.getSheetAt(0).getRow(1).getCell(4)
);
@ -256,7 +256,7 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
assertEquals("Cost*[XRefCalcData.xls]MarkupSheet!$B$1", cell.getCellFormula());
// Check it evaluates correctly
eval.evaluateFormulaCellEnum(cell);
eval.evaluateFormulaCell(cell);
assertEquals(24.60*1.8, cell.getNumericCellValue(), 0);
@ -291,7 +291,7 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
new HSSFFormulaEvaluator(wb3)
}
);
eval.evaluateFormulaCellEnum(cell);
eval.evaluateFormulaCell(cell);
assertEquals("In another workbook", cell.getStringCellValue());
@ -310,13 +310,13 @@ public final class TestHSSFFormulaEvaluator extends BaseTestFormulaEvaluator {
// Check the one referring to the previously existing workbook behaves
cell = wb4.getSheetAt(0).getRow(1).getCell(40);
assertEquals("Cost*[XRefCalcData.xls]MarkupSheet!$B$1", cell.getCellFormula());
eval.evaluateFormulaCellEnum(cell);
eval.evaluateFormulaCell(cell);
assertEquals(24.60*1.8, cell.getNumericCellValue(), 0);
// Now check the newly added reference
cell = wb4.getSheetAt(0).getRow(1).getCell(42);
assertEquals("[alt.xls]Sheet0!$A$1", cell.getCellFormula());
eval.evaluateFormulaCellEnum(cell);
eval.evaluateFormulaCell(cell);
assertEquals("In another workbook", cell.getStringCellValue());
wb4.close();

View File

@ -151,12 +151,12 @@ public abstract class BaseTestExternalFunctions {
Cell cell2 = sh.getRow(2).getCell(1);
assertEquals("ISODD(2)", cell2.getCellFormula());
assertEquals(false, evaluator.evaluate(cell2).getBooleanValue());
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCellEnum(cell2));
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(cell2));
Cell cell3 = sh.getRow(3).getCell(1);
assertEquals("ISEVEN(2)", cell3.getCellFormula());
assertEquals(true, evaluator.evaluate(cell3).getBooleanValue());
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCellEnum(cell3));
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(cell3));
wb.close();
}

View File

@ -739,7 +739,7 @@ public class TestEvaluationCache extends TestCase {
//calculate
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
evaluator.evaluateFormulaCellEnum(summaryCell);
evaluator.evaluateFormulaCell(summaryCell);
}
@ -779,7 +779,7 @@ public class TestEvaluationCache extends TestCase {
//calculate
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
evaluator.evaluateFormulaCellEnum(summaryCell);
evaluator.evaluateFormulaCell(summaryCell);
assertEquals(8394753.0, summaryCell.getNumericCellValue());
}

View File

@ -67,9 +67,9 @@ public class TestMissingWorkbook extends TestCase {
Row lARow = lSheet.getRow(0);
Cell lA1Cell = lARow.getCell(0);
assertEquals(CellType.FORMULA, lA1Cell.getCellTypeEnum());
assertEquals(CellType.FORMULA, lA1Cell.getCellType());
try {
evaluator.evaluateFormulaCellEnum(lA1Cell);
evaluator.evaluateFormulaCell(lA1Cell);
fail("Missing external workbook reference exception expected!");
}catch(RuntimeException re) {
assertTrue("Unexpected exception: " + re, re.getMessage().indexOf(SOURCE_DUMMY_WORKBOOK_FILENAME) != -1);
@ -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.getCellTypeEnum());
assertEquals(CellType.FORMULA, lB1Cell.getCellTypeEnum());
assertEquals(CellType.FORMULA, lC1Cell.getCellTypeEnum());
assertEquals(CellType.FORMULA, lA1Cell.getCellType());
assertEquals(CellType.FORMULA, lB1Cell.getCellType());
assertEquals(CellType.FORMULA, lC1Cell.getCellType());
// Check cached values
assertEquals(10.0d, lA1Cell.getNumericCellValue(), 0.00001d);
@ -95,9 +95,9 @@ public class TestMissingWorkbook extends TestCase {
FormulaEvaluator evaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator();
evaluator.setIgnoreMissingWorkbooks(true);
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCellEnum(lA1Cell));
assertEquals(CellType.STRING, evaluator.evaluateFormulaCellEnum(lB1Cell));
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCellEnum(lC1Cell));
assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(lA1Cell));
assertEquals(CellType.STRING, evaluator.evaluateFormulaCell(lB1Cell));
assertEquals(CellType.BOOLEAN, evaluator.evaluateFormulaCell(lC1Cell));
assertEquals(10.0d, lA1Cell.getNumericCellValue(), 0.00001d);
assertEquals("POI rocks!", lB1Cell.getStringCellValue());
@ -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.getCellTypeEnum());
assertEquals(CellType.FORMULA, lB1Cell.getCellTypeEnum());
assertEquals(CellType.FORMULA, lC1Cell.getCellTypeEnum());
assertEquals(CellType.FORMULA, lA1Cell.getCellType());
assertEquals(CellType.FORMULA, lB1Cell.getCellType());
assertEquals(CellType.FORMULA, lC1Cell.getCellType());
FormulaEvaluator lMainWorkbookEvaluator = mainWorkbook.getCreationHelper().createFormulaEvaluator();
FormulaEvaluator lSourceEvaluator = sourceWorkbook.getCreationHelper().createFormulaEvaluator();
@ -122,9 +122,9 @@ public class TestMissingWorkbook extends TestCase {
workbooks.put(SOURCE_DUMMY_WORKBOOK_FILENAME, lSourceEvaluator);
lMainWorkbookEvaluator.setupReferencedWorkbooks(workbooks);
assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCellEnum(lA1Cell));
assertEquals(CellType.STRING, lMainWorkbookEvaluator.evaluateFormulaCellEnum(lB1Cell));
assertEquals(CellType.BOOLEAN, lMainWorkbookEvaluator.evaluateFormulaCellEnum(lC1Cell));
assertEquals(CellType.NUMERIC, lMainWorkbookEvaluator.evaluateFormulaCell(lA1Cell));
assertEquals(CellType.STRING, lMainWorkbookEvaluator.evaluateFormulaCell(lB1Cell));
assertEquals(CellType.BOOLEAN, lMainWorkbookEvaluator.evaluateFormulaCell(lC1Cell));
assertEquals(20.0d, lA1Cell.getNumericCellValue(), 0.00001d);
assertEquals("Apache rocks!", lB1Cell.getStringCellValue());

View File

@ -533,7 +533,7 @@ public class TestWorkbookEvaluator {
Cell D1 = wb.getSheet("IFEquals").getRow(0).getCell(3);
FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
CellType resultCellType = eval.evaluateFormulaCellEnum(D1);
CellType resultCellType = eval.evaluateFormulaCell(D1);
// Call should modify the contents, but leave the formula intact
assertEquals(CellType.FORMULA, D1.getCellType());

View File

@ -66,11 +66,11 @@ public class TestRandBetween extends TestCase {
evaluator.clearAllCachedResultValues();
formulaCell.setCellFormula("RANDBETWEEN(1,1)");
evaluator.evaluateFormulaCellEnum(formulaCell);
evaluator.evaluateFormulaCell(formulaCell);
assertEquals(1, formulaCell.getNumericCellValue(), 0);
evaluator.clearAllCachedResultValues();
formulaCell.setCellFormula("RANDBETWEEN(-1,-1)");
evaluator.evaluateFormulaCellEnum(formulaCell);
evaluator.evaluateFormulaCell(formulaCell);
assertEquals(-1, formulaCell.getNumericCellValue(), 0);
}
@ -86,25 +86,25 @@ public class TestRandBetween extends TestCase {
topValueCell.setCellValue(0.1);
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
evaluator.evaluateFormulaCell(formulaCell);
assertEquals(1, formulaCell.getNumericCellValue(), 0);
bottomValueCell.setCellValue(-0.1);
topValueCell.setCellValue(-0.05);
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
evaluator.evaluateFormulaCell(formulaCell);
assertEquals(0, formulaCell.getNumericCellValue(), 0);
bottomValueCell.setCellValue(-1.1);
topValueCell.setCellValue(-1.05);
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
evaluator.evaluateFormulaCell(formulaCell);
assertEquals(-1, formulaCell.getNumericCellValue(), 0);
bottomValueCell.setCellValue(-1.1);
topValueCell.setCellValue(-1.1);
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
evaluator.evaluateFormulaCell(formulaCell);
assertEquals(-1, formulaCell.getNumericCellValue(), 0);
}
@ -117,7 +117,7 @@ public class TestRandBetween extends TestCase {
topValueCell.setCellType(CellType.BLANK);
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
evaluator.evaluateFormulaCell(formulaCell);
assertTrue(formulaCell.getNumericCellValue() == 0 || formulaCell.getNumericCellValue() == -1);
}
@ -130,7 +130,7 @@ public class TestRandBetween extends TestCase {
topValueCell.setCellValue(1);
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
evaluator.evaluateFormulaCell(formulaCell);
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
@ -140,7 +140,7 @@ public class TestRandBetween extends TestCase {
topValueCell.setCellValue("STRING");
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
evaluator.evaluateFormulaCell(formulaCell);
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
@ -149,7 +149,7 @@ public class TestRandBetween extends TestCase {
topValueCell.setCellValue("STRING");
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
evaluator.evaluateFormulaCell(formulaCell);
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), formulaCell.getErrorCellValue());
@ -165,14 +165,14 @@ public class TestRandBetween extends TestCase {
topValueCell.setCellValue(0);
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
evaluator.evaluateFormulaCell(formulaCell);
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
bottomValueCell.setCellValue(1);
topValueCell.setCellType(CellType.BLANK);
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
evaluator.evaluateFormulaCell(formulaCell);
assertEquals(CellType.ERROR, formulaCell.getCachedFormulaResultType());
assertEquals(ErrorEval.NUM_ERROR.getErrorCode(), formulaCell.getErrorCellValue());
}
@ -186,7 +186,7 @@ public class TestRandBetween extends TestCase {
topValueCell.setCellValue(Double.MAX_VALUE);
formulaCell.setCellFormula("RANDBETWEEN($A$1,$B$1)");
evaluator.clearAllCachedResultValues();
evaluator.evaluateFormulaCellEnum(formulaCell);
evaluator.evaluateFormulaCell(formulaCell);
assertTrue(formulaCell.getNumericCellValue() >= Double.MIN_VALUE && formulaCell.getNumericCellValue() <= Double.MAX_VALUE);
}

View File

@ -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.getCellTypeEnum() != CellType.FORMULA) {
if (c == null || c.getCellType() != CellType.FORMULA) {
continue;
}
@ -187,27 +187,27 @@ 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.getCellTypeEnum();
final CellType cellType = expValue.getCellType();
switch (cellType) {
case BLANK:
assertEquals(msg, CellType.BLANK, actValue.getCellTypeEnum());
assertEquals(msg, CellType.BLANK, actValue.getCellType());
break;
case BOOLEAN:
assertEquals(msg, CellType.BOOLEAN, actValue.getCellTypeEnum());
assertEquals(msg, CellType.BOOLEAN, actValue.getCellType());
assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue());
break;
case ERROR:
assertEquals(msg, CellType.ERROR, actValue.getCellTypeEnum());
assertEquals(msg, CellType.ERROR, actValue.getCellType());
assertEquals(msg, ErrorEval.getText(expValue.getErrorCellValue()), ErrorEval.getText(actValue.getErrorValue()));
break;
case FORMULA: // will never be used, since we will call method after formula evaluation
fail("Cannot expect formula as result of formula evaluation: " + msg);
case NUMERIC:
assertEquals(msg, CellType.NUMERIC, actValue.getCellTypeEnum());
assertEquals(msg, CellType.NUMERIC, actValue.getCellType());
TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR);
break;
case STRING:
assertEquals(msg, CellType.STRING, actValue.getCellTypeEnum());
assertEquals(msg, CellType.STRING, actValue.getCellType());
assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue());
break;
default:
@ -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.getCellTypeEnum() == CellType.BLANK) {
if(cell.getCellType() == CellType.BLANK) {
return null;
}
if(cell.getCellTypeEnum() == CellType.STRING) {
if(cell.getCellType() == CellType.STRING) {
return cell.getRichStringCellValue().getString();
}
throw new AssertionFailedError("Bad cell type for 'function name' column: ("
+ cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")");
+ cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
}
}

View File

@ -123,7 +123,7 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
currentGroupComment = newMarkerValue;
}
HSSFCell evalCell = r.getCell(SS.COLUMN_INDEX_EVALUATION);
if (evalCell == null || evalCell.getCellTypeEnum() != CellType.FORMULA) {
if (evalCell == null || evalCell.getCellType() != CellType.FORMULA) {
continue;
}
String rowComment = getCellTextValue(r, SS.COLUMN_ROW_COMMENT, "row comment");
@ -153,9 +153,9 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
assertNotNull(msg + " - Bad setup data expected value is null", expectedCell);
assertNotNull(msg + " - actual value was null", actualValue);
if (expectedCell.getCellTypeEnum() == CellType.ERROR) {
if (expectedCell.getCellType() == CellType.ERROR) {
int expectedErrorCode = expectedCell.getErrorCellValue();
assertEquals(msg, CellType.ERROR, actualValue.getCellTypeEnum());
assertEquals(msg, CellType.ERROR, actualValue.getCellType());
assertEquals(msg, ErrorEval.getText(expectedErrorCode), actualValue.formatAsString());
assertEquals(msg, expectedErrorCode, actualValue.getErrorValue());
assertEquals(msg, ErrorEval.getText(expectedErrorCode), ErrorEval.getText(actualValue.getErrorValue()));
@ -163,13 +163,13 @@ public abstract class BaseTestFunctionsFromSpreadsheet {
}
// unexpected error
assertNotEquals(msg, CellType.ERROR, actualValue.getCellTypeEnum());
assertNotEquals(msg, CellType.ERROR, actualValue.getCellType());
assertNotEquals(msg, formatValue(expectedCell), ErrorEval.getText(actualValue.getErrorValue()));
// wrong type error
assertEquals(msg, expectedCell.getCellTypeEnum(), actualValue.getCellTypeEnum());
assertEquals(msg, expectedCell.getCellType(), actualValue.getCellType());
final CellType expectedCellType = expectedCell.getCellTypeEnum();
final CellType expectedCellType = expectedCell.getCellType();
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.getCellTypeEnum() == CellType.BLANK) {
if(cell.getCellType() == CellType.BLANK) {
return null;
}
if(cell.getCellTypeEnum() == CellType.STRING) {
if(cell.getCellType() == CellType.STRING) {
return cell.getRichStringCellValue().getString();
}
fail("Bad cell type for '" + columnName + "' column: ("
+ cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")");
+ cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")");
return "";
}
private static String formatValue(HSSFCell expecedCell) {
switch (expecedCell.getCellTypeEnum()) {
switch (expecedCell.getCellType()) {
case BLANK: return "<blank>";
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.getCellTypeEnum() + ")");
default: fail("Unexpected cell type of expected value (" + expecedCell.getCellType() + ")");
}
return "";
}

View File

@ -82,7 +82,7 @@ public final class TestDate extends TestCase {
cell11.setCellFormula(formulaText);
evaluator.clearAllCachedResultValues();
CellValue cv = evaluator.evaluate(cell11);
if (cv.getCellTypeEnum() != CellType.NUMERIC) {
if (cv.getCellType() != CellType.NUMERIC) {
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString());
}
double actualValue = cv.getNumberValue();

View File

@ -66,7 +66,7 @@ public final class TestFind {
cell.setCellFormula(formulaText);
fe.notifyUpdateCell(cell);
CellValue result = fe.evaluate(cell);
assertEquals(result.getCellTypeEnum(), CellType.NUMERIC);
assertEquals(result.getCellType(), CellType.NUMERIC);
assertEquals(expectedResult, result.getNumberValue(), 0.0);
}
@ -75,7 +75,7 @@ public final class TestFind {
cell.setCellFormula(formulaText);
fe.notifyUpdateCell(cell);
CellValue result = fe.evaluate(cell);
assertEquals(result.getCellTypeEnum(), CellType.ERROR);
assertEquals(result.getCellType(), CellType.ERROR);
assertEquals(expectedErrorCode.getCode(), result.getErrorValue());
}
}

View File

@ -117,7 +117,7 @@ public final class TestFixed {
cell11.setCellFormula(formulaText);
evaluator.clearAllCachedResultValues();
CellValue cv = evaluator.evaluate(cell11);
assertEquals("Wrong result type: " + cv.formatAsString(), CellType.STRING, cv.getCellTypeEnum());
assertEquals("Wrong result type: " + cv.formatAsString(), CellType.STRING, cv.getCellType());
String actualValue = cv.getStringValue();
assertEquals(expectedResult, actualValue);
}
@ -127,7 +127,7 @@ public final class TestFixed {
evaluator.clearAllCachedResultValues();
CellValue cv = evaluator.evaluate(cell11);
assertTrue("Wrong result type: " + cv.formatAsString(),
cv.getCellTypeEnum() == CellType.ERROR
cv.getCellType() == CellType.ERROR
&& cv.getErrorValue() == FormulaError.VALUE.getCode());
}
}

View File

@ -185,7 +185,7 @@ public final class TestIndirect {
fe.clearAllCachedResultValues();
cell.setCellFormula(formula);
CellValue cv = fe.evaluate(cell);
if (cv.getCellTypeEnum() != CellType.NUMERIC) {
if (cv.getCellType() != CellType.NUMERIC) {
fail("expected numeric cell type but got " + cv.formatAsString());
}
assertEquals(expectedResult, cv.getNumberValue(), 0.0);
@ -196,7 +196,7 @@ public final class TestIndirect {
fe.clearAllCachedResultValues();
cell.setCellFormula(formula);
CellValue cv = fe.evaluate(cell);
if (cv.getCellTypeEnum() != CellType.ERROR) {
if (cv.getCellType() != CellType.ERROR) {
fail("expected error cell type but got " + cv.formatAsString());
}
int expCode = expectedResult.getErrorCode();

View File

@ -81,7 +81,7 @@ public final class TestIrr extends TestCase {
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
fe.clearAllCachedResultValues();
fe.evaluateFormulaCellEnum(cell);
fe.evaluateFormulaCell(cell);
double res = cell.getNumericCellValue();
assertEquals(0.143d, Math.round(res * 1000d) / 1000d);
}

View File

@ -121,7 +121,7 @@ public final class TestMirr extends TestCase {
HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
fe.clearAllCachedResultValues();
fe.evaluateFormulaCellEnum(cell);
fe.evaluateFormulaCell(cell);
double res = cell.getNumericCellValue();
assertEquals(0.18736225093, res, 0.00000001);
}
@ -162,7 +162,7 @@ public final class TestMirr extends TestCase {
private static void assertFormulaResult(CellValue cv, HSSFCell cell) {
double actualValue = cv.getNumberValue();
double expectedValue = cell.getNumericCellValue(); // cached formula result calculated by Excel
assertEquals("Invalid formula result: " + cv, CellType.NUMERIC, cv.getCellTypeEnum());
assertEquals("Invalid formula result: " + cv, CellType.NUMERIC, cv.getCellType());
assertEquals(expectedValue, actualValue, 1E-8);
}
}

View File

@ -50,7 +50,7 @@ public final class TestNpv extends TestCase {
// Enumeration
cell.setCellFormula("NPV(A2, A4,A5,A6,A7,A8)+A3");
fe.clearAllCachedResultValues();
fe.evaluateFormulaCellEnum(cell);
fe.evaluateFormulaCell(cell);
double res = cell.getNumericCellValue();
assertEquals(1922.06d, Math.round(res * 100d) / 100d);
@ -58,7 +58,7 @@ public final class TestNpv extends TestCase {
cell.setCellFormula("NPV(A2, A4:A8)+A3");
fe.clearAllCachedResultValues();
fe.evaluateFormulaCellEnum(cell);
fe.evaluateFormulaCell(cell);
res = cell.getNumericCellValue();
assertEquals(1922.06d, Math.round(res * 100d) / 100d);
}

View File

@ -96,9 +96,9 @@ public final class TestExternalNameReference extends TestCase {
HSSFCell ccell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell((int)cellRef.getCol());
cellRef = new CellReference(wb.getName("TOTALCOST").getRefersToFormula());
HSSFCell tccell = wb.getSheet(cellRef.getSheetName()).getRow(cellRef.getRow()).getCell((int)cellRef.getCol());
evaluator.evaluateFormulaCellEnum(uccell);
evaluator.evaluateFormulaCellEnum(ccell);
evaluator.evaluateFormulaCellEnum(tccell);
evaluator.evaluateFormulaCell(uccell);
evaluator.evaluateFormulaCell(ccell);
evaluator.evaluateFormulaCell(tccell);
assertEquals(NEW_PART_COST, uccell.getNumericCellValue());
assertEquals(NEW_PART_COST*NEW_QUANT, ccell.getNumericCellValue());
assertEquals(NEW_PART_COST*NEW_QUANT*MARKUP_COST_2, tccell.getNumericCellValue());

View File

@ -864,7 +864,7 @@ public abstract class BaseTestBugzillaIssues {
private Cell evaluateCell(Workbook wb, Cell c) {
Sheet s = c.getSheet();
wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCellEnum(c);
wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCell(c);
return s.getRow(c.getRowIndex()).getCell(c.getColumnIndex());
}
@ -945,8 +945,8 @@ public abstract class BaseTestBugzillaIssues {
// Try to evaluate, with the other file
evaluator.evaluateFormulaCellEnum(c1);
evaluator.evaluateFormulaCellEnum(c2);
evaluator.evaluateFormulaCell(c1);
evaluator.evaluateFormulaCell(c2);
assertEquals(otherCellText, c1.getStringCellValue());
assertEquals(otherCellText, c2.getStringCellValue());
@ -1153,8 +1153,8 @@ public abstract class BaseTestBugzillaIssues {
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
assertEquals(CellType.NUMERIC, fe.evaluate(cfn).getCellType());
assertEquals(CellType.STRING, fe.evaluate(cfs).getCellType());
fe.evaluateFormulaCellEnum(cfn);
fe.evaluateFormulaCellEnum(cfs);
fe.evaluateFormulaCell(cfn);
fe.evaluateFormulaCell(cfs);
// Now test
assertEquals(CellType.NUMERIC, cn.getCellType());
@ -1282,17 +1282,17 @@ public abstract class BaseTestBugzillaIssues {
// Check read ok, and re-evaluate fine
cell = row.getCell(5);
assertEquals("ab", cell.getStringCellValue());
ev.evaluateFormulaCellEnum(cell);
ev.evaluateFormulaCell(cell);
assertEquals("ab", cell.getStringCellValue());
cell = row.getCell(6);
assertEquals("empty", cell.getStringCellValue());
ev.evaluateFormulaCellEnum(cell);
ev.evaluateFormulaCell(cell);
assertEquals("empty", cell.getStringCellValue());
cell = row.getCell(7);
assertEquals("ab", cell.getStringCellValue());
ev.evaluateFormulaCellEnum(cell);
ev.evaluateFormulaCell(cell);
assertEquals("ab", cell.getStringCellValue());
wb2.close();
}

View File

@ -503,7 +503,7 @@ public abstract class BaseTestCell {
FormulaEvaluator fe = cellA1.getSheet().getWorkbook().getCreationHelper().createFormulaEvaluator();
fe.evaluateFormulaCellEnum(cellA1);
fe.evaluateFormulaCell(cellA1);
assertEquals("abc", cellA1.getStringCellValue());
fe.evaluateInCell(cellA1);
@ -526,14 +526,14 @@ public abstract class BaseTestCell {
cellA1.setCellFormula("\"DEF\"");
fe.clearAllCachedResultValues();
fe.evaluateFormulaCellEnum(cellA1);
fe.evaluateFormulaCell(cellA1);
assertEquals("DEF", cellA1.getStringCellValue());
cellA1.setCellType(CellType.STRING);
assertEquals("DEF", cellA1.getStringCellValue());
cellA1.setCellFormula("25.061");
fe.clearAllCachedResultValues();
fe.evaluateFormulaCellEnum(cellA1);
fe.evaluateFormulaCell(cellA1);
confirmCannotReadString(cellA1);
assertEquals(25.061, cellA1.getNumericCellValue(), 0.0);
cellA1.setCellType(CellType.STRING);
@ -541,7 +541,7 @@ public abstract class BaseTestCell {
cellA1.setCellFormula("TRUE");
fe.clearAllCachedResultValues();
fe.evaluateFormulaCellEnum(cellA1);
fe.evaluateFormulaCell(cellA1);
confirmCannotReadString(cellA1);
assertEquals(true, cellA1.getBooleanCellValue());
cellA1.setCellType(CellType.STRING);
@ -549,7 +549,7 @@ public abstract class BaseTestCell {
cellA1.setCellFormula("#NAME?");
fe.clearAllCachedResultValues();
fe.evaluateFormulaCellEnum(cellA1);
fe.evaluateFormulaCell(cellA1);
confirmCannotReadString(cellA1);
assertEquals(FormulaError.NAME, forInt(cellA1.getErrorCellValue()));
cellA1.setCellType(CellType.STRING);
@ -819,7 +819,7 @@ public abstract class BaseTestCell {
Row row = sheet.createRow(0);
Cell cell = row.createCell(0);
cell.setCellFormula("SQRT(-1)");
wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCellEnum(cell);
wb.getCreationHelper().createFormulaEvaluator().evaluateFormulaCell(cell);
assertEquals(36, cell.getErrorCellValue());
} finally {
wb.close();

View File

@ -57,8 +57,8 @@ public abstract class BaseTestFormulaEvaluator {
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
fe.evaluateFormulaCellEnum(c1);
fe.evaluateFormulaCellEnum(c2);
fe.evaluateFormulaCell(c1);
fe.evaluateFormulaCell(c2);
assertEquals(6.0, c1.getNumericCellValue(), 0.0001);
assertEquals(5.0, c2.getNumericCellValue(), 0.0001);
@ -98,10 +98,10 @@ public abstract class BaseTestFormulaEvaluator {
// Evaluate and test
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
fe.evaluateFormulaCellEnum(c1);
fe.evaluateFormulaCellEnum(c2);
fe.evaluateFormulaCellEnum(c3);
fe.evaluateFormulaCellEnum(c4);
fe.evaluateFormulaCell(c1);
fe.evaluateFormulaCell(c2);
fe.evaluateFormulaCell(c3);
fe.evaluateFormulaCell(c4);
assertEquals(3.6, c1.getNumericCellValue(), 0.0001);
assertEquals(17.5, c2.getNumericCellValue(), 0.0001);
@ -290,7 +290,7 @@ public abstract class BaseTestFormulaEvaluator {
FormulaEvaluator fe = wb.getCreationHelper().createFormulaEvaluator();
cellA1.setCellErrorValue(FormulaError.NAME.getCode());
fe.evaluateFormulaCellEnum(cellB1);
fe.evaluateFormulaCell(cellB1);
cellA1.setCellValue(2.5);
fe.notifyUpdateCell(cellA1);

View File

@ -344,8 +344,8 @@ public abstract class BaseTestSheetAutosizeColumn {
Sheet sheet = workbook.getSheetAt(i);
for (Row r : sheet) {
for (Cell c : r) {
if (c.getCellTypeEnum() == CellType.FORMULA){
eval.evaluateFormulaCellEnum(c);
if (c.getCellType() == CellType.FORMULA){
eval.evaluateFormulaCell(c);
}
}
}