poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1751237 [3/4] - in /poi/trunk/src: examples/src/org/apache/poi/hssf/usermodel/examples/ examples/src/org/apache/poi/hssf/view/ examples/src/org/apache/poi/ss/examples/ examples/src/org/apache/poi/ss/examples/html/ java/org/apache/poi/hssf/...
Date Mon, 04 Jul 2016 09:45:47 GMT
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFEvaluationCell.java Mon Jul  4 09:45:46 2016
@@ -19,6 +19,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;
 
 /**
  * XSSF wrapper for a cell under evaluation
@@ -37,6 +38,7 @@ final class XSSFEvaluationCell implement
 		this(cell, new XSSFEvaluationSheet(cell.getSheet()));
 	}
 
+	@Override
 	public Object getIdentityKey() {
 		// save memory by just using the cell itself as the identity key
 		// Note - this assumes XSSFCell has not overridden hashCode and equals
@@ -46,31 +48,40 @@ final class XSSFEvaluationCell implement
 	public XSSFCell getXSSFCell() {
 		return _cell;
 	}
+	@Override
 	public boolean getBooleanCellValue() {
 		return _cell.getBooleanCellValue();
 	}
-	public int getCellType() {
+	@Override
+	public CellType getCellType() {
 		return _cell.getCellType();
 	}
+	@Override
 	public int getColumnIndex() {
 		return _cell.getColumnIndex();
 	}
+	@Override
 	public int getErrorCellValue() {
 		return _cell.getErrorCellValue();
 	}
+	@Override
 	public double getNumericCellValue() {
 		return _cell.getNumericCellValue();
 	}
+	@Override
 	public int getRowIndex() {
 		return _cell.getRowIndex();
 	}
+	@Override
 	public EvaluationSheet getSheet() {
 		return _evalSheet;
 	}
+	@Override
 	public String getStringCellValue() {
 		return _cell.getRichStringCellValue().getString();
 	}
-	public int getCachedFormulaResultType() {
+	@Override
+	public CellType getCachedFormulaResultType() {
 		return _cell.getCachedFormulaResultType();
 	}
 }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java Mon Jul  4 09:45:46 2016
@@ -27,6 +27,7 @@ import org.apache.poi.ss.SpreadsheetVers
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellCopyPolicy;
 import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellReference;
@@ -184,7 +185,7 @@ public class XSSFRow implements Row, Com
     /**
      * Use this to create new cells within the row and return it.
      * <p>
-     * The cell that is returned is a {@link Cell#CELL_TYPE_BLANK}. The type can be changed
+     * The cell that is returned is a {@link CellType#BLANK}. The type can be changed
      * either through calling <code>setCellValue</code> or <code>setCellType</code>.
      * </p>
      * @param columnIndex - the column number this cell represents
@@ -194,7 +195,7 @@ public class XSSFRow implements Row, Com
      */
     @Override
     public XSSFCell createCell(int columnIndex) {
-    	return createCell(columnIndex, Cell.CELL_TYPE_BLANK);
+        return createCell(columnIndex, CellType.BLANK);
     }
 
     /**
@@ -205,15 +206,29 @@ public class XSSFRow implements Row, Com
      * @return XSSFCell a high level representation of the created cell.
      * @throws IllegalArgumentException if the specified cell type is invalid, columnIndex < 0
      *   or greater than 16384, the maximum number of columns supported by the SpreadsheetML format (.xlsx)
-     * @see Cell#CELL_TYPE_BLANK
-     * @see Cell#CELL_TYPE_BOOLEAN
-     * @see Cell#CELL_TYPE_ERROR
-     * @see Cell#CELL_TYPE_FORMULA
-     * @see Cell#CELL_TYPE_NUMERIC
-     * @see Cell#CELL_TYPE_STRING
+     * @see CellType#BLANK
+     * @see CellType#BOOLEAN
+     * @see CellType#ERROR
+     * @see CellType#FORMULA
+     * @see CellType#NUMERIC
+     * @see CellType#STRING
+     * @deprecated POI 3.15 beta 3. Use {@link #createCell(int, CellType)} instead.
      */
     @Override
     public XSSFCell createCell(int columnIndex, int type) {
+        return createCell(columnIndex, CellType.forInt(type));
+    }
+    /**
+     * Use this to create new cells within the row and return it.
+     *
+     * @param columnIndex - the column number this cell represents
+     * @param type - the cell's data type
+     * @return XSSFCell a high level representation of the created cell.
+     * @throws IllegalArgumentException if the specified cell type is invalid, columnIndex < 0
+     *   or greater than 16384, the maximum number of columns supported by the SpreadsheetML format (.xlsx)
+     */
+    @Override
+    public XSSFCell createCell(int columnIndex, CellType type) {
         // Performance optimization for bug 57840: explicit boxing is slightly faster than auto-unboxing, though may use more memory
         final Integer colI = new Integer(columnIndex); // NOSONAR
         CTCell ctCell;
@@ -226,8 +241,8 @@ public class XSSFRow implements Row, Com
         }
         XSSFCell xcell = new XSSFCell(this, ctCell);
         xcell.setCellNum(columnIndex);
-        if (type != Cell.CELL_TYPE_BLANK) {
-        	xcell.setCellType(type);
+        if (type != CellType.BLANK) {
+            xcell.setCellType(type);
         }
         _cells.put(colI, xcell);
         return xcell;
@@ -261,10 +276,10 @@ public class XSSFRow implements Row, Com
             case RETURN_NULL_AND_BLANK:
                 return cell;
             case RETURN_BLANK_AS_NULL:
-                boolean isBlank = (cell != null && cell.getCellType() == Cell.CELL_TYPE_BLANK);
+                boolean isBlank = (cell != null && cell.getCellType() == CellType.BLANK);
                 return (isBlank) ? null : cell;
             case CREATE_NULL_AS_BLANK:
-                return (cell == null) ? createCell(cellnum, Cell.CELL_TYPE_BLANK) : cell;
+                return (cell == null) ? createCell(cellnum, CellType.BLANK) : cell;
             default:
                 throw new IllegalArgumentException("Illegal policy " + policy + " (" + policy.id + ")");
         }
@@ -481,7 +496,7 @@ public class XSSFRow implements Row, Com
         if(xcell.isPartOfArrayFormulaGroup()) {
             xcell.notifyArrayFormulaChanging();
         }
-        if(cell.getCellType() == Cell.CELL_TYPE_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

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/ss/format/TestCellFormatPart.java Mon Jul  4 09:45:46 2016
@@ -58,13 +58,14 @@ public class TestCellFormatPart extends
     public void testGeneralFormat() throws Exception {
         runFormatTests("GeneralFormatTests.xlsx", new CellValue() {
             public Object getValue(Cell cell) {
-                int type = CellFormat.ultimateType(cell);
-                if (type == Cell.CELL_TYPE_BOOLEAN)
-                    return cell.getBooleanCellValue();
-                else if (type == Cell.CELL_TYPE_NUMERIC)
-                    return cell.getNumericCellValue();
-                else
-                    return cell.getStringCellValue();
+                switch (CellFormat.ultimateType(cell)) {
+                    case BOOLEAN:
+                        return cell.getBooleanCellValue();
+                    case NUMERIC:
+                        return cell.getNumericCellValue();
+                    default:
+                        return cell.getStringCellValue();
+                }
             }
         });
     }
@@ -125,10 +126,12 @@ public class TestCellFormatPart extends
     public void testTextFormat() throws Exception {
         runFormatTests("TextFormatTests.xlsx", new CellValue() {
             public Object getValue(Cell cell) {
-                if (CellFormat.ultimateType(cell) == Cell.CELL_TYPE_BOOLEAN)
-                    return cell.getBooleanCellValue();
-                else
-                    return cell.getStringCellValue();
+                switch(CellFormat.ultimateType(cell)) {
+                    case BOOLEAN:
+                        return cell.getBooleanCellValue();
+                    default:
+                        return cell.getStringCellValue();
+                }
             }
         });
     }

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestFormulaEvaluatorOnXSSF.java Mon Jul  4 09:45:46 2016
@@ -35,6 +35,7 @@ import org.apache.poi.openxml4j.opc.Pack
 import org.apache.poi.ss.formula.eval.TestFormulasFromSpreadsheet;
 import org.apache.poi.ss.formula.functions.TestMathX;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
 import org.apache.poi.ss.usermodel.FormulaEvaluator;
 import org.apache.poi.ss.usermodel.Row;
@@ -189,7 +190,7 @@ public final class TestFormulaEvaluatorO
 		for (short colnum=SS.COLUMN_INDEX_FIRST_TEST_VALUE; colnum < endcolnum; colnum++) {
 			Cell c = formulasRow.getCell(colnum);
 			assumeNotNull(c);
-			assumeTrue(c.getCellType() == Cell.CELL_TYPE_FORMULA);
+			assumeTrue(c.getCellType() == CellType.FORMULA);
 			ignoredFormulaTestCase(c.getCellFormula());
 
 			CellValue actValue = evaluator.evaluate(c);
@@ -201,33 +202,36 @@ public final class TestFormulaEvaluatorO
 			assertNotNull(msg + " - Bad setup data expected value is null", expValue);
 			assertNotNull(msg + " - actual value was null", actValue);
 	        
-	        switch (expValue.getCellType()) {
-	            case Cell.CELL_TYPE_BLANK:
-	                assertEquals(msg, Cell.CELL_TYPE_BLANK, actValue.getCellType());
+	        final CellType expectedCellType = expValue.getCellType();
+	        switch (expectedCellType) {
+	            case BLANK:
+	                assertEquals(msg, CellType.BLANK, actValue.getCellType());
 	                break;
-	            case Cell.CELL_TYPE_BOOLEAN:
-	                assertEquals(msg, Cell.CELL_TYPE_BOOLEAN, actValue.getCellType());
+	            case BOOLEAN:
+	                assertEquals(msg, CellType.BOOLEAN, actValue.getCellType());
 	                assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue());
 	                break;
-	            case Cell.CELL_TYPE_ERROR:
-	                assertEquals(msg, Cell.CELL_TYPE_ERROR, actValue.getCellType());
+	            case ERROR:
+	                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());
 //	              }
 	                break;
-	            case Cell.CELL_TYPE_FORMULA: // will never be used, since we will call method after formula evaluation
+	            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 Cell.CELL_TYPE_NUMERIC:
-	                assertEquals(msg, Cell.CELL_TYPE_NUMERIC, actValue.getCellType());
+	            case NUMERIC:
+	                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 Cell.CELL_TYPE_STRING:
-	                assertEquals(msg, Cell.CELL_TYPE_STRING, actValue.getCellType());
+	            case STRING:
+	                assertEquals(msg, CellType.STRING, actValue.getCellType());
 	                assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue());
 	                break;
+	            default:
+	                fail("Unexpected cell type: " + expectedCellType);
 	        }
 		}
 	}
