mirror of
https://github.com/apache/poi.git
synced 2026-02-27 20:40:08 +08:00
Fix some IDE warnings, remove usage of deprecated methods
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1876947 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a415ae13f7
commit
52320e3213
@ -839,7 +839,7 @@ public class HSSFCell extends CellBase {
|
||||
case STRING:
|
||||
int sstIndex = ((LabelSSTRecord)_record).getSSTIndex();
|
||||
String text = _book.getWorkbook().getSSTString(sstIndex).getString();
|
||||
return Boolean.valueOf(text).booleanValue();
|
||||
return Boolean.parseBoolean(text);
|
||||
case NUMERIC:
|
||||
return ((NumberRecord)_record).getValue() != 0;
|
||||
|
||||
@ -1028,7 +1028,7 @@ public class HSSFCell extends CellBase {
|
||||
* Errors are displayed as #ERR<errIdx>
|
||||
*/
|
||||
public String toString() {
|
||||
switch (getCellTypeEnum()) {
|
||||
switch (getCellType()) {
|
||||
case BLANK:
|
||||
return "";
|
||||
case BOOLEAN:
|
||||
@ -1125,7 +1125,7 @@ public class HSSFCell extends CellBase {
|
||||
link.setFirstColumn(_record.getColumn());
|
||||
link.setLastColumn(_record.getColumn());
|
||||
|
||||
switch(link.getTypeEnum()){
|
||||
switch(link.getType()){
|
||||
case EMAIL:
|
||||
case URL:
|
||||
link.setLabel("url");
|
||||
|
||||
@ -123,7 +123,8 @@ public interface Cell {
|
||||
* @return the cell type
|
||||
* @since POI 3.15 beta 3
|
||||
* @deprecated will be removed in 4.2
|
||||
* Will be renamed to <code>getCellType()</code> when we make the CellType enum transition in POI 4.0. See bug 59791.
|
||||
* Use <code>getCellType()</code>
|
||||
* Was renamed to <code>getCellType()</code> when we made the CellType enum transition in POI 4.0. See bug 59791.
|
||||
*/
|
||||
@Deprecated
|
||||
@Removal(version="4.2")
|
||||
|
||||
@ -71,7 +71,7 @@ final class SXSSFEvaluationCell implements EvaluationCell {
|
||||
@Internal(since="POI 3.15 beta 3")
|
||||
@Override
|
||||
public CellType getCellTypeEnum() {
|
||||
return _cell.getCellTypeEnum();
|
||||
return _cell.getCellType();
|
||||
}
|
||||
@Override
|
||||
public int getColumnIndex() {
|
||||
@ -97,17 +97,17 @@ final class SXSSFEvaluationCell implements EvaluationCell {
|
||||
public String getStringCellValue() {
|
||||
return _cell.getRichStringCellValue().getString();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public CellRangeAddress getArrayFormulaRange() {
|
||||
return _cell.getArrayFormulaRange();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isPartOfArrayFormulaGroup() {
|
||||
return _cell.isPartOfArrayFormulaGroup();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return cell type of cached formula result
|
||||
*/
|
||||
|
||||
@ -98,7 +98,7 @@ public class TestSXSSFCell extends BaseTestXCell {
|
||||
@Test
|
||||
public void getCellTypeEnumDelegatesToGetCellType() {
|
||||
SXSSFCell instance = spy(new SXSSFCell(null, CellType.BLANK));
|
||||
CellType result = instance.getCellTypeEnum();
|
||||
CellType result = instance.getCellType();
|
||||
verify(instance).getCellType();
|
||||
assertEquals(CellType.BLANK, result);
|
||||
}
|
||||
@ -107,6 +107,7 @@ public class TestSXSSFCell extends BaseTestXCell {
|
||||
public void getCachedFormulaResultTypeEnum_delegatesTo_getCachedFormulaResultType() {
|
||||
SXSSFCell instance = spy(new SXSSFCell(null, CellType.BLANK));
|
||||
instance.setCellFormula("");
|
||||
//noinspection deprecation
|
||||
instance.getCachedFormulaResultTypeEnum();
|
||||
verify(instance).getCachedFormulaResultType();
|
||||
}
|
||||
|
||||
@ -162,10 +162,12 @@ public final class TestFormulaParser {
|
||||
// Verify that myFunc and yourFunc were successfully added to Workbook names
|
||||
try (HSSFWorkbook wb2 = HSSFTestDataSamples.writeOutAndReadBack(wb)) {
|
||||
// HSSFWorkbook/EXCEL97-specific side-effects user-defined function names must be added to Workbook's defined names in order to be saved.
|
||||
assertNotNull(wb2.getName("myFunc"));
|
||||
assertEqualsIgnoreCase("myFunc", wb2.getName("myFunc").getNameName());
|
||||
assertNotNull(wb2.getName("yourFunc"));
|
||||
assertEqualsIgnoreCase("yourFunc", wb2.getName("yourFunc").getNameName());
|
||||
HSSFName myFunc = wb2.getName("myFunc");
|
||||
assertNotNull(myFunc);
|
||||
assertEqualsIgnoreCase("myFunc", myFunc.getNameName());
|
||||
HSSFName yourFunc = wb2.getName("yourFunc");
|
||||
assertNotNull(yourFunc);
|
||||
assertEqualsIgnoreCase("yourFunc", yourFunc.getNameName());
|
||||
|
||||
// Manually check to make sure file isn't corrupted
|
||||
// TODO: develop a process for occasionally manually reviewing workbooks
|
||||
@ -542,14 +544,14 @@ public final class TestFormulaParser {
|
||||
assertEquals("Cash_Flow!A1", formula);
|
||||
|
||||
// Then the other
|
||||
cell.setCellFormula("\'Test Sheet\'!A1");
|
||||
cell.setCellFormula("'Test Sheet'!A1");
|
||||
formula = cell.getCellFormula();
|
||||
assertEquals("\'Test Sheet\'!A1", formula);
|
||||
assertEquals("'Test Sheet'!A1", formula);
|
||||
|
||||
// Now both
|
||||
cell.setCellFormula("Cash_Flow:\'Test Sheet\'!A1");
|
||||
cell.setCellFormula("Cash_Flow:'Test Sheet'!A1");
|
||||
formula = cell.getCellFormula();
|
||||
assertEquals("Cash_Flow:\'Test Sheet\'!A1", formula);
|
||||
assertEquals("Cash_Flow:'Test Sheet'!A1", formula);
|
||||
|
||||
|
||||
// References to a range (area) of cells:
|
||||
@ -560,14 +562,14 @@ public final class TestFormulaParser {
|
||||
assertEquals("Cash_Flow!A1:B2", formula);
|
||||
|
||||
// Then the other
|
||||
cell.setCellFormula("\'Test Sheet\'!A1:B2");
|
||||
cell.setCellFormula("'Test Sheet'!A1:B2");
|
||||
formula = cell.getCellFormula();
|
||||
assertEquals("\'Test Sheet\'!A1:B2", formula);
|
||||
assertEquals("'Test Sheet'!A1:B2", formula);
|
||||
|
||||
// Now both
|
||||
cell.setCellFormula("Cash_Flow:\'Test Sheet\'!A1:B2");
|
||||
cell.setCellFormula("Cash_Flow:'Test Sheet'!A1:B2");
|
||||
formula = cell.getCellFormula();
|
||||
assertEquals("Cash_Flow:\'Test Sheet\'!A1:B2", formula);
|
||||
assertEquals("Cash_Flow:'Test Sheet'!A1:B2", formula);
|
||||
|
||||
wb.close();
|
||||
}
|
||||
@ -1085,13 +1087,13 @@ public final class TestFormulaParser {
|
||||
confirmTokenClasses(ptgs, ArrayPtg.class);
|
||||
Object element = ((ArrayPtg)ptgs[0]).getTokenArrayValues()[0][0];
|
||||
|
||||
assertEquals(-42.0, ((Double)element).doubleValue(), 0.0);
|
||||
assertEquals(-42.0, (Double) element, 0.0);
|
||||
|
||||
// Should be able to handle whitespace between unary minus and digits (Excel
|
||||
// accepts this formula after presenting the user with a confirmation dialog).
|
||||
ptgs = parseFormula("{- 5}");
|
||||
element = ((ArrayPtg)ptgs[0]).getTokenArrayValues()[0][0];
|
||||
assertEquals(-5.0, ((Double)element).doubleValue(), 0.0);
|
||||
assertEquals(-5.0, (Double) element, 0.0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -133,18 +133,15 @@ public abstract class BaseTestCell {
|
||||
assertProhibitedValueAccess(cell, CellType.BOOLEAN, CellType.STRING,
|
||||
CellType.FORMULA, CellType.ERROR);
|
||||
|
||||
String strNull = null;
|
||||
cell.setCellValue(strNull);
|
||||
cell.setCellValue((String)null);
|
||||
assertEquals("", cell.getStringCellValue());
|
||||
assertEquals(CellType.BLANK, cell.getCellType());
|
||||
|
||||
LocalDate ldNull = null;
|
||||
cell.setCellValue(ldNull);
|
||||
cell.setCellValue((LocalDate)null);
|
||||
assertNull(cell.getLocalDateTimeCellValue());
|
||||
assertEquals(CellType.BLANK, cell.getCellType());
|
||||
|
||||
LocalDateTime ldtNull = null;
|
||||
cell.setCellValue(ldtNull);
|
||||
cell.setCellValue((LocalDateTime)null);
|
||||
assertNull(cell.getLocalDateTimeCellValue());
|
||||
assertEquals(CellType.BLANK, cell.getCellType());
|
||||
|
||||
@ -769,12 +766,12 @@ public abstract class BaseTestCell {
|
||||
Sheet sh = wb1.createSheet();
|
||||
Row row = sh.createRow(0);
|
||||
Cell cell = row.createCell(0);
|
||||
cell.setCellValue(Integer.valueOf(23));
|
||||
cell.setCellValue(23);
|
||||
|
||||
cell.setCellValue("some");
|
||||
|
||||
cell = row.createCell(1);
|
||||
cell.setCellValue(Integer.valueOf(23));
|
||||
cell.setCellValue(23);
|
||||
|
||||
cell.setCellValue("24");
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user