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:
* 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 :: ",
*
* @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 <code>getType()</code> instead
*/
+ @Deprecated
+ @Removal(version = "4.2")
public HyperlinkType getTypeEnum();
}
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.
*
* @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 <code>getType()</code> instead
*/
+ @Deprecated
+ @Removal(version = "4.2")
@Override
public HyperlinkType getTypeEnum() {
- return link_type;
+ return getType();
}
/**
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();
* Return a formula for the cell, for example, <code>SUM(C4:E4)</code>
*
* @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();
* For formulas or error cells we return the precalculated value;
* </p>
* @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 <code>double</code>.
* @see DataFormatter for turning this number into a string similar to that which Excel would render this number as.
*/
* For strings we throw an exception. For blank cells we return a null.
* </p>
* @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 <code>double</code>.
* @see DataFormatter for formatting this date into a string similar to how excel does.
*/
* For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
* </p>
* @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();
* </p>
*
* @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();
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<XSLFShape,XSLFTextParagraph> {
_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 = "";
if (action.equals("ppaction://hlinksldjump") || action.startsWith("ppaction://hlinkshowjump")) {
return HyperlinkType.DOCUMENT;
}
-
+
String address = getAddress();
if (address == null) {
address = "";
}
}
+ @Deprecated
+ @Removal(version = "4.2")
+ @Override
+ public HyperlinkType getTypeEnum() {
+ return getType();
+ }
+
@Override
public void linkToEmail(String emailAddress) {
linkToExternal("mailto:"+emailAddress);
* Return a formula for the cell, for example, <code>SUM(C4:E4)</code>
*
* @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()
* For formulas or error cells we return the precalculated value;
* </p>
* @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 <code>double</code>.
* @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:
@Override
public Date getDateCellValue()
{
- CellType cellType = getCellTypeEnum();
+ CellType cellType = getCellType();
if (cellType == CellType.BLANK)
{
return null;
@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;
@Override
public String getStringCellValue()
{
- CellType cellType = getCellTypeEnum();
+ CellType cellType = getCellType();
switch(cellType)
{
case BLANK:
@Override
public boolean getBooleanCellValue()
{
- CellType cellType = getCellTypeEnum();
+ CellType cellType = getCellType();
switch(cellType)
{
case BLANK:
@Override
public byte getErrorCellValue()
{
- CellType cellType = getCellTypeEnum();
+ CellType cellType = getCellType();
switch(cellType)
{
case BLANK:
case STRING:
return getRichStringCellValue().toString();
default:
- return "Unknown Cell Type: " + getCellTypeEnum();
+ return "Unknown Cell Type: " + getCellType();
}
}
}
private boolean convertCellValueToBoolean() {
- CellType cellType = getCellTypeEnum();
+ CellType cellType = getCellType();
if (cellType == CellType.FORMULA) {
cellType = getCachedFormulaResultType();
}
private String convertCellValueToString() {
- CellType cellType = getCellTypeEnum();
+ CellType cellType = getCellType();
return convertCellValueToString(cellType);
}
private String convertCellValueToString(CellType cellType) {
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;
/**
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();
*
* @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 <code>getType</code> instead
*/
+ @Deprecated
+ @Removal(version = "4.2")
@Override
public HyperlinkType getTypeEnum() {
- return _type;
+ return getType();
}
/**
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();
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();
}
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
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());
}
Cell c = sheet.getRow(rowNum).getCell(colNum);
- if (c == null || c.getCellTypeEnum() != CellType.FORMULA) {
+ if (c == null || c.getCellType() != CellType.FORMULA) {
continue;
}
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:
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) + ")");
}
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);
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());
// }
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:
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 "";
}
/**
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 "";
}
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
*
* @return the hyperlink URL
* @see InteractiveInfoAtom
- * @deprecated POI 3.15 beta 3. Use {@link #getTypeEnum()}
*/
@Override
- public int getType() {
- return getTypeEnum().getCode();
+ public HyperlinkType getType() {
+ 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 the hyperlink URL
* @see InteractiveInfoAtom
+ * @deprecated use <code>getType</code> 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
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);
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();
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);
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);
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
Cell c = sheet.getRow(rowNum).getCell(colNum);
- if (c == null || c.getCellTypeEnum() != CellType.FORMULA) {
+ if (c == null || c.getCellType() != CellType.FORMULA) {
continue;
}
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:
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) + ")");
}
* 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());
}
CellValue cellValue = evaluateWithCycles(wb, testCell);
- assertTrue(cellValue.getCellTypeEnum() == CellType.NUMERIC);
+ assertTrue(cellValue.getCellType() == CellType.NUMERIC);
assertEquals(2, cellValue.getNumberValue(), 0);
wb.close();
}
// 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();
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:
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;
}
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 <code>null</code> if cell is missing, empty or blank
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) + ")");
}
}
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());
// 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();
}
assertTrue(cell5 == it.next());
assertTrue(it.hasNext());
assertTrue(cell2 == it.next());
- assertEquals(CellType.STRING, cell5.getCellTypeEnum());
+ assertEquals(CellType.STRING, cell5.getCellType());
wb.close();
}
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());
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,
CellRange<? extends Cell> 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);
CellRange<? extends Cell> 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);
CellRange<? extends Cell> 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());
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){
}
// 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();
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);
//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
// 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();
CellRange<? extends Cell> 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()));
//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
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();
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());
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());
}
*/
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();
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);
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());
}
Cell emptyCell = sheet.getRow(1).getCell(1);
assertNotNull(emptyCell);
- assertEquals(CellType.BLANK, emptyCell.getCellTypeEnum());
+ assertEquals(CellType.BLANK, emptyCell.getCellType());
}
public void testSheetName() {