@@ -260,10 +264,10 @@ public final class TestFormulaEvaluatorO
             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() == Cell.CELL_TYPE_BLANK) {
+		if(cell.getCellType() == CellType.BLANK) {
 			return null;
 		}
-		if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
+		if(cell.getCellType() == CellType.STRING) {
 			return cell.getRichStringCellValue().getString();
 		}
 		

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java Mon Jul  4 09:45:46 2016
@@ -34,6 +34,7 @@ import org.apache.poi.openxml4j.opc.Pack
 import org.apache.poi.ss.formula.eval.TestFormulasFromSpreadsheet;
 import org.apache.poi.ss.formula.functions.TestMathX;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
 import org.apache.poi.ss.usermodel.FormulaEvaluator;
 import org.apache.poi.ss.usermodel.Row;
@@ -175,7 +176,7 @@ public final class TestMultiSheetFormula
 
         Cell c = r.getCell(SS.COLUMN_INDEX_ACTUAL_VALUE);
         assumeNotNull(c);
-        assumeTrue(c.getCellType() == Cell.CELL_TYPE_FORMULA);
+        assumeTrue(c.getCellType() == CellType.FORMULA);
 
         CellValue actValue = evaluator.evaluate(c);
 
@@ -184,33 +185,36 @@ public final class TestMultiSheetFormula
 
         assertNotNull(msg + " - actual value was null", actValue);
 
-        switch (expValue.getCellType()) {
-            case Cell.CELL_TYPE_BLANK:
-                assertEquals(msg, Cell.CELL_TYPE_BLANK, actValue.getCellType());
+        final CellType expectedCellType = expValue.getCellType();
+        switch (expectedCellType) {
+            case BLANK:
+                assertEquals(msg, CellType.BLANK, actValue.getCellType());
                 break;
-            case Cell.CELL_TYPE_BOOLEAN:
-                assertEquals(msg, Cell.CELL_TYPE_BOOLEAN, actValue.getCellType());
+            case BOOLEAN:
+                assertEquals(msg, CellType.BOOLEAN, actValue.getCellType());
                 assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue());
                 break;
-            case Cell.CELL_TYPE_ERROR:
-                assertEquals(msg, Cell.CELL_TYPE_ERROR, actValue.getCellType());
+            case ERROR:
+                assertEquals(msg, CellType.ERROR, actValue.getCellType());
 //              if(false) { // TODO: fix ~45 functions which are currently returning incorrect error values
 //                  assertEquals(msg, expected.getErrorCellValue(), actual.getErrorValue());
 //              }
                 break;
-            case Cell.CELL_TYPE_FORMULA: // will never be used, since we will call method after formula evaluation
+            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 Cell.CELL_TYPE_NUMERIC:
-                assertEquals(msg, Cell.CELL_TYPE_NUMERIC, actValue.getCellType());
+            case NUMERIC:
+                assertEquals(msg, CellType.NUMERIC, actValue.getCellType());
                 TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR);
 //              double delta = Math.abs(expected.getNumericCellValue()-actual.getNumberValue());
 //              double pctExpected = Math.abs(0.00001*expected.getNumericCellValue());
 //              assertTrue(msg, delta <= pctExpected);
                 break;
-            case Cell.CELL_TYPE_STRING:
-                assertEquals(msg, Cell.CELL_TYPE_STRING, actValue.getCellType());
+            case STRING:
+                assertEquals(msg, CellType.STRING, actValue.getCellType());
                 assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue());
                 break;
+            default:
+                fail("Unexpected cell type: " + expectedCellType);
         }
     }
 
