From: PJ Fanning Date: Mon, 18 Sep 2017 15:55:48 +0000 (+0000) Subject: change HyperLink getType to return HyperlinkType X-Git-Tag: REL_4_0_0_FINAL~499 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1e8ecbec04bbe9701898f321d2f3b3bd17d78f94;p=poi.git change HyperLink getType to return HyperlinkType git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808737 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java b/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java index 5c6fa9fa44..c64508a7be 100644 --- a/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java +++ b/src/examples/src/org/apache/poi/ss/examples/ExcelComparator.java @@ -179,7 +179,7 @@ public class ExcelComparator { private void compareDataInCell(Locator loc1, Locator loc2) { if (isCellTypeMatches(loc1, loc2)) { - final CellType loc1cellType = loc1.cell.getCellTypeEnum(); + final CellType loc1cellType = loc1.cell.getCellType(); switch(loc1cellType) { case BLANK: case STRING: @@ -579,8 +579,8 @@ public class ExcelComparator { * Checks if cell type matches. */ private boolean isCellTypeMatches(Locator loc1, Locator loc2) { - CellType type1 = loc1.cell.getCellTypeEnum(); - CellType type2 = loc2.cell.getCellTypeEnum(); + CellType type1 = loc1.cell.getCellType(); + CellType type2 = loc2.cell.getCellType(); if (type1 == type2) return true; addMessage(loc1, loc2, "Cell Data-Type does not Match in :: ", diff --git a/src/java/org/apache/poi/common/usermodel/Hyperlink.java b/src/java/org/apache/poi/common/usermodel/Hyperlink.java index 648227b152..edb57bc645 100644 --- a/src/java/org/apache/poi/common/usermodel/Hyperlink.java +++ b/src/java/org/apache/poi/common/usermodel/Hyperlink.java @@ -56,16 +56,17 @@ public interface Hyperlink { * * @return the type of this hyperlink * @see HyperlinkType#forInt(int) - * @deprecated POI 3.15 beta 3. Use {@link #getTypeEnum()} - * getType will return a HyperlinkType enum in the future. */ - public int getType(); + public HyperlinkType getType(); /** * Return the type of this hyperlink * * @return the type of this hyperlink * @since POI 3.15 beta 3 + * @deprecated use getType() instead */ + @Deprecated + @Removal(version = "4.2") public HyperlinkType getTypeEnum(); } diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java b/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java index 137a681914..4b947959e6 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFHyperlink.java @@ -20,6 +20,7 @@ import org.apache.poi.common.usermodel.HyperlinkType; import org.apache.poi.hssf.record.HyperlinkRecord; import org.apache.poi.ss.usermodel.Hyperlink; import org.apache.poi.util.Internal; +import org.apache.poi.util.Removal; /** * Represents an Excel hyperlink. @@ -258,22 +259,23 @@ public class HSSFHyperlink implements Hyperlink { * * @return the type of this hyperlink * @see HyperlinkType#forInt - * @deprecated POI 3.15. Use {@link #getTypeEnum()} instead. - * getType will return a HyperlinkType enum in the future. */ @Override - public int getType() { - return link_type.getCode(); + public HyperlinkType getType() { + return link_type; } /** * Return the type of this hyperlink * * @return the type of this hyperlink + * @deprecated use getType() instead */ + @Deprecated + @Removal(version = "4.2") @Override public HyperlinkType getTypeEnum() { - return link_type; + return getType(); } /** diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java b/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java index be1f3044f2..c38fd375b2 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFOptimiser.java @@ -142,7 +142,7 @@ public class HSSFOptimiser { HSSFSheet s = workbook.getSheetAt(sheetNum); for (Row row : s) { for (Cell cell : row) { - if(cell.getCellTypeEnum() == CellType.STRING) { + if(cell.getCellType() == CellType.STRING) { HSSFRichTextString rtr = (HSSFRichTextString)cell.getRichStringCellValue(); UnicodeString u = rtr.getRawUnicodeString(); diff --git a/src/java/org/apache/poi/ss/usermodel/Cell.java b/src/java/org/apache/poi/ss/usermodel/Cell.java index d77efed56f..13ddfd6518 100644 --- a/src/java/org/apache/poi/ss/usermodel/Cell.java +++ b/src/java/org/apache/poi/ss/usermodel/Cell.java @@ -208,7 +208,7 @@ public interface Cell { * Return a formula for the cell, for example, SUM(C4:E4) * * @return a formula for the cell - * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not {@link CellType#FORMULA} + * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not {@link CellType#FORMULA} */ String getCellFormula(); @@ -219,7 +219,7 @@ public interface Cell { * For formulas or error cells we return the precalculated value; *

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

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

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

* * @return the value of the cell as an error code - * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't {@link CellType#ERROR} + * @throws IllegalStateException if the cell type returned by {@link #getCellType()} isn't {@link CellType#ERROR} * @see FormulaError for error codes */ byte getErrorCellValue(); diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java index c0e029fed7..d5d0d4c6cb 100644 --- a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java +++ b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFHyperlink.java @@ -26,6 +26,7 @@ import org.apache.poi.openxml4j.opc.TargetMode; import org.apache.poi.sl.usermodel.Hyperlink; import org.apache.poi.sl.usermodel.Slide; import org.apache.poi.util.Internal; +import org.apache.poi.util.Removal; import org.openxmlformats.schemas.drawingml.x2006.main.CTHyperlink; public class XSLFHyperlink implements Hyperlink { @@ -69,17 +70,8 @@ public class XSLFHyperlink implements Hyperlink { _link.setTooltip(label); } - /* (non-Javadoc) - * @deprecated POI 3.15. Use {@link #getTypeEnum()} instead. - * Will return a HyperlinkType enum in the future - */ @Override - public int getType() { - return getTypeEnum().getCode(); - } - - @Override - public HyperlinkType getTypeEnum() { + public HyperlinkType getType() { String action = _link.getAction(); if (action == null) { action = ""; @@ -87,7 +79,7 @@ public class XSLFHyperlink implements Hyperlink { if (action.equals("ppaction://hlinksldjump") || action.startsWith("ppaction://hlinkshowjump")) { return HyperlinkType.DOCUMENT; } - + String address = getAddress(); if (address == null) { address = ""; @@ -99,6 +91,13 @@ public class XSLFHyperlink implements Hyperlink { } } + @Deprecated + @Removal(version = "4.2") + @Override + public HyperlinkType getTypeEnum() { + return getType(); + } + @Override public void linkToEmail(String emailAddress) { linkToExternal("mailto:"+emailAddress); diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java index 0396f39108..9cb9f698c7 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java @@ -343,7 +343,7 @@ public class SXSSFCell implements Cell { * Return a formula for the cell, for example, SUM(C4:E4) * * @return a formula for the cell - * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is not CellType.FORMULA + * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is not CellType.FORMULA */ @Override public String getCellFormula() @@ -360,14 +360,14 @@ public class SXSSFCell implements Cell { * For formulas or error cells we return the precalculated value; *

* @return the value of the cell as a number - * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} is CellType.STRING + * @throws IllegalStateException if the cell type returned by {@link #getCellType()} is CellType.STRING * @exception NumberFormatException if the cell value isn't a parsable double. * @see org.apache.poi.ss.usermodel.DataFormatter for turning this number into a string similar to that which Excel would render this number as. */ @Override public double getNumericCellValue() { - CellType cellType = getCellTypeEnum(); + CellType cellType = getCellType(); switch(cellType) { case BLANK: @@ -399,7 +399,7 @@ public class SXSSFCell implements Cell { @Override public Date getDateCellValue() { - CellType cellType = getCellTypeEnum(); + CellType cellType = getCellType(); if (cellType == CellType.BLANK) { return null; @@ -421,8 +421,8 @@ public class SXSSFCell implements Cell { @Override public RichTextString getRichStringCellValue() { - CellType cellType = getCellTypeEnum(); - if(getCellTypeEnum() != CellType.STRING) + CellType cellType = getCellType(); + if(getCellType() != CellType.STRING) throw typeMismatch(CellType.STRING, cellType, false); StringValue sval = (StringValue)_value; @@ -446,7 +446,7 @@ public class SXSSFCell implements Cell { @Override public String getStringCellValue() { - CellType cellType = getCellTypeEnum(); + CellType cellType = getCellType(); switch(cellType) { case BLANK: @@ -518,7 +518,7 @@ public class SXSSFCell implements Cell { @Override public boolean getBooleanCellValue() { - CellType cellType = getCellTypeEnum(); + CellType cellType = getCellType(); switch(cellType) { case BLANK: @@ -553,7 +553,7 @@ public class SXSSFCell implements Cell { @Override public byte getErrorCellValue() { - CellType cellType = getCellTypeEnum(); + CellType cellType = getCellType(); switch(cellType) { case BLANK: @@ -746,7 +746,7 @@ public class SXSSFCell implements Cell { case STRING: return getRichStringCellValue().toString(); default: - return "Unknown Cell Type: " + getCellTypeEnum(); + return "Unknown Cell Type: " + getCellType(); } } @@ -979,7 +979,7 @@ public class SXSSFCell implements Cell { } private boolean convertCellValueToBoolean() { - CellType cellType = getCellTypeEnum(); + CellType cellType = getCellType(); if (cellType == CellType.FORMULA) { cellType = getCachedFormulaResultType(); @@ -1002,7 +1002,7 @@ public class SXSSFCell implements Cell { } private String convertCellValueToString() { - CellType cellType = getCellTypeEnum(); + CellType cellType = getCellType(); return convertCellValueToString(cellType); } private String convertCellValueToString(CellType cellType) { diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java index 1065fc60c7..be7f6c397c 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java @@ -25,6 +25,7 @@ import org.apache.poi.openxml4j.opc.PackageRelationship; import org.apache.poi.ss.usermodel.Hyperlink; import org.apache.poi.ss.util.CellReference; import org.apache.poi.util.Internal; +import org.apache.poi.util.Removal; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHyperlink; /** @@ -108,13 +109,13 @@ public class XSSFHyperlink implements Hyperlink { public XSSFHyperlink(Hyperlink other) { if (other instanceof XSSFHyperlink) { XSSFHyperlink xlink = (XSSFHyperlink) other; - _type = xlink.getTypeEnum(); + _type = xlink.getType(); _location = xlink._location; _externalRel = xlink._externalRel; _ctHyperlink = (CTHyperlink) xlink._ctHyperlink.copy(); } else { - _type = other.getTypeEnum(); + _type = other.getType(); _location = other.getAddress(); _externalRel = null; _ctHyperlink = CTHyperlink.Factory.newInstance(); @@ -156,22 +157,23 @@ public class XSSFHyperlink implements Hyperlink { * * @return the type of this hyperlink * @see HyperlinkType#forInt - * @deprecated POI 3.15 beta 3. Use {@link #getTypeEnum()} instead. - * getType will return a HyperlinkType enum in the future. */ @Override - public int getType() { - return _type.getCode(); + public HyperlinkType getType() { + return _type; } /** * Return the type of this hyperlink * * @return the type of this hyperlink + * @deprecated use getType instead */ + @Deprecated + @Removal(version = "4.2") @Override public HyperlinkType getTypeEnum() { - return _type; + return getType(); } /** diff --git a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java index 746c1bb124..4c4152badb 100644 --- a/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java +++ b/src/ooxml/testcases/org/apache/poi/xslf/usermodel/TestXSLFHyperlink.java @@ -147,13 +147,13 @@ public class TestXSLFHyperlink { hl1 = tb1.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink(); assertNotNull(hl1); assertEquals("dev@poi.apache.org", hl1.getLabel()); - assertEquals(HyperlinkType.EMAIL, hl1.getTypeEnum()); + assertEquals(HyperlinkType.EMAIL, hl1.getType()); tb2 = (XSLFTextBox)slides.get(1).getShapes().get(0); hl2 = tb2.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink(); assertNotNull(hl2); assertEquals("lastslide", hl2.getXmlObject().getAction().split("=")[1]); - assertEquals(HyperlinkType.DOCUMENT, hl2.getTypeEnum()); + assertEquals(HyperlinkType.DOCUMENT, hl2.getType()); tb3 = (XSLFTextBox)slides.get(2).getShapes().get(0); XSLFHyperlink hl3 = tb3.getTextParagraphs().get(0).getTextRuns().get(1).getHyperlink(); @@ -161,19 +161,19 @@ public class TestXSLFHyperlink { hl3 = tb3.getTextParagraphs().get(0).getTextRuns().get(3).getHyperlink(); assertNotNull(hl3); assertEquals("/ppt/slides/slide1.xml", hl3.getAddress()); - assertEquals(HyperlinkType.DOCUMENT, hl3.getTypeEnum()); + assertEquals(HyperlinkType.DOCUMENT, hl3.getType()); tb4 = (XSLFTextBox)slides.get(3).getShapes().get(0); hl4 = tb4.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink(); assertNotNull(hl4); assertEquals("http://poi.apache.org", hl4.getLabel()); - assertEquals(HyperlinkType.URL, hl4.getTypeEnum()); + assertEquals(HyperlinkType.URL, hl4.getType()); tb5 = (XSLFTextBox)slides.get(4).getShapes().get(0); hl5 = tb5.getHyperlink(); assertNotNull(hl5); assertEquals("firstslide", hl5.getXmlObject().getAction().split("=")[1]); - assertEquals(HyperlinkType.DOCUMENT, hl5.getTypeEnum()); + assertEquals(HyperlinkType.DOCUMENT, hl5.getType()); ppt2.close(); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java b/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java index d2fd60f3ea..42cf2714a5 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/model/TestCalculationChain.java @@ -42,7 +42,7 @@ public final class TestCalculationChain extends TestCase { XSSFSheet sheet = wb.getSheet("Test"); XSSFCell cell = sheet.getRow(0).getCell(4); - assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, cell.getCellType()); cell.setCellFormula(null); //the count of items is less by one @@ -53,9 +53,9 @@ public final class TestCalculationChain extends TestCase { assertEquals(10, c.getI()); assertEquals("C1", c.getR()); - assertEquals(CellType.STRING, cell.getCellTypeEnum()); + assertEquals(CellType.STRING, cell.getCellType()); cell.setCellValue("ABC"); - assertEquals(CellType.STRING, cell.getCellTypeEnum()); + assertEquals(CellType.STRING, cell.getCellType()); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java index 39e3cb87f6..0f6b1e2a52 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMatrixFormulasFromXMLSpreadsheet.java @@ -165,7 +165,7 @@ public final class TestMatrixFormulasFromXMLSpreadsheet { Cell c = sheet.getRow(rowNum).getCell(colNum); - if (c == null || c.getCellTypeEnum() != CellType.FORMULA) { + if (c == null || c.getCellType() != CellType.FORMULA) { continue; } @@ -178,27 +178,27 @@ public final class TestMatrixFormulasFromXMLSpreadsheet { 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: @@ -222,15 +222,15 @@ public final class TestMatrixFormulasFromXMLSpreadsheet { System.err.println("Warning - Row " + r.getRowNum() + " has no cell " + Navigator.START_OPERATORS_COL_INDEX + ", 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) + ")"); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java index bdd85130c8..74648bb7e6 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestMultiSheetFormulaEvaluatorOnXSSF.java @@ -176,7 +176,7 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF { Cell c = r.getCell(SS.COLUMN_INDEX_ACTUAL_VALUE); assumeNotNull(c); - assumeTrue(c.getCellTypeEnum() == CellType.FORMULA); + assumeTrue(c.getCellType() == CellType.FORMULA); CellValue actValue = evaluator.evaluate(c); @@ -185,17 +185,17 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF { 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, expected.getErrorCellValue(), actual.getErrorValue()); // } @@ -203,14 +203,14 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF { 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(expected.getNumericCellValue()-actual.getNumberValue()); // double pctExpected = Math.abs(0.00001*expected.getNumericCellValue()); // assertTrue(msg, delta <= pctExpected); break; case STRING: - assertEquals(msg, CellType.STRING, actValue.getCellTypeEnum()); + assertEquals(msg, CellType.STRING, actValue.getCellType()); assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue()); break; default: @@ -231,15 +231,15 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF { logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name"); return null; } - if(cell.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 'function name' column: (" - + cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")"); + + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")"); return ""; } /** @@ -255,15 +255,15 @@ public final class TestMultiSheetFormulaEvaluatorOnXSSF { logger.log(POILogger.WARN, "Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_TEST_NAME + ", can't figure out test name"); return null; } - if(cell.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 'test name' column: (" - + cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")"); + + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")"); return ""; } diff --git a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFHyperlink.java b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFHyperlink.java index 73d11905fd..2385a00c4e 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFHyperlink.java +++ b/src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFHyperlink.java @@ -33,6 +33,7 @@ import org.apache.poi.hslf.record.Record; import org.apache.poi.hslf.record.TxInteractiveInfoAtom; import org.apache.poi.sl.usermodel.Hyperlink; import org.apache.poi.sl.usermodel.Slide; +import org.apache.poi.util.Removal; /** * Represents a hyperlink in a PowerPoint document @@ -128,11 +129,26 @@ public final class HSLFHyperlink implements HyperlinkgetType instead */ + @Deprecated + @Removal(version = "4.2") @Override public HyperlinkType getTypeEnum() { - switch (info.getInteractiveInfoAtom().getHyperlinkType()) { - case InteractiveInfoAtom.LINK_Url: - return (exHyper.getLinkURL().startsWith("mailto:")) ? HyperlinkType.EMAIL : HyperlinkType.URL; - case InteractiveInfoAtom.LINK_NextSlide: - case InteractiveInfoAtom.LINK_PreviousSlide: - case InteractiveInfoAtom.LINK_FirstSlide: - case InteractiveInfoAtom.LINK_LastSlide: - case InteractiveInfoAtom.LINK_SlideNumber: - return HyperlinkType.DOCUMENT; - case InteractiveInfoAtom.LINK_CustomShow: - case InteractiveInfoAtom.LINK_OtherPresentation: - case InteractiveInfoAtom.LINK_OtherFile: - return HyperlinkType.FILE; - default: - case InteractiveInfoAtom.LINK_NULL: - return HyperlinkType.NONE; - } + return getType(); } @Override diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java b/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java index 0a9414c6f6..6505a391db 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestCellStyle.java @@ -438,7 +438,7 @@ public final class TestCellStyle extends TestCase { Cell cell = row.getCell(idxCell); cell.getCellStyle().getDataFormatString(); - if (cell.getCellTypeEnum() == CellType.NUMERIC) { + if (cell.getCellType() == CellType.NUMERIC) { boolean isDate = HSSFDateUtil.isCellDateFormatted(cell); if (idxCell > 0 && isDate) { fail("cell " + idxCell + " is not a date: " + idxCell); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java index a54d8f1e74..382a1f3f0b 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFHyperlink.java @@ -65,7 +65,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { assertEquals("POI", link.getLabel()); assertEquals("POI", cell.getRichStringCellValue().getString()); assertEquals("http://poi.apache.org/", link.getAddress()); - assertEquals(HyperlinkType.URL, link.getTypeEnum()); + assertEquals(HyperlinkType.URL, link.getType()); cell = sheet.getRow(8).getCell(0); link = cell.getHyperlink(); @@ -73,7 +73,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { assertEquals("HSSF", link.getLabel()); assertEquals("HSSF", cell.getRichStringCellValue().getString()); assertEquals("http://poi.apache.org/hssf/", link.getAddress()); - assertEquals(HyperlinkType.URL, link.getTypeEnum()); + assertEquals(HyperlinkType.URL, link.getType()); sheet = wb.getSheet("Emails"); cell = sheet.getRow(4).getCell(0); @@ -82,7 +82,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { assertEquals("dev", link.getLabel()); assertEquals("dev", cell.getRichStringCellValue().getString()); assertEquals("mailto:dev@poi.apache.org", link.getAddress()); - assertEquals(HyperlinkType.EMAIL, link.getTypeEnum()); + assertEquals(HyperlinkType.EMAIL, link.getType()); sheet = wb.getSheet("Internal"); cell = sheet.getRow(4).getCell(0); @@ -92,7 +92,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink { assertEquals("Link To First Sheet", cell.getRichStringCellValue().getString()); assertEquals("WebLinks!A1", link.getTextMark()); assertEquals("WebLinks!A1", link.getAddress()); - assertEquals(HyperlinkType.DOCUMENT, link.getTypeEnum()); + assertEquals(HyperlinkType.DOCUMENT, link.getType()); } @Test diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestMatrixFormulasFromBinarySpreadsheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestMatrixFormulasFromBinarySpreadsheet.java index 4aac72893f..9d17834189 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestMatrixFormulasFromBinarySpreadsheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestMatrixFormulasFromBinarySpreadsheet.java @@ -164,7 +164,7 @@ public final class TestMatrixFormulasFromBinarySpreadsheet { Cell c = sheet.getRow(rowNum).getCell(colNum); - if (c == null || c.getCellTypeEnum() != CellType.FORMULA) { + if (c == null || c.getCellType() != CellType.FORMULA) { continue; } @@ -177,27 +177,27 @@ public final class TestMatrixFormulasFromBinarySpreadsheet { 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: @@ -221,15 +221,15 @@ public final class TestMatrixFormulasFromBinarySpreadsheet { System.err.println("Warning - Row " + r.getRowNum() + " has no cell " + Navigator.START_OPERATORS_COL_INDEX + ", 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) + ")"); } diff --git a/src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java b/src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java index ec3aa9107d..4c0223afd7 100644 --- a/src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java +++ b/src/testcases/org/apache/poi/ss/formula/eval/BaseTestCircularReferences.java @@ -66,7 +66,7 @@ public abstract class BaseTestCircularReferences { * Makes sure that the specified evaluated cell value represents a circular reference error. */ private static void confirmCycleErrorCode(CellValue cellValue) { - assertTrue(cellValue.getCellTypeEnum() == CellType.ERROR); + assertTrue(cellValue.getCellType() == CellType.ERROR); assertEquals(ErrorEval.CIRCULAR_REF_ERROR.getErrorCode(), cellValue.getErrorValue()); } @@ -96,7 +96,7 @@ public abstract class BaseTestCircularReferences { CellValue cellValue = evaluateWithCycles(wb, testCell); - assertTrue(cellValue.getCellTypeEnum() == CellType.NUMERIC); + assertTrue(cellValue.getCellType() == CellType.NUMERIC); assertEquals(2, cellValue.getNumberValue(), 0); wb.close(); } @@ -166,24 +166,24 @@ public abstract class BaseTestCircularReferences { // Happy day flow - evaluate A1 first cv = fe.evaluate(cellA1); - assertEquals(CellType.NUMERIC, cv.getCellTypeEnum()); + assertEquals(CellType.NUMERIC, cv.getCellType()); assertEquals(42.0, cv.getNumberValue(), 0.0); cv = fe.evaluate(cellB1); // no circ-ref-error because A1 result is cached - assertEquals(CellType.NUMERIC, cv.getCellTypeEnum()); + assertEquals(CellType.NUMERIC, cv.getCellType()); assertEquals(46.0, cv.getNumberValue(), 0.0); // Show the bug - evaluate another cell from the loop first fe.clearAllCachedResultValues(); cv = fe.evaluate(cellB1); // Identified bug 46898 - assertNotEquals(cv.getCellTypeEnum(), ErrorEval.CIRCULAR_REF_ERROR.getErrorCode()); - assertEquals(CellType.NUMERIC, cv.getCellTypeEnum()); + assertNotEquals(cv.getCellType(), ErrorEval.CIRCULAR_REF_ERROR.getErrorCode()); + assertEquals(CellType.NUMERIC, cv.getCellType()); assertEquals(46.0, cv.getNumberValue(), 0.0); // start evaluation on another cell fe.clearAllCachedResultValues(); cv = fe.evaluate(cellE1); - assertEquals(CellType.NUMERIC, cv.getCellTypeEnum()); + assertEquals(CellType.NUMERIC, cv.getCellType()); assertEquals(43.0, cv.getNumberValue(), 0.0); wb.close(); diff --git a/src/testcases/org/apache/poi/ss/formula/eval/TestMultiSheetEval.java b/src/testcases/org/apache/poi/ss/formula/eval/TestMultiSheetEval.java index f3128579c3..c82fa6a57f 100644 --- a/src/testcases/org/apache/poi/ss/formula/eval/TestMultiSheetEval.java +++ b/src/testcases/org/apache/poi/ss/formula/eval/TestMultiSheetEval.java @@ -106,28 +106,28 @@ public final class TestMultiSheetEval extends TestCase { throw new AssertionFailedError(msg + " - actual value was null"); } - final CellType cellType = expected.getCellTypeEnum(); + final CellType cellType = expected.getCellType(); switch (cellType) { case BLANK: - assertEquals(msg, CellType.BLANK, actual.getCellTypeEnum()); + assertEquals(msg, CellType.BLANK, actual.getCellType()); break; case BOOLEAN: - assertEquals(msg, CellType.BOOLEAN, actual.getCellTypeEnum()); + assertEquals(msg, CellType.BOOLEAN, actual.getCellType()); assertEquals(msg, expected.getBooleanCellValue(), actual.getBooleanValue()); break; case ERROR: - assertEquals(msg, CellType.ERROR, actual.getCellTypeEnum()); + assertEquals(msg, CellType.ERROR, actual.getCellType()); assertEquals(msg, ErrorEval.getText(expected.getErrorCellValue()), ErrorEval.getText(actual.getErrorValue())); break; 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 NUMERIC: - assertEquals(msg, CellType.NUMERIC, actual.getCellTypeEnum()); + assertEquals(msg, CellType.NUMERIC, actual.getCellType()); TestMathX.assertEquals(msg, expected.getNumericCellValue(), actual.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR); break; case STRING: - assertEquals(msg, CellType.STRING, actual.getCellTypeEnum()); + assertEquals(msg, CellType.STRING, actual.getCellType()); assertEquals(msg, expected.getRichStringCellValue().getString(), actual.getStringValue()); break; default: @@ -232,7 +232,7 @@ public final class TestMultiSheetEval extends TestCase { int result = Result.NO_EVALUATIONS_FOUND; // so far Cell c = formulasRow.getCell(SS.COLUMN_INDEX_ACTUAL_VALUE); - if (c == null || c.getCellTypeEnum() != CellType.FORMULA) { + if (c == null || c.getCellType() != CellType.FORMULA) { return result; } @@ -301,15 +301,15 @@ public final class TestMultiSheetEval extends TestCase { System.err.println("Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_FUNCTION_NAME + ", can't figure out function name"); return null; } - if(cell.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) + ")"); } /** * @return null if cell is missing, empty or blank @@ -324,15 +324,15 @@ public final class TestMultiSheetEval extends TestCase { System.err.println("Warning - Row " + r.getRowNum() + " has no cell " + SS.COLUMN_INDEX_TEST_NAME + ", can't figure out test name"); return null; } - if(cell.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 'test name' column: (" - + cell.getCellTypeEnum() + ") row (" + (r.getRowNum() +1) + ")"); + + cell.getCellType() + ") row (" + (r.getRowNum() +1) + ")"); } } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java index 2492c20a81..27ac4c93a8 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java @@ -256,36 +256,36 @@ public abstract class BaseTestRow { row.createCell(5).setCellValue(4); // First up, no policy given, uses default - assertEquals(CellType.STRING, row.getCell(0).getCellTypeEnum()); - assertEquals(CellType.NUMERIC, row.getCell(1).getCellTypeEnum()); + assertEquals(CellType.STRING, row.getCell(0).getCellType()); + assertEquals(CellType.NUMERIC, row.getCell(1).getCellType()); assertEquals(null, row.getCell(2)); assertEquals(null, row.getCell(3)); - assertEquals(CellType.BLANK, row.getCell(4).getCellTypeEnum()); - assertEquals(CellType.NUMERIC, row.getCell(5).getCellTypeEnum()); + assertEquals(CellType.BLANK, row.getCell(4).getCellType()); + assertEquals(CellType.NUMERIC, row.getCell(5).getCellType()); // RETURN_NULL_AND_BLANK - same as default - assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellTypeEnum()); - assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellTypeEnum()); + assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType()); + assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType()); assertEquals(null, row.getCell(2, MissingCellPolicy.RETURN_NULL_AND_BLANK)); assertEquals(null, row.getCell(3, MissingCellPolicy.RETURN_NULL_AND_BLANK)); - assertEquals(CellType.BLANK, row.getCell(4, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellTypeEnum()); - assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellTypeEnum()); + assertEquals(CellType.BLANK, row.getCell(4, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType()); + assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_NULL_AND_BLANK).getCellType()); // RETURN_BLANK_AS_NULL - nearly the same - assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellTypeEnum()); - assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellTypeEnum()); + assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType()); + assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType()); assertEquals(null, row.getCell(2, MissingCellPolicy.RETURN_BLANK_AS_NULL)); assertEquals(null, row.getCell(3, MissingCellPolicy.RETURN_BLANK_AS_NULL)); assertEquals(null, row.getCell(4, MissingCellPolicy.RETURN_BLANK_AS_NULL)); - assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellTypeEnum()); + assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.RETURN_BLANK_AS_NULL).getCellType()); // CREATE_NULL_AS_BLANK - creates as needed - assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum()); - assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum()); - assertEquals(CellType.BLANK, row.getCell(2, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum()); - assertEquals(CellType.BLANK, row.getCell(3, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum()); - assertEquals(CellType.BLANK, row.getCell(4, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum()); - assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellTypeEnum()); + assertEquals(CellType.STRING, row.getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType()); + assertEquals(CellType.NUMERIC, row.getCell(1, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType()); + assertEquals(CellType.BLANK, row.getCell(2, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType()); + assertEquals(CellType.BLANK, row.getCell(3, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType()); + assertEquals(CellType.BLANK, row.getCell(4, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType()); + assertEquals(CellType.NUMERIC, row.getCell(5, MissingCellPolicy.CREATE_NULL_AS_BLANK).getCellType()); // Check created ones get the right column assertEquals(0, row.getCell(0, MissingCellPolicy.CREATE_NULL_AS_BLANK).getColumnIndex()); @@ -300,12 +300,12 @@ public abstract class BaseTestRow { // that that is now used if no policy given workbook.setMissingCellPolicy(MissingCellPolicy.RETURN_BLANK_AS_NULL); - assertEquals(CellType.STRING, row.getCell(0).getCellTypeEnum()); - assertEquals(CellType.NUMERIC, row.getCell(1).getCellTypeEnum()); + assertEquals(CellType.STRING, row.getCell(0).getCellType()); + assertEquals(CellType.NUMERIC, row.getCell(1).getCellType()); assertEquals(null, row.getCell(2)); assertEquals(null, row.getCell(3)); assertEquals(null, row.getCell(4)); - assertEquals(CellType.NUMERIC, row.getCell(5).getCellTypeEnum()); + assertEquals(CellType.NUMERIC, row.getCell(5).getCellType()); workbook.close(); } @@ -420,7 +420,7 @@ public abstract class BaseTestRow { assertTrue(cell5 == it.next()); assertTrue(it.hasNext()); assertTrue(cell2 == it.next()); - assertEquals(CellType.STRING, cell5.getCellTypeEnum()); + assertEquals(CellType.STRING, cell5.getCellType()); wb.close(); } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java index bbc9ab7e73..7d25d634f5 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheetUpdateArrayFormulas.java @@ -133,7 +133,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { for(Cell acell : cells){ assertTrue(acell.isPartOfArrayFormulaGroup()); - assertEquals(CellType.FORMULA, acell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, acell.getCellType()); assertEquals("SUM(A1:A3*B1:B3)", acell.getCellFormula()); //retrieve the range and check it is the same assertEquals(range.formatAsString(), acell.getArrayFormulaRange().formatAsString()); @@ -210,7 +210,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { for(Cell acell : cr){ assertFalse(acell.isPartOfArrayFormulaGroup()); - assertEquals(CellType.BLANK, acell.getCellTypeEnum()); + assertEquals(CellType.BLANK, acell.getCellType()); } // cells C4:C6 are not included in array formula, @@ -279,7 +279,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { CellRange srange = sheet.setArrayFormula("SUM(A4:A6,B4:B6)", CellRangeAddress.valueOf("B5")); Cell scell = srange.getTopLeftCell(); - assertEquals(CellType.FORMULA, scell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, scell.getCellType()); assertEquals(0.0, scell.getNumericCellValue(), 0); scell.setCellValue(1.1); assertEquals(1.1, scell.getNumericCellValue(), 0); @@ -288,7 +288,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { CellRange mrange = sheet.setArrayFormula("A1:A3*B1:B3", CellRangeAddress.valueOf("C1:C3")); for(Cell mcell : mrange){ - assertEquals(CellType.FORMULA, mcell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, mcell.getCellType()); assertEquals(0.0, mcell.getNumericCellValue(), 0); double fmlaResult = 1.2; mcell.setCellValue(fmlaResult); @@ -307,10 +307,10 @@ public abstract class BaseTestSheetUpdateArrayFormulas { CellRange srange = sheet.setArrayFormula("SUM(A4:A6,B4:B6)", CellRangeAddress.valueOf("B5")); Cell scell = srange.getTopLeftCell(); - assertEquals(CellType.FORMULA, scell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, scell.getCellType()); assertEquals(0.0, scell.getNumericCellValue(), 0); scell.setCellType(CellType.STRING); - assertEquals(CellType.STRING, scell.getCellTypeEnum()); + assertEquals(CellType.STRING, scell.getCellType()); scell.setCellValue("string cell"); assertEquals("string cell", scell.getStringCellValue()); @@ -319,7 +319,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { sheet.setArrayFormula("A1:A3*B1:B3", CellRangeAddress.valueOf("C1:C3")); for(Cell mcell : mrange){ try { - assertEquals(CellType.FORMULA, mcell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, mcell.getCellType()); mcell.setCellType(CellType.NUMERIC); fail("expected exception"); } catch (IllegalStateException e){ @@ -329,7 +329,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { } // a failed invocation of Cell.setCellType leaves the cell // in the state that it was in prior to the invocation - assertEquals(CellType.FORMULA, mcell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, mcell.getCellType()); assertTrue(mcell.isPartOfArrayFormulaGroup()); } workbook.close(); @@ -344,13 +344,13 @@ public abstract class BaseTestSheetUpdateArrayFormulas { sheet.setArrayFormula("SUM(A4:A6,B4:B6)", CellRangeAddress.valueOf("B5")); Cell scell = srange.getTopLeftCell(); assertEquals("SUM(A4:A6,B4:B6)", scell.getCellFormula()); - assertEquals(CellType.FORMULA, scell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, scell.getCellType()); assertTrue(scell.isPartOfArrayFormulaGroup()); scell.setCellFormula("SUM(A4,A6)"); //we are now a normal formula cell assertEquals("SUM(A4,A6)", scell.getCellFormula()); assertFalse(scell.isPartOfArrayFormulaGroup()); - assertEquals(CellType.FORMULA, scell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, scell.getCellType()); //check that setting formula result works assertEquals(0.0, scell.getNumericCellValue(), 0); scell.setCellValue(33.0); @@ -396,7 +396,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { //re-create the removed cell scell = srow.createCell(cra.getFirstColumn()); - assertEquals(CellType.BLANK, scell.getCellTypeEnum()); + assertEquals(CellType.BLANK, scell.getCellType()); assertFalse(scell.isPartOfArrayFormulaGroup()); //we cannot remove cells included in a multi-cell array formula @@ -417,7 +417,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { // in the state that it was in prior to the invocation assertSame(mcell, mrow.getCell(columnIndex)); assertTrue(mcell.isPartOfArrayFormulaGroup()); - assertEquals(CellType.FORMULA, mcell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, mcell.getCellType()); } workbook.close(); @@ -433,7 +433,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { CellRange srange = sheet.setArrayFormula("SUM(A4:A6,B4:B6)", cra); Cell scell = srange.getTopLeftCell(); - assertEquals(CellType.FORMULA, scell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, scell.getCellType()); Row srow = scell.getRow(); assertSame(srow, sheet.getRow(cra.getFirstRow())); @@ -442,7 +442,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { //re-create the removed row and cell scell = sheet.createRow(cra.getFirstRow()).createCell(cra.getFirstColumn()); - assertEquals(CellType.BLANK, scell.getCellTypeEnum()); + assertEquals(CellType.BLANK, scell.getCellType()); assertFalse(scell.isPartOfArrayFormulaGroup()); //we cannot remove rows with cells included in a multi-cell array formula @@ -463,7 +463,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { assertSame(mrow, sheet.getRow(mrow.getRowNum())); assertSame(mcell, mrow.getCell(columnIndex)); assertTrue(mcell.isPartOfArrayFormulaGroup()); - assertEquals(CellType.FORMULA, mcell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, mcell.getCellType()); } workbook.close(); @@ -481,7 +481,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { Cell scell = srange.getTopLeftCell(); sheet.addMergedRegion(CellRangeAddress.valueOf("B5:C6")); //we are still an array formula - assertEquals(CellType.FORMULA, scell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, scell.getCellType()); assertTrue(scell.isPartOfArrayFormulaGroup()); assertEquals(1, sheet.getNumMergedRegions()); @@ -570,7 +570,7 @@ public abstract class BaseTestSheetUpdateArrayFormulas { assertEquals(cra.formatAsString(), mcell.getArrayFormulaRange().formatAsString()); assertEquals("A2:A4*B2:B4", mcell.getCellFormula()); assertTrue(mcell.isPartOfArrayFormulaGroup()); - assertEquals(CellType.FORMULA, mcell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, mcell.getCellType()); } */ diff --git a/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java b/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java index fb81622509..b642de340e 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java +++ b/src/testcases/org/apache/poi/ss/usermodel/TestDataFormatter.java @@ -811,7 +811,7 @@ public class TestDataFormatter { CellReference ref = new CellReference("D47"); Cell cell = wb.getSheetAt(0).getRow(ref.getRow()).getCell(ref.getCol()); - assertEquals(CellType.FORMULA, cell.getCellTypeEnum()); + assertEquals(CellType.FORMULA, cell.getCellType()); assertEquals("G9:K9 I7:I12", cell.getCellFormula()); DataFormatter formatter = new DataFormatter(); diff --git a/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java b/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java index d081db0fc3..7a668b016d 100644 --- a/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java +++ b/src/testcases/org/apache/poi/ss/util/TestSheetBuilder.java @@ -50,7 +50,7 @@ public final class TestSheetBuilder extends TestCase { Row firstRow = sheet.getRow(0); Cell firstCell = firstRow.getCell(0); - assertEquals(firstCell.getCellTypeEnum(), CellType.NUMERIC); + assertEquals(firstCell.getCellType(), CellType.NUMERIC); assertEquals(1.0, firstCell.getNumericCellValue(), 0.00001); @@ -59,11 +59,11 @@ public final class TestSheetBuilder extends TestCase { assertNull(secondRow.getCell(2)); Row thirdRow = sheet.getRow(2); - assertEquals(CellType.STRING, thirdRow.getCell(0).getCellTypeEnum()); + assertEquals(CellType.STRING, thirdRow.getCell(0).getCellType()); String cellValue = thirdRow.getCell(0).getStringCellValue(); assertEquals(testData[2][0].toString(), cellValue); - assertEquals(CellType.FORMULA, thirdRow.getCell(2).getCellTypeEnum()); + assertEquals(CellType.FORMULA, thirdRow.getCell(2).getCellType()); assertEquals("A1+B2", thirdRow.getCell(2).getCellFormula()); } @@ -73,7 +73,7 @@ public final class TestSheetBuilder extends TestCase { Cell emptyCell = sheet.getRow(1).getCell(1); assertNotNull(emptyCell); - assertEquals(CellType.BLANK, emptyCell.getCellTypeEnum()); + assertEquals(CellType.BLANK, emptyCell.getCellType()); } public void testSheetName() {