@@ -227,10 +231,10 @@ public final class TestMultiSheetFormula
             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() == Cell.CELL_TYPE_BLANK) {
+		if(cell.getCellType() == CellType.BLANK) {
 			return null;
 		}
-		if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
+		if(cell.getCellType() == CellType.STRING) {
 			return cell.getRichStringCellValue().getString();
 		}
 
@@ -251,10 +255,10 @@ public final class TestMultiSheetFormula
 		    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() == Cell.CELL_TYPE_BLANK) {
+		if(cell.getCellType() == CellType.BLANK) {
 			return null;
 		}
-		if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
+		if(cell.getCellType() == CellType.STRING) {
 			return cell.getRichStringCellValue().getString();
 		}
 

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java Mon Jul  4 09:45:46 2016
@@ -67,29 +67,7 @@ import org.apache.poi.ss.formula.eval.Er
 import org.apache.poi.ss.formula.eval.NumberEval;
 import org.apache.poi.ss.formula.eval.ValueEval;
 import org.apache.poi.ss.formula.functions.Function;
-import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.CellValue;
-import org.apache.poi.ss.usermodel.ClientAnchor;
-import org.apache.poi.ss.usermodel.Comment;
-import org.apache.poi.ss.usermodel.CreationHelper;
-import org.apache.poi.ss.usermodel.DataFormat;
-import org.apache.poi.ss.usermodel.DataFormatter;
-import org.apache.poi.ss.usermodel.DateUtil;
-import org.apache.poi.ss.usermodel.Drawing;
-import org.apache.poi.ss.usermodel.Font;
-import org.apache.poi.ss.usermodel.FormulaError;
-import org.apache.poi.ss.usermodel.FormulaEvaluator;
-import org.apache.poi.ss.usermodel.Hyperlink;
-import org.apache.poi.ss.usermodel.IndexedColors;
-import org.apache.poi.ss.usermodel.Name;
-import org.apache.poi.ss.usermodel.PrintSetup;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-import org.apache.poi.ss.usermodel.SheetConditionalFormatting;
-import org.apache.poi.ss.usermodel.Workbook;
-import org.apache.poi.ss.usermodel.WorkbookFactory;
+import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.ss.util.AreaReference;
 import org.apache.poi.ss.util.CellRangeAddress;
 import org.apache.poi.ss.util.CellReference;
@@ -322,10 +300,10 @@ public final class TestXSSFBugs extends
                 Sheet s = wb.getSheetAt(i);
                 for(Row r : s) {
                     for(Cell c : r) {
-                        if(c.getCellType() == Cell.CELL_TYPE_FORMULA) {
+                        if(c.getCellType() == CellType.FORMULA) {
                             CellValue cv = eval.evaluate(c);
 
-                            if(cv.getCellType() == Cell.CELL_TYPE_NUMERIC) {
+                            if(cv.getCellType() == CellType.NUMERIC) {
                                 // assert that the calculated value agrees with
                                 // the cached formula result calculated by Excel
                                 String formula = c.getCellFormula();
@@ -446,7 +424,7 @@ public final class TestXSSFBugs extends
 
         cell = sheet.getRow(0).getCell(0);
         assertEquals("#REF!*#REF!", cell.getCellFormula());
-        assertEquals(Cell.CELL_TYPE_ERROR, evaluator.evaluateInCell(cell).getCellType());
+        assertEquals(CellType.ERROR, evaluator.evaluateInCell(cell).getCellType());
         assertEquals("#REF!", FormulaError.forInt(cell.getErrorCellValue()).getString());
 
         Name nm1 = wb.getName("sale_1");
@@ -458,7 +436,7 @@ public final class TestXSSFBugs extends
 
         cell = sheet.getRow(1).getCell(0);
         assertEquals("sale_1*sale_2", cell.getCellFormula());
-        assertEquals(Cell.CELL_TYPE_ERROR, evaluator.evaluateInCell(cell).getCellType());
+        assertEquals(CellType.ERROR, evaluator.evaluateInCell(cell).getCellType());
         assertEquals("#REF!", FormulaError.forInt(cell.getErrorCellValue()).getString());
         
         wb.close();
@@ -606,10 +584,10 @@ public final class TestXSSFBugs extends
         // Otherwise should go
         sheet.getRow(1).getCell(0).setCellFormula("A1"); // stay
         sheet.getRow(2).getCell(0).setCellFormula(null); // go
-        sheet.getRow(3).getCell(0).setCellType(Cell.CELL_TYPE_FORMULA); // stay
+        sheet.getRow(3).getCell(0).setCellType(CellType.FORMULA); // stay
         XSSFTestDataSamples.writeOutAndReadBack(wb1).close();
 
-        sheet.getRow(4).getCell(0).setCellType(Cell.CELL_TYPE_STRING); // go
+        sheet.getRow(4).getCell(0).setCellType(CellType.STRING); // go
         XSSFTestDataSamples.writeOutAndReadBack(wb1).close();
 
         validateCells(sheet);
@@ -617,7 +595,7 @@ public final class TestXSSFBugs extends
         validateCells(sheet);
         XSSFTestDataSamples.writeOutAndReadBack(wb1).close();
 
-        sheet.getRow(6).getCell(0).setCellType(Cell.CELL_TYPE_BLANK); // go
+        sheet.getRow(6).getCell(0).setCellType(CellType.BLANK); // go
         XSSFTestDataSamples.writeOutAndReadBack(wb1).close();
 
         sheet.getRow(7).getCell(0).setCellValue((String) null); // go
@@ -664,7 +642,7 @@ public final class TestXSSFBugs extends
         Sheet sheet = wb.getSheetAt(0);
         for(Row row : sheet){
             for(Cell cell : row){
-                if(cell.getCellType() == Cell.CELL_TYPE_FORMULA){
+                if(cell.getCellType() == CellType.FORMULA){
                     formulaEvaluator.evaluateInCell(cell); // caused NPE on some cells
                 }
             }
@@ -1718,7 +1696,7 @@ public final class TestXSSFBugs extends
 
         // Get wrong cell by row 8 & column 7
         Cell cell = sheet.getRow(8).getCell(7);
-        assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCellType());
+        assertEquals(CellType.NUMERIC, cell.getCellType());
 
         // Check the value - will be zero as it is <c><v/></c>
         assertEquals(0.0, cell.getNumericCellValue(), 0.001);
@@ -2204,11 +2182,11 @@ public final class TestXSSFBugs extends
 
         Sheet sheet = wb.getSheet("Sheet1");
         Cell cell = sheet.getRow(5).getCell(4);
-        assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
+        assertEquals(CellType.FORMULA, cell.getCellType());
         assertEquals("E4+E5", cell.getCellFormula());
 
         CellValue value = evaluator.evaluate(cell);
-        assertEquals(Cell.CELL_TYPE_ERROR, value.getCellType());
+        assertEquals(CellType.ERROR, value.getCellType());
         assertEquals(-60, value.getErrorValue());
         assertEquals("~CIRCULAR~REF~", FormulaError.forInt(value.getErrorValue()).getString());
         assertEquals("CIRCULAR_REF", FormulaError.forInt(value.getErrorValue()).toString());
@@ -2563,7 +2541,7 @@ public final class TestXSSFBugs extends
                 if(cell == null){
                     cell = row.createCell(cellnum);
                 } else {
-                    if(cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
+                    if(cell.getCellType() == CellType.FORMULA) {
                         cell.setCellFormula(null);
                         cell.getCellStyle().setDataFormat((short) 0);
                     }
@@ -2629,13 +2607,13 @@ public final class TestXSSFBugs extends
     }
 
     private void assertFormula(Workbook wb, Cell intF, String expectedFormula, String expectedResultOrNull) {
-        assertEquals(Cell.CELL_TYPE_FORMULA, intF.getCellType());
+        assertEquals(CellType.FORMULA, intF.getCellType());
         if (null == expectedResultOrNull) {
-            assertEquals(Cell.CELL_TYPE_ERROR, intF.getCachedFormulaResultType());
+            assertEquals(CellType.ERROR, intF.getCachedFormulaResultType());
             expectedResultOrNull = "#VALUE!";
         }
         else {
-            assertEquals(Cell.CELL_TYPE_NUMERIC, intF.getCachedFormulaResultType());
+            assertEquals(CellType.NUMERIC, intF.getCachedFormulaResultType());
         }
 
         assertEquals(expectedFormula, intF.getCellFormula());
@@ -2676,7 +2654,7 @@ public final class TestXSSFBugs extends
         Sheet sheet = wb.getSheet("Sheet1");
         for(Row aRow : sheet) {
             Cell cell = aRow.getCell(1);
-            if(cell.getCellType() == Cell.CELL_TYPE_FORMULA) {
+            if(cell.getCellType() == CellType.FORMULA) {
                 String formula = cell.getCellFormula();
                 //System.out.println("formula: " + formula);
                 assertNotNull(formula);
@@ -2980,16 +2958,16 @@ public final class TestXSSFBugs extends
         row = worksheet.getRow(2);
         cell = row.getCell(1);
 
-        assertEquals(Cell.CELL_TYPE_BLANK, cell.getCellType());
-        assertEquals(-1, evaluator.evaluateFormulaCell(cell));
+        assertEquals(CellType.BLANK, cell.getCellType());
+        assertEquals(CellType._UNINITIALIZED, evaluator.evaluateFormulaCell(cell));
 
         // A3
         row = worksheet.getRow(2);
         cell = row.getCell(0);
 
-        assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
+        assertEquals(CellType.FORMULA, cell.getCellType());
         assertEquals("IF(ISBLANK(B3),\"\",B3)", cell.getCellFormula());
-        assertEquals(Cell.CELL_TYPE_STRING, evaluator.evaluateFormulaCell(cell));
+        assertEquals(CellType.STRING, evaluator.evaluateFormulaCell(cell));
         CellValue value = evaluator.evaluate(cell);
         assertEquals("", value.getStringValue());
 
@@ -2997,9 +2975,9 @@ public final class TestXSSFBugs extends
         row = worksheet.getRow(4);
         cell = row.getCell(0);
 
-        assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
+        assertEquals(CellType.FORMULA, cell.getCellType());
         assertEquals("COUNTBLANK(A1:A4)", cell.getCellFormula());
-        assertEquals(Cell.CELL_TYPE_NUMERIC, evaluator.evaluateFormulaCell(cell));
+        assertEquals(CellType.NUMERIC, evaluator.evaluateFormulaCell(cell));
         value = evaluator.evaluate(cell);
         assertEquals(1.0, value.getNumberValue(), 0.1);
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelConverter.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelConverter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/AbstractExcelConverter.java Mon Jul  4 09:45:46 2016
@@ -123,31 +123,31 @@ public abstract class AbstractExcelConve
         final String value;
         switch ( cell.getCellType() )
         {
-        case HSSFCell.CELL_TYPE_STRING:
+        case STRING:
             // XXX: enrich
             value = cell.getRichStringCellValue().getString();
             break;
-        case HSSFCell.CELL_TYPE_FORMULA:
+        case FORMULA:
             switch ( cell.getCachedFormulaResultType() )
             {
-            case HSSFCell.CELL_TYPE_STRING:
+            case STRING:
                 HSSFRichTextString str = cell.getRichStringCellValue();
                 if ( str == null || str.length() <= 0 )
                     return false;
 
                 value = str.toString();
                 break;
-            case HSSFCell.CELL_TYPE_NUMERIC:
+            case NUMERIC:
                 HSSFCellStyle style = cell.getCellStyle();
                 double nval = cell.getNumericCellValue();
                 short df = style.getDataFormat();
                 String dfs = style.getDataFormatString();
                 value = _formatter.formatRawCellContents(nval, df, dfs);
                 break;
-            case HSSFCell.CELL_TYPE_BOOLEAN:
+            case BOOLEAN:
                 value = String.valueOf( cell.getBooleanCellValue() );
                 break;
-            case HSSFCell.CELL_TYPE_ERROR:
+            case ERROR:
                 value = ErrorEval.getText( cell.getErrorCellValue() );
                 break;
             default:
@@ -155,16 +155,16 @@ public abstract class AbstractExcelConve
                 break;
             }
             break;
-        case HSSFCell.CELL_TYPE_BLANK:
+        case BLANK:
             value = ExcelToHtmlUtils.EMPTY;
             break;
-        case HSSFCell.CELL_TYPE_NUMERIC:
+        case NUMERIC:
             value = _formatter.formatCellValue( cell );
             break;
-        case HSSFCell.CELL_TYPE_BOOLEAN:
+        case BOOLEAN:
             value = String.valueOf( cell.getBooleanCellValue() );
             break;
-        case HSSFCell.CELL_TYPE_ERROR:
+        case ERROR:
             value = ErrorEval.getText( cell.getErrorCellValue() );
             break;
         default:

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToFoConverter.java Mon Jul  4 09:45:46 2016
@@ -209,14 +209,14 @@ public class ExcelToFoConverter extends
         String value;
         switch ( cell.getCellType() )
         {
-        case HSSFCell.CELL_TYPE_STRING:
+        case STRING:
             // XXX: enrich
             value = cell.getRichStringCellValue().getString();
             break;
-        case HSSFCell.CELL_TYPE_FORMULA:
+        case FORMULA:
             switch ( cell.getCachedFormulaResultType() )
             {
-            case HSSFCell.CELL_TYPE_STRING:
+            case STRING:
                 HSSFRichTextString str = cell.getRichStringCellValue();
                 if ( str != null && str.length() > 0 )
                 {
@@ -227,16 +227,16 @@ public class ExcelToFoConverter extends
                     value = ExcelToHtmlUtils.EMPTY;
                 }
                 break;
-            case HSSFCell.CELL_TYPE_NUMERIC:
+            case NUMERIC:
                 double nValue = cell.getNumericCellValue();
                 short df = cellStyle.getDataFormat();
                 String dfs = cellStyle.getDataFormatString();
                 value = _formatter.formatRawCellContents(nValue, df, dfs );
                 break;
-            case HSSFCell.CELL_TYPE_BOOLEAN:
+            case BOOLEAN:
                 value = Boolean.toString( cell.getBooleanCellValue() );
                 break;
-            case HSSFCell.CELL_TYPE_ERROR:
+            case ERROR:
                 value = ErrorEval.getText( cell.getErrorCellValue() );
                 break;
             default:
@@ -248,16 +248,16 @@ public class ExcelToFoConverter extends
                 break;
             }
             break;
-        case HSSFCell.CELL_TYPE_BLANK:
+        case BLANK:
             value = ExcelToHtmlUtils.EMPTY;
             break;
-        case HSSFCell.CELL_TYPE_NUMERIC:
+        case NUMERIC:
             value = _formatter.formatCellValue( cell );
             break;
-        case HSSFCell.CELL_TYPE_BOOLEAN:
+        case BOOLEAN:
             value = Boolean.toString( cell.getBooleanCellValue() );
             break;
-        case HSSFCell.CELL_TYPE_ERROR:
+        case ERROR:
             value = ErrorEval.getText( cell.getErrorCellValue() );
             break;
         default:

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hssf/converter/ExcelToHtmlConverter.java Mon Jul  4 09:45:46 2016
@@ -296,14 +296,14 @@ public class ExcelToHtmlConverter extend
         String value;
         switch ( cell.getCellType() )
         {
-        case HSSFCell.CELL_TYPE_STRING:
+        case STRING:
             // XXX: enrich
             value = cell.getRichStringCellValue().getString();
             break;
-        case HSSFCell.CELL_TYPE_FORMULA:
+        case FORMULA:
             switch ( cell.getCachedFormulaResultType() )
             {
-            case HSSFCell.CELL_TYPE_STRING:
+            case STRING:
                 HSSFRichTextString str = cell.getRichStringCellValue();
                 if ( str != null && str.length() > 0 )
                 {
@@ -314,16 +314,16 @@ public class ExcelToHtmlConverter extend
                     value = ExcelToHtmlUtils.EMPTY;
                 }
                 break;
-            case HSSFCell.CELL_TYPE_NUMERIC:
+            case NUMERIC:
                 double nValue = cell.getNumericCellValue();
                 short df = cellStyle.getDataFormat();
                 String dfs = cellStyle.getDataFormatString();
                 value = _formatter.formatRawCellContents(nValue, df, dfs);
                 break;
-            case HSSFCell.CELL_TYPE_BOOLEAN:
+            case BOOLEAN:
                 value = String.valueOf( cell.getBooleanCellValue() );
                 break;
-            case HSSFCell.CELL_TYPE_ERROR:
+            case ERROR:
                 value = ErrorEval.getText( cell.getErrorCellValue() );
                 break;
             default:
@@ -335,16 +335,16 @@ public class ExcelToHtmlConverter extend
                 break;
             }
             break;
-        case HSSFCell.CELL_TYPE_BLANK:
+        case BLANK:
             value = ExcelToHtmlUtils.EMPTY;
             break;
-        case HSSFCell.CELL_TYPE_NUMERIC:
+        case NUMERIC:
             value = _formatter.formatCellValue( cell );
             break;
-        case HSSFCell.CELL_TYPE_BOOLEAN:
+        case BOOLEAN:
             value = String.valueOf( cell.getBooleanCellValue() );
             break;
-        case HSSFCell.CELL_TYPE_ERROR:
+        case ERROR:
             value = ErrorEval.getText( cell.getErrorCellValue() );
             break;
         default:

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java Mon Jul  4 09:45:46 2016
@@ -17,12 +17,12 @@
 
 package org.apache.poi.hssf.record;
 
-import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.ss.formula.ptg.AttrPtg;
 import org.apache.poi.ss.formula.ptg.FuncVarPtg;
 import org.apache.poi.ss.formula.ptg.IntPtg;
 import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.formula.ptg.RefPtg;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.FormulaError;
 
 import junit.framework.AssertionFailedError;
@@ -83,7 +83,7 @@ public final class TestFormulaRecord ext
 		FormulaRecord record = new FormulaRecord(TestcaseRecordInputStream.create(FormulaRecord.sid, formulaByte));
 		assertEquals("Row", 0, record.getRow());
 		assertEquals("Column", 0, record.getColumn());
-		assertEquals(HSSFCell.CELL_TYPE_ERROR, record.getCachedResultType());
+		assertEquals(CellType.ERROR.getCode(), record.getCachedResultType());
 
 		byte[] output = record.serialize();
 		assertEquals("Output size", 33, output.length); //includes sid+recordlength

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Mon Jul  4 09:45:46 2016
@@ -72,6 +72,7 @@ import org.apache.poi.ss.usermodel.BaseT
 import org.apache.poi.ss.usermodel.BorderStyle;
 import org.apache.poi.ss.usermodel.Cell;
 import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.ClientAnchor.AnchorType;
 import org.apache.poi.ss.usermodel.DataFormatter;
 import org.apache.poi.ss.usermodel.FormulaEvaluator;
@@ -173,7 +174,7 @@ public final class TestBugs extends Base
             cell = row.createCell(3);
 
         // Write test
-        cell.setCellType(Cell.CELL_TYPE_STRING);
+        cell.setCellType(CellType.STRING);
         setCellText(cell, "a test");
 
         // change existing numeric cell value
@@ -468,7 +469,7 @@ public final class TestBugs extends Base
             HSSFRow row =  sheet.getRow(i);
             if (row != null) {
                 HSSFCell cell = row .getCell(0);
-                assertEquals(Cell.CELL_TYPE_STRING, cell.getCellType());
+                assertEquals(CellType.STRING, cell.getCellType());
                 count++;
             }
         }
@@ -1111,7 +1112,7 @@ public final class TestBugs extends Base
             c3.getNumericCellValue();
             fail("exception should have been thrown");
         } catch (IllegalStateException e) {
-            assertEquals("Cannot get a numeric value from a text formula cell", e.getMessage());
+            assertEquals("Cannot get a NUMERIC value from a STRING formula cell", e.getMessage());
         }
 
 
@@ -1166,13 +1167,13 @@ public final class TestBugs extends Base
     }
 
     private static void confirmCachedValue(double expectedValue, HSSFCell cell) {
-        assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
-        assertEquals(Cell.CELL_TYPE_NUMERIC, cell.getCachedFormulaResultType());
+        assertEquals(CellType.FORMULA, cell.getCellType());
+        assertEquals(CellType.NUMERIC, cell.getCachedFormulaResultType());
         assertEquals(expectedValue, cell.getNumericCellValue(), 0.0);
     }
     private static void confirmCachedValue(String expectedValue, HSSFCell cell) {
-        assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
-        assertEquals(Cell.CELL_TYPE_STRING, cell.getCachedFormulaResultType());
+        assertEquals(CellType.FORMULA, cell.getCellType());
+        assertEquals(CellType.STRING, cell.getCachedFormulaResultType());
         assertEquals(expectedValue, cell.getRichStringCellValue().getString());
     }
 
@@ -1287,7 +1288,7 @@ public final class TestBugs extends Base
         s = wb.getSheet("OneVariable Table Completed");
         r = s.getRow(3);
         c = r.getCell(4);
-        assertEquals(Cell.CELL_TYPE_FORMULA, c.getCellType());
+        assertEquals(CellType.FORMULA, c.getCellType());
 
         // TODO - check the formula once tables and
         //  arrays are properly supported
@@ -1297,7 +1298,7 @@ public final class TestBugs extends Base
         s = wb.getSheet("TwoVariable Table Example");
         r = s.getRow(3);
         c = r.getCell(4);
-        assertEquals(Cell.CELL_TYPE_FORMULA, c.getCellType());
+        assertEquals(CellType.FORMULA, c.getCellType());
 
         // TODO - check the formula once tables and
         //  arrays are properly supported
@@ -1823,26 +1824,26 @@ public final class TestBugs extends Base
        HSSFRow row;
 
        row = s.getRow(0);
-       assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1).getCellType());
+       assertEquals(CellType.NUMERIC, row.getCell(1).getCellType());
        assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
 
        row = s.getRow(1);
-       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
        assertEquals("B1", row.getCell(1).getCellFormula());
        assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
 
        row = s.getRow(2);
-       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
        assertEquals("Sheet1!B1", row.getCell(1).getCellFormula());
        assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
 
        row = s.getRow(3);
-       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
        assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula());
        assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
 
        row = s.getRow(4);
-       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
        assertEquals("'[$http://gagravarr.org/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula());
        assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
 
@@ -1852,7 +1853,7 @@ public final class TestBugs extends Base
 
        // Add 5
        row = s.createRow(5);
-       row.createCell(1, Cell.CELL_TYPE_FORMULA);
+       row.createCell(1, CellType.FORMULA);
        row.getCell(1).setCellFormula("'[$http://example.com/FormulaRefs.xls]Sheet1'!B1");
        row.getCell(1).setCellValue(234.0);
 
@@ -1863,32 +1864,32 @@ public final class TestBugs extends Base
        s = wb2.getSheetAt(0);
 
        row = s.getRow(0);
-       assertEquals(Cell.CELL_TYPE_NUMERIC, row.getCell(1).getCellType());
+       assertEquals(CellType.NUMERIC, row.getCell(1).getCellType());
        assertEquals(112.0, row.getCell(1).getNumericCellValue(),0);
 
        row = s.getRow(1);
-       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
        assertEquals("B1", row.getCell(1).getCellFormula());
        assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
 
        row = s.getRow(2);
-       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
        assertEquals("Sheet1!B1", row.getCell(1).getCellFormula());
        assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
 
        row = s.getRow(3);
-       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
        assertEquals("[Formulas2.xls]Sheet1!B2", row.getCell(1).getCellFormula());
        assertEquals(112.0, row.getCell(1).getNumericCellValue(), 0);
 
        // TODO - Fix these so they work...
        /*row = s.getRow(4);
-       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
        assertEquals("'[$http://gagravarr.org/FormulaRefs2.xls]Sheet1'!B2", row.getCell(1).getCellFormula());
        assertEquals(123.0, row.getCell(1).getNumericCellValue(), 0);
 
        row = s.getRow(5);
-       assertEquals(Cell.CELL_TYPE_FORMULA, row.getCell(1).getCellType());
+       assertEquals(CellType.FORMULA, row.getCell(1).getCellType());
        assertEquals("'[$http://example.com/FormulaRefs.xls]Sheet1'!B1", row.getCell(1).getCellFormula());
        assertEquals(234.0, row.getCell(1).getNumericCellValue(), 0);*/
        
@@ -2087,13 +2088,13 @@ public final class TestBugs extends Base
        HSSFWorkbook workbook = new HSSFWorkbook();
        Sheet sheet = workbook.createSheet("Bug50416");
        Row row1 = sheet.createRow(0);
-       Cell cellA_1 = row1.createCell(0,Cell.CELL_TYPE_STRING);
+       Cell cellA_1 = row1.createCell(0,CellType.STRING);
        cellA_1.setCellValue("Cell A,1");
        Row row2 = sheet.createRow(1);
-       Cell cellA_2 = row2.createCell(0,Cell.CELL_TYPE_STRING);
+       Cell cellA_2 = row2.createCell(0,CellType.STRING);
        cellA_2.setCellValue("Cell A,2");
        Row row3 = sheet.createRow(2);
-       Cell cellA_3 = row3.createCell(0,Cell.CELL_TYPE_STRING);
+       Cell cellA_3 = row3.createCell(0,CellType.STRING);
        cellA_3.setCellValue("Cell A,3");
 
        // Test the last Row number it currently correct
@@ -2541,7 +2542,7 @@ public final class TestBugs extends Base
             row.createCell(2).setCellValue(cal);
             row.createCell(3).setCellValue(String.format(Locale.ROOT, "row:%d/col:%d", r, 3));
             row.createCell(4).setCellValue(true);
-            row.createCell(5).setCellType(Cell.CELL_TYPE_ERROR);
+            row.createCell(5).setCellType(CellType.ERROR);
             row.createCell(6).setCellValue("added cells.");
         }
 
@@ -2754,13 +2755,13 @@ public final class TestBugs extends Base
     }
     
     private void assertFormula(Workbook wb, Cell intF, String expectedFormula, String expectedResultOrNull) {
-        assertEquals(Cell.CELL_TYPE_FORMULA, intF.getCellType());
+        assertEquals(CellType.FORMULA, intF.getCellType());
         if (null == expectedResultOrNull) {
-            assertEquals(Cell.CELL_TYPE_ERROR, intF.getCachedFormulaResultType());
+            assertEquals(CellType.ERROR, intF.getCachedFormulaResultType());
             expectedResultOrNull = "#VALUE!";
         }
         else {
-            assertEquals(Cell.CELL_TYPE_NUMERIC, intF.getCachedFormulaResultType());
+            assertEquals(CellType.NUMERIC, intF.getCachedFormulaResultType());
         }
         
         assertEquals(expectedFormula, intF.getCellFormula());
@@ -2986,12 +2987,12 @@ public final class TestBugs extends Base
         Sheet sheet = wb.getSheetAt(0);
         Row row = sheet.getRow(0);
         Cell cell = row.getCell(0);
-        assertEquals(Cell.CELL_TYPE_FORMULA, cell.getCellType());
+        assertEquals(CellType.FORMULA, cell.getCellType());
         assertEquals("IF(TRUE,\"\",\"\")", cell.getCellFormula());
         assertEquals("", cell.getStringCellValue());
-        cell.setCellType(Cell.CELL_TYPE_STRING);
+        cell.setCellType(CellType.STRING);
 
-        assertEquals(Cell.CELL_TYPE_BLANK, cell.getCellType());
+        assertEquals(CellType.BLANK, cell.getCellType());
         try {
             assertNull(cell.getCellFormula());
             fail("Should throw an exception here");

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFCell.java Mon Jul  4 09:45:46 2016
@@ -36,6 +36,7 @@ import org.apache.poi.hssf.record.Record
 import org.apache.poi.hssf.record.StringRecord;
 import org.apache.poi.ss.usermodel.BaseTestCell;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.FormulaError;
 import org.apache.poi.ss.usermodel.RichTextString;
 import org.apache.poi.ss.usermodel.Row;
@@ -417,14 +418,7 @@ public final class TestHSSFCell extends
             cell.getCachedFormulaResultType();
             fail("Should catch exception");
         } catch (IllegalStateException e) {
-			// expected here
-        }
-        
-        try {
-            assertNotNull(new HSSFCell(wb, sheet, 0, (short)0, Cell.CELL_TYPE_ERROR+1 ));
-            fail("Should catch exception");
-        } catch (RuntimeException e) {
-			// expected here
+            // expected here
         }
         
         cell.removeCellComment();
@@ -440,36 +434,36 @@ public final class TestHSSFCell extends
         Row row = sheet.createRow(0);
         Cell cell = row.createCell(0);
 
-        cell.setCellType(Cell.CELL_TYPE_BLANK);
+        cell.setCellType(CellType.BLANK);
         assertNull(null, cell.getDateCellValue());
         assertFalse(cell.getBooleanCellValue());
         assertEquals("", cell.toString());
         
-        cell.setCellType(Cell.CELL_TYPE_STRING);
+        cell.setCellType(CellType.STRING);
         assertEquals("", cell.toString());
-        cell.setCellType(Cell.CELL_TYPE_STRING);
+        cell.setCellType(CellType.STRING);
         cell.setCellValue(1.2);
-        cell.setCellType(Cell.CELL_TYPE_NUMERIC);
+        cell.setCellType(CellType.NUMERIC);
         assertEquals("1.2", cell.toString());
-        cell.setCellType(Cell.CELL_TYPE_BOOLEAN);
+        cell.setCellType(CellType.BOOLEAN);
         assertEquals("TRUE", cell.toString());
-        cell.setCellType(Cell.CELL_TYPE_BOOLEAN);
+        cell.setCellType(CellType.BOOLEAN);
         cell.setCellValue("" + FormulaError.VALUE.name());
-        cell.setCellType(Cell.CELL_TYPE_ERROR);
+        cell.setCellType(CellType.ERROR);
         assertEquals("#VALUE!", cell.toString());
-        cell.setCellType(Cell.CELL_TYPE_ERROR);
-        cell.setCellType(Cell.CELL_TYPE_BOOLEAN);
+        cell.setCellType(CellType.ERROR);
+        cell.setCellType(CellType.BOOLEAN);
         assertEquals("FALSE", cell.toString());
         cell.setCellValue(1.2);
-        cell.setCellType(Cell.CELL_TYPE_NUMERIC);
+        cell.setCellType(CellType.NUMERIC);
         assertEquals("1.2", cell.toString());
-        cell.setCellType(Cell.CELL_TYPE_BOOLEAN);
-        cell.setCellType(Cell.CELL_TYPE_STRING);
-        cell.setCellType(Cell.CELL_TYPE_ERROR);
-        cell.setCellType(Cell.CELL_TYPE_STRING);
+        cell.setCellType(CellType.BOOLEAN);
+        cell.setCellType(CellType.STRING);
+        cell.setCellType(CellType.ERROR);
+        cell.setCellType(CellType.STRING);
         cell.setCellValue(1.2);
-        cell.setCellType(Cell.CELL_TYPE_NUMERIC);
-        cell.setCellType(Cell.CELL_TYPE_STRING);
+        cell.setCellType(CellType.NUMERIC);
+        cell.setCellType(CellType.STRING);
         assertEquals("1.2", cell.toString());
         
         cell.setCellValue((String)null);

Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestWorkbook.java Mon Jul  4 09:45:46 2016
@@ -30,7 +30,7 @@ import org.apache.poi.hssf.record.Backup
 import org.apache.poi.hssf.record.LabelSSTRecord;
 import org.apache.poi.hssf.record.Record;
 import org.apache.poi.hssf.record.aggregates.RecordAggregate.RecordVisitor;
-import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.Name;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -384,16 +384,15 @@ public final class TestWorkbook {
      * OBJECTIVE:  Test that HSSF can read a simple spreadsheet with and RKRecord and correctly
      *             identify the cell as numeric and convert it to a NumberRecord.  <P>
      * SUCCESS:    HSSF reads a sheet.  HSSF returns that the cell is a numeric type cell.    <P>
-     * FAILURE:    HSSF does not read a sheet or excepts.  HSSF incorrectly indentifies the cell<P>
+     * FAILURE:    HSSF does not read a sheet or excepts.  HSSF incorrectly identifies the cell<P>
      */
     @Test
     public void testReadSheetWithRK() throws IOException {
         HSSFWorkbook wb = openSample("rk.xls");
         HSSFSheet    s  = wb.getSheetAt(0);
         HSSFCell     c  = s.getRow(0).getCell(0);
-        int          a  = c.getCellType();
 
-        assertEquals(a, Cell.CELL_TYPE_NUMERIC);
+        assertEquals(CellType.NUMERIC, c.getCellType());
         
         wb.close();
     }

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/TestWorkbookEvaluator.java Mon Jul  4 09:45:46 2016
@@ -42,6 +42,7 @@ import org.apache.poi.ss.formula.ptg.Int
 import org.apache.poi.ss.formula.ptg.Ptg;
 import org.apache.poi.ss.formula.ptg.RefErrorPtg;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
 import org.apache.poi.ss.usermodel.FormulaEvaluator;
 import org.apache.poi.ss.usermodel.Name;
@@ -200,7 +201,7 @@ public class TestWorkbookEvaluator {
         } catch (RuntimeException e) {
             fail("Missing arg result not being handled correctly.");
         }
-        assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType());
+        assertEquals(CellType.NUMERIC, cv.getCellType());
         // adding blank to 1.0 gives 1.0
         assertEquals(1.0, cv.getNumberValue(), 0.0);
 
@@ -208,7 +209,7 @@ public class TestWorkbookEvaluator {
         cell.setCellFormula("\"abc\"&IF(1,,)");
         fe.notifySetFormula(cell);
         cv = fe.evaluate(cell);
-        assertEquals(HSSFCell.CELL_TYPE_STRING, cv.getCellType());
+        assertEquals(CellType.STRING, cv.getCellType());
         // adding blank to "abc" gives "abc"
         assertEquals("abc", cv.getStringValue());
 
@@ -216,7 +217,7 @@ public class TestWorkbookEvaluator {
         cell.setCellFormula("\"abc\"&CHOOSE(2,5,,9)");
         fe.notifySetFormula(cell);
         cv = fe.evaluate(cell);
-        assertEquals(HSSFCell.CELL_TYPE_STRING, cv.getCellType());
+        assertEquals(CellType.STRING, cv.getCellType());
         // adding blank to "abc" gives "abc"
         assertEquals("abc", cv.getStringValue());
     }
@@ -242,14 +243,14 @@ public class TestWorkbookEvaluator {
                 }
                 throw new RuntimeException(e);
             }
-            assertEquals(Cell.CELL_TYPE_ERROR, cv.getCellType());
+            assertEquals(CellType.ERROR, cv.getCellType());
             assertEquals(ErrorEval.VALUE_INVALID.getErrorCode(), cv.getErrorValue());
 
             // verify circular refs are still detected properly
             fe.clearAllCachedResultValues();
             cell.setCellFormula("OFFSET(A1,0,0)");
             cv = fe.evaluate(cell);
-            assertEquals(Cell.CELL_TYPE_ERROR, cv.getCellType());
+            assertEquals(CellType.ERROR, cv.getCellType());
             assertEquals(ErrorEval.CIRCULAR_REF_ERROR.getErrorCode(), cv.getErrorValue());
         } finally {
             wb.close();
@@ -304,7 +305,7 @@ public class TestWorkbookEvaluator {
     
 // Test IF-Equals Formula Evaluation (bug 58591)
     
-    private Workbook testIFEqualsFormulaEvaluation_setup(String formula, int a1CellType) {
+    private Workbook testIFEqualsFormulaEvaluation_setup(String formula, CellType a1CellType) {
         Workbook wb = new HSSFWorkbook();
         Sheet sheet = wb.createSheet("IFEquals");
         Row row = sheet.createRow(0);
@@ -314,27 +315,29 @@ public class TestWorkbookEvaluator {
         Cell D1 = row.createCell(3);
         
         switch (a1CellType) {
-            case Cell.CELL_TYPE_NUMERIC:
+            case NUMERIC:
                 A1.setCellValue(1.0);
                 // "A1=1" should return true
                 break;
-            case Cell.CELL_TYPE_STRING:
+            case STRING:
                 A1.setCellValue("1");
                 // "A1=1" should return false
                 // "A1=\"1\"" should return true
                 break;
-            case Cell.CELL_TYPE_BOOLEAN:
+            case BOOLEAN:
                 A1.setCellValue(true);
                 // "A1=1" should return true
                 break;
-            case Cell.CELL_TYPE_FORMULA:
+            case FORMULA:
                 A1.setCellFormula("1");
                 // "A1=1" should return true
                 break;
-            case Cell.CELL_TYPE_BLANK:
+            case BLANK:
                 A1.setCellValue((String) null);
                 // "A1=1" should return false
                 break;
+            default:
+                throw new IllegalArgumentException("unexpected cell type: " + a1CellType);
         }
         B1.setCellValue(2.0);
         C1.setCellValue(3.0);
@@ -354,7 +357,7 @@ public class TestWorkbookEvaluator {
     
     
     private void testIFEqualsFormulaEvaluation_evaluate(
-        String formula, int cellType, String expectedFormula, double expectedResult) {
+        String formula, CellType cellType, String expectedFormula, double expectedResult) {
         Workbook wb = testIFEqualsFormulaEvaluation_setup(formula, cellType);
         Cell D1 = wb.getSheet("IFEquals").getRow(0).getCell(3);
         
@@ -362,17 +365,17 @@ public class TestWorkbookEvaluator {
         CellValue result = eval.evaluate(D1);
         
         // Call should not modify the contents
-        assertEquals(Cell.CELL_TYPE_FORMULA, D1.getCellType());
+        assertEquals(CellType.FORMULA, D1.getCellType());
         assertEquals(expectedFormula, D1.getCellFormula());
         
-        assertEquals(Cell.CELL_TYPE_NUMERIC, result.getCellType());
+        assertEquals(CellType.NUMERIC, result.getCellType());
         assertEquals(expectedResult, result.getNumberValue(), EPSILON);
         
         testIFEqualsFormulaEvaluation_teardown(wb);
     }
     
     private void testIFEqualsFormulaEvaluation_eval(
-            final String formula, final int cellType, final String expectedFormula, final double expectedValue) {
+            final String formula, final CellType cellType, final String expectedFormula, final double expectedValue) {
         testIFEqualsFormulaEvaluation_evaluate(formula, cellType, expectedFormula, expectedValue);
         testIFEqualsFormulaEvaluation_evaluateFormulaCell(formula, cellType, expectedFormula, expectedValue);
         testIFEqualsFormulaEvaluation_evaluateInCell(formula, cellType, expectedFormula, expectedValue);
@@ -383,7 +386,7 @@ public class TestWorkbookEvaluator {
     @Test
     public void testIFEqualsFormulaEvaluation_NumericLiteral() {
         final String formula = "IF(A1=1, 2, 3)";
-        final int cellType = Cell.CELL_TYPE_NUMERIC;
+        final CellType cellType = CellType.NUMERIC;
         final String expectedFormula = "IF(A1=1,2,3)";
         final double expectedValue = 2.0;
         testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
@@ -392,7 +395,7 @@ public class TestWorkbookEvaluator {
     @Test
     public void testIFEqualsFormulaEvaluation_Numeric() {
         final String formula = "IF(A1=1, B1, C1)";
-        final int cellType = Cell.CELL_TYPE_NUMERIC;
+        final CellType cellType = CellType.NUMERIC;
         final String expectedFormula = "IF(A1=1,B1,C1)";
         final double expectedValue = 2.0;
         testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
@@ -401,7 +404,7 @@ public class TestWorkbookEvaluator {
     @Test
     public void testIFEqualsFormulaEvaluation_NumericCoerceToString() {
         final String formula = "IF(A1&\"\"=\"1\", B1, C1)";
-        final int cellType = Cell.CELL_TYPE_NUMERIC;
+        final CellType cellType = CellType.NUMERIC;
         final String expectedFormula = "IF(A1&\"\"=\"1\",B1,C1)";
         final double expectedValue = 2.0;
         testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
@@ -410,7 +413,7 @@ public class TestWorkbookEvaluator {
     @Test
     public void testIFEqualsFormulaEvaluation_String() {
         final String formula = "IF(A1=1, B1, C1)";
-        final int cellType = Cell.CELL_TYPE_STRING;
+        final CellType cellType = CellType.STRING;
         final String expectedFormula = "IF(A1=1,B1,C1)";
         final double expectedValue = 3.0;
         testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
@@ -419,7 +422,7 @@ public class TestWorkbookEvaluator {
     @Test
     public void testIFEqualsFormulaEvaluation_StringCompareToString() {
         final String formula = "IF(A1=\"1\", B1, C1)";
-        final int cellType = Cell.CELL_TYPE_STRING;
+        final CellType cellType = CellType.STRING;
         final String expectedFormula = "IF(A1=\"1\",B1,C1)";
         final double expectedValue = 2.0;
         testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
@@ -428,7 +431,7 @@ public class TestWorkbookEvaluator {
     @Test
     public void testIFEqualsFormulaEvaluation_StringCoerceToNumeric() {
         final String formula = "IF(A1+0=1, B1, C1)";
-        final int cellType = Cell.CELL_TYPE_STRING;
+        final CellType cellType = CellType.STRING;
         final String expectedFormula = "IF(A1+0=1,B1,C1)";
         final double expectedValue = 2.0;
         testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
@@ -438,7 +441,7 @@ public class TestWorkbookEvaluator {
     @Test
     public void testIFEqualsFormulaEvaluation_Boolean() {
         final String formula = "IF(A1=1, B1, C1)";
-        final int cellType = Cell.CELL_TYPE_BOOLEAN;
+        final CellType cellType = CellType.BOOLEAN;
         final String expectedFormula = "IF(A1=1,B1,C1)";
         final double expectedValue = 2.0;
         testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
@@ -448,7 +451,7 @@ public class TestWorkbookEvaluator {
     @Test
     public void testIFEqualsFormulaEvaluation_BooleanSimple() {
         final String formula = "3-(A1=1)";
-        final int cellType = Cell.CELL_TYPE_BOOLEAN;
+        final CellType cellType = CellType.BOOLEAN;
         final String expectedFormula = "3-(A1=1)";
         final double expectedValue = 2.0;
         testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
@@ -457,7 +460,7 @@ public class TestWorkbookEvaluator {
     @Test
     public void testIFEqualsFormulaEvaluation_Formula() {
         final String formula = "IF(A1=1, B1, C1)";
-        final int cellType = Cell.CELL_TYPE_FORMULA;
+        final CellType cellType = CellType.FORMULA;
         final String expectedFormula = "IF(A1=1,B1,C1)";
         final double expectedValue = 2.0;
         testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
@@ -466,7 +469,7 @@ public class TestWorkbookEvaluator {
     @Test
     public void testIFEqualsFormulaEvaluation_Blank() {
         final String formula = "IF(A1=1, B1, C1)";
-        final int cellType = Cell.CELL_TYPE_BLANK;
+        final CellType cellType = CellType.BLANK;
         final String expectedFormula = "IF(A1=1,B1,C1)";
         final double expectedValue = 3.0;
         testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
@@ -475,7 +478,7 @@ public class TestWorkbookEvaluator {
     @Test
     public void testIFEqualsFormulaEvaluation_BlankCompareToZero() {
         final String formula = "IF(A1=0, B1, C1)";
-        final int cellType = Cell.CELL_TYPE_BLANK;
+        final CellType cellType = CellType.BLANK;
         final String expectedFormula = "IF(A1=0,B1,C1)";
         final double expectedValue = 2.0;
         testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
@@ -485,7 +488,7 @@ public class TestWorkbookEvaluator {
     @Test
     public void testIFEqualsFormulaEvaluation_BlankInverted() {
         final String formula = "IF(NOT(A1)=1, B1, C1)";
-        final int cellType = Cell.CELL_TYPE_BLANK;
+        final CellType cellType = CellType.BLANK;
         final String expectedFormula = "IF(NOT(A1)=1,B1,C1)";
         final double expectedValue = 2.0;
         testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
@@ -495,7 +498,7 @@ public class TestWorkbookEvaluator {
     @Test
     public void testIFEqualsFormulaEvaluation_BlankInvertedSimple() {
         final String formula = "3-(NOT(A1)=1)";
-        final int cellType = Cell.CELL_TYPE_BLANK;
+        final CellType cellType = CellType.BLANK;
         final String expectedFormula = "3-(NOT(A1)=1)";
         final double expectedValue = 2.0;
         testIFEqualsFormulaEvaluation_eval(formula, cellType, expectedFormula, expectedValue);
@@ -503,25 +506,25 @@ public class TestWorkbookEvaluator {
     
     
     private void testIFEqualsFormulaEvaluation_evaluateFormulaCell(
-            String formula, int cellType, String expectedFormula, double expectedResult) {
+            String formula, CellType cellType, String expectedFormula, double expectedResult) {
         Workbook wb = testIFEqualsFormulaEvaluation_setup(formula, cellType);
         Cell D1 = wb.getSheet("IFEquals").getRow(0).getCell(3);
         
         FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
-        int resultCellType = eval.evaluateFormulaCell(D1);
+        CellType resultCellType = eval.evaluateFormulaCell(D1);
         
         // Call should modify the contents, but leave the formula intact
-        assertEquals(Cell.CELL_TYPE_FORMULA, D1.getCellType());
+        assertEquals(CellType.FORMULA, D1.getCellType());
         assertEquals(expectedFormula, D1.getCellFormula());
-        assertEquals(Cell.CELL_TYPE_NUMERIC, resultCellType);
-        assertEquals(Cell.CELL_TYPE_NUMERIC, D1.getCachedFormulaResultType());
+        assertEquals(CellType.NUMERIC, resultCellType);
+        assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultType());
         assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON);
         
         testIFEqualsFormulaEvaluation_teardown(wb);
     }
     
     private void testIFEqualsFormulaEvaluation_evaluateInCell(
-            String formula, int cellType, String expectedFormula, double expectedResult) {
+            String formula, CellType cellType, String expectedFormula, double expectedResult) {
         Workbook wb = testIFEqualsFormulaEvaluation_setup(formula, cellType);
         Cell D1 = wb.getSheet("IFEquals").getRow(0).getCell(3);
         
@@ -534,14 +537,14 @@ public class TestWorkbookEvaluator {
             D1.getCellFormula();
             fail("cell formula should be overwritten with formula result");
         } catch (final IllegalStateException expected) { }
-        assertEquals(Cell.CELL_TYPE_NUMERIC, D1.getCellType());
+        assertEquals(CellType.NUMERIC, D1.getCellType());
         assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON);
         
         testIFEqualsFormulaEvaluation_teardown(wb);
     }
     
     private void testIFEqualsFormulaEvaluation_evaluateAll(
-            String formula, int cellType, String expectedFormula, double expectedResult) {
+            String formula, CellType cellType, String expectedFormula, double expectedResult) {
         Workbook wb = testIFEqualsFormulaEvaluation_setup(formula, cellType);
         Cell D1 = wb.getSheet("IFEquals").getRow(0).getCell(3);
         
@@ -549,28 +552,28 @@ public class TestWorkbookEvaluator {
         eval.evaluateAll();
         
         // Call should modify the contents
-        assertEquals(Cell.CELL_TYPE_FORMULA, D1.getCellType());
+        assertEquals(CellType.FORMULA, D1.getCellType());
         assertEquals(expectedFormula, D1.getCellFormula());
         
-        assertEquals(Cell.CELL_TYPE_NUMERIC, D1.getCachedFormulaResultType());
+        assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultType());
         assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON);
         
         testIFEqualsFormulaEvaluation_teardown(wb);
     }
     
     private void testIFEqualsFormulaEvaluation_evaluateAllFormulaCells(
-            String formula, int cellType, String expectedFormula, double expectedResult) {
+            String formula, CellType cellType, String expectedFormula, double expectedResult) {
         Workbook wb = testIFEqualsFormulaEvaluation_setup(formula, cellType);
         Cell D1 = wb.getSheet("IFEquals").getRow(0).getCell(3);
         
         HSSFFormulaEvaluator.evaluateAllFormulaCells(wb);
         
         // Call should modify the contents
-        assertEquals(Cell.CELL_TYPE_FORMULA, D1.getCellType());
+        assertEquals(CellType.FORMULA, D1.getCellType());
         // whitespace gets deleted because formula is parsed and re-rendered
         assertEquals(expectedFormula, D1.getCellFormula());
         
-        assertEquals(Cell.CELL_TYPE_NUMERIC, D1.getCachedFormulaResultType());
+        assertEquals(CellType.NUMERIC, D1.getCachedFormulaResultType());
         assertEquals(expectedResult, D1.getNumericCellValue(), EPSILON);
         
         testIFEqualsFormulaEvaluation_teardown(wb);

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/TestFormulasFromSpreadsheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/TestFormulasFromSpreadsheet.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/TestFormulasFromSpreadsheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/TestFormulasFromSpreadsheet.java Mon Jul  4 09:45:46 2016
@@ -31,6 +31,7 @@ import org.apache.poi.hssf.usermodel.HSS
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.formula.functions.TestMathX;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -173,7 +174,7 @@ public final class TestFormulasFromSprea
        // 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() != Cell.CELL_TYPE_FORMULA) {
+           if (c == null || c.getCellType() != CellType.FORMULA) {
                continue;
            }
 
@@ -186,28 +187,31 @@ public final class TestFormulasFromSprea
            assertNotNull(msg + " - Bad setup data expected value is null", expValue);
            assertNotNull(msg + " - actual value was null", actValue);
 
-           switch (expValue.getCellType()) {
-               case Cell.CELL_TYPE_BLANK:
-                   assertEquals(msg, Cell.CELL_TYPE_BLANK, actValue.getCellType());
+           final CellType cellType = expValue.getCellType();
+           switch (cellType) {
+               case BLANK:
+                   assertEquals(msg, CellType.BLANK, actValue.getCellType());
                    break;
-               case Cell.CELL_TYPE_BOOLEAN:
-                   assertEquals(msg, Cell.CELL_TYPE_BOOLEAN, actValue.getCellType());
+               case BOOLEAN:
+                   assertEquals(msg, CellType.BOOLEAN, actValue.getCellType());
                    assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue());
                    break;
-               case Cell.CELL_TYPE_ERROR:
-                   assertEquals(msg, Cell.CELL_TYPE_ERROR, actValue.getCellType());
+               case ERROR:
+                   assertEquals(msg, CellType.ERROR, actValue.getCellType());
                    assertEquals(msg, ErrorEval.getText(expValue.getErrorCellValue()), ErrorEval.getText(actValue.getErrorValue()));
                    break;
-               case Cell.CELL_TYPE_FORMULA: // will never be used, since we will call method after formula evaluation
+               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 Cell.CELL_TYPE_NUMERIC:
-                   assertEquals(msg, Cell.CELL_TYPE_NUMERIC, actValue.getCellType());
+               case NUMERIC:
+                   assertEquals(msg, CellType.NUMERIC, actValue.getCellType());
                    TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR);
                    break;
-               case Cell.CELL_TYPE_STRING:
-                   assertEquals(msg, Cell.CELL_TYPE_STRING, actValue.getCellType());
+               case STRING:
+                   assertEquals(msg, CellType.STRING, actValue.getCellType());
                    assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue());
                    break;
+               default:
+                   fail("Unexpected cell type: " + cellType);
            }
        }
    }
@@ -224,10 +228,10 @@ public final class TestFormulasFromSprea
 			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() == Cell.CELL_TYPE_BLANK) {
+		if(cell.getCellType() == CellType.BLANK) {
 			return null;
 		}
-		if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
+		if(cell.getCellType() == CellType.STRING) {
 			return cell.getRichStringCellValue().getString();
 		}
 

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/TestMultiSheetEval.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/TestMultiSheetEval.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/TestMultiSheetEval.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/eval/TestMultiSheetEval.java Mon Jul  4 09:45:46 2016
@@ -30,6 +30,7 @@ import org.apache.poi.hssf.usermodel.HSS
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.ss.formula.functions.TestMathX;
 import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
@@ -104,29 +105,33 @@ public final class TestMultiSheetEval ex
 		if(actual == null) {
 			throw new AssertionFailedError(msg + " - actual value was null");
 		}
+		
+		final CellType cellType = expected.getCellType();
 
-		switch (expected.getCellType()) {
-			case Cell.CELL_TYPE_BLANK:
-				assertEquals(msg, Cell.CELL_TYPE_BLANK, actual.getCellType());
+		switch (cellType) {
+			case BLANK:
+				assertEquals(msg, CellType.BLANK, actual.getCellType());
 				break;
-			case Cell.CELL_TYPE_BOOLEAN:
-				assertEquals(msg, Cell.CELL_TYPE_BOOLEAN, actual.getCellType());
+			case BOOLEAN:
+				assertEquals(msg, CellType.BOOLEAN, actual.getCellType());
 				assertEquals(msg, expected.getBooleanCellValue(), actual.getBooleanValue());
 				break;
-			case Cell.CELL_TYPE_ERROR:
-				assertEquals(msg, Cell.CELL_TYPE_ERROR, actual.getCellType());
+			case ERROR:
+				assertEquals(msg, CellType.ERROR, actual.getCellType());
 				assertEquals(msg, ErrorEval.getText(expected.getErrorCellValue()), ErrorEval.getText(actual.getErrorValue()));
 				break;
-			case Cell.CELL_TYPE_FORMULA: // will never be used, since we will call method after formula evaluation
+			case FORMULA: // will never be used, since we will call method after formula evaluation
 				throw new AssertionFailedError("Cannot expect formula as result of formula evaluation: " + msg);
-			case Cell.CELL_TYPE_NUMERIC:
-				assertEquals(msg, Cell.CELL_TYPE_NUMERIC, actual.getCellType());
+			case NUMERIC:
+				assertEquals(msg, CellType.NUMERIC, actual.getCellType());
 				TestMathX.assertEquals(msg, expected.getNumericCellValue(), actual.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR);
 				break;
-			case Cell.CELL_TYPE_STRING:
-				assertEquals(msg, Cell.CELL_TYPE_STRING, actual.getCellType());
+			case STRING:
+				assertEquals(msg, CellType.STRING, actual.getCellType());
 				assertEquals(msg, expected.getRichStringCellValue().getString(), actual.getStringValue());
 				break;
+			default:
+				throw new AssertionFailedError("Unexpected cell type: " + cellType);
 		}
 	}
 
@@ -226,7 +231,7 @@ public final class TestMultiSheetEval ex
 		int result = Result.NO_EVALUATIONS_FOUND; // so far
 
 		Cell c = formulasRow.getCell(SS.COLUMN_INDEX_ACTUAL_VALUE);
-		if (c == null || c.getCellType() != Cell.CELL_TYPE_FORMULA) {
+		if (c == null || c.getCellType() != CellType.FORMULA) {
 			return result;
 		}
 
@@ -295,10 +300,10 @@ public final class TestMultiSheetEval ex
 			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() == Cell.CELL_TYPE_BLANK) {
+		if(cell.getCellType() == CellType.BLANK) {
 			return null;
 		}
-		if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
+		if(cell.getCellType() == CellType.STRING) {
 			return cell.getRichStringCellValue().getString();
 		}
 
@@ -318,10 +323,10 @@ public final class TestMultiSheetEval ex
 			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() == Cell.CELL_TYPE_BLANK) {
+		if(cell.getCellType() == CellType.BLANK) {
 			return null;
 		}
-		if(cell.getCellType() == Cell.CELL_TYPE_STRING) {
+		if(cell.getCellType() == CellType.STRING) {
 			return cell.getRichStringCellValue().getString();
 		}
 

Modified: poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/BaseTestFunctionsFromSpreadsheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/BaseTestFunctionsFromSpreadsheet.java?rev=1751237&r1=1751236&r2=1751237&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/BaseTestFunctionsFromSpreadsheet.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/formula/functions/BaseTestFunctionsFromSpreadsheet.java Mon Jul  4 09:45:46 2016
@@ -36,6 +36,7 @@ import org.apache.poi.hssf.usermodel.HSS
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 import org.apache.poi.hssf.util.CellReference;
 import org.apache.poi.ss.formula.eval.ErrorEval;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.CellValue;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -122,7 +123,7 @@ public abstract class BaseTestFunctionsF
                 currentGroupComment = newMarkerValue;
             }
             HSSFCell evalCell = r.getCell(SS.COLUMN_INDEX_EVALUATION);
-            if (evalCell == null || evalCell.getCellType() != HSSFCell.CELL_TYPE_FORMULA) {
+            if (evalCell == null || evalCell.getCellType() != CellType.FORMULA) {
                 continue;
             }
             String rowComment = getCellTextValue(r, SS.COLUMN_ROW_COMMENT, "row comment");
@@ -152,9 +153,9 @@ public abstract class BaseTestFunctionsF
         assertNotNull(msg + " - Bad setup data expected value is null", expectedCell);
         assertNotNull(msg + " - actual value was null", actualValue);
 
-        if (expectedCell.getCellType() == HSSFCell.CELL_TYPE_ERROR) {
+        if (expectedCell.getCellType() == CellType.ERROR) {
             int expectedErrorCode = expectedCell.getErrorCellValue();
-            assertEquals(msg, HSSFCell.CELL_TYPE_ERROR, actualValue.getCellType());
+            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()));
@@ -162,24 +163,27 @@ public abstract class BaseTestFunctionsF
         }
 
         // unexpected error
-        assertNotEquals(msg, HSSFCell.CELL_TYPE_ERROR, actualValue.getCellType());
+        assertNotEquals(msg, CellType.ERROR, actualValue.getCellType());
         assertNotEquals(msg, formatValue(expectedCell), ErrorEval.getText(actualValue.getErrorValue()));
 
         // wrong type error
         assertEquals(msg, expectedCell.getCellType(), actualValue.getCellType());
 
-        switch (expectedCell.getCellType()) {
-            case HSSFCell.CELL_TYPE_BOOLEAN:
+        final CellType expectedCellType = expectedCell.getCellType();
+        switch (expectedCellType) {
+            case BOOLEAN:
                 assertEquals(msg, expectedCell.getBooleanCellValue(), actualValue.getBooleanValue());
                 break;
-            case HSSFCell.CELL_TYPE_FORMULA: // will never be used, since we will call method after formula evaluation
+            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 HSSFCell.CELL_TYPE_NUMERIC:
+            case NUMERIC:
                 assertEquals(expectedCell.getNumericCellValue(), actualValue.getNumberValue(), 0.0);
                 break;
-            case HSSFCell.CELL_TYPE_STRING:
+            case STRING:
                 assertEquals(msg, expectedCell.getRichStringCellValue().getString(), actualValue.getStringValue());
                 break;
+            default:
+                fail("Unexpected cell type: " + expectedCellType);
         }
     }
 
@@ -208,10 +212,10 @@ public abstract class BaseTestFunctionsF
         if(cell == null) {
             return null;
         }
-        if(cell.getCellType() == HSSFCell.CELL_TYPE_BLANK) {
+        if(cell.getCellType() == CellType.BLANK) {
             return null;
         }
-        if(cell.getCellType() == HSSFCell.CELL_TYPE_STRING) {
+        if(cell.getCellType() == CellType.STRING) {
             return cell.getRichStringCellValue().getString();
         }
 
@@ -222,12 +226,12 @@ public abstract class BaseTestFunctionsF
 
     private static String formatValue(HSSFCell expecedCell) {
         switch (expecedCell.getCellType()) {
-            case HSSFCell.CELL_TYPE_BLANK: return "<blank>";
-            case HSSFCell.CELL_TYPE_BOOLEAN: return Boolean.toString(expecedCell.getBooleanCellValue());
-            case HSSFCell.CELL_TYPE_NUMERIC: return Double.toString(expecedCell.getNumericCellValue());
-            case HSSFCell.CELL_TYPE_STRING: return expecedCell.getRichStringCellValue().getString();
+            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.getCellType() + ")");
         }
-        fail("Unexpected cell type of expected value (" + expecedCell.getCellType() + ")");
         return "";
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message