From 8d4f3fde68d19056aada68c8e9a0c98154b42ca3 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Sat, 3 Mar 2018 01:48:46 +0000 Subject: [PATCH] remove some casts to short git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1825749 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/ss/util/PropertyTemplate.java | 4 ++-- .../org/apache/poi/ss/util/RegionUtil.java | 2 +- .../apache/poi/xssf/streaming/SXSSFCell.java | 2 +- .../xssf/usermodel/XSSFFontFormatting.java | 2 +- .../poi/xssf/usermodel/TestXSSFBugs.java | 6 ++--- .../poi/xssf/usermodel/TestXSSFColor.java | 2 +- .../poi/xssf/usermodel/TestXSSFFont.java | 22 +++++++++---------- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/java/org/apache/poi/ss/util/PropertyTemplate.java b/src/java/org/apache/poi/ss/util/PropertyTemplate.java index 7b310cdbd..b19ea9f71 100644 --- a/src/java/org/apache/poi/ss/util/PropertyTemplate.java +++ b/src/java/org/apache/poi/ss/util/PropertyTemplate.java @@ -958,8 +958,8 @@ public final class PropertyTemplate { * @return short value, or 0 if not a short */ private static short getShort(Object value) { - if (value instanceof Short) { - return ((Short) value).shortValue(); + if (value instanceof Number) { + return ((Number) value).shortValue(); } return 0; } diff --git a/src/java/org/apache/poi/ss/util/RegionUtil.java b/src/java/org/apache/poi/ss/util/RegionUtil.java index 5434aa380..7846d015a 100644 --- a/src/java/org/apache/poi/ss/util/RegionUtil.java +++ b/src/java/org/apache/poi/ss/util/RegionUtil.java @@ -42,7 +42,7 @@ public final class RegionUtil { public CellPropertySetter(String propertyName, int value) { _propertyName = propertyName; - _propertyValue = Short.valueOf((short) value); + _propertyValue = Integer.valueOf(value); } public CellPropertySetter(String propertyName, BorderStyle value) { _propertyName = propertyName; 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 782e21bee..4e8310ea2 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFCell.java @@ -613,7 +613,7 @@ public class SXSSFCell implements Cell { { if(_style == null){ SXSSFWorkbook wb = (SXSSFWorkbook)getRow().getSheet().getWorkbook(); - return wb.getCellStyleAt((short)0); + return wb.getCellStyleAt(0); } else { return _style; } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java index 89eea6ad4..a86c637ee 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFontFormatting.java @@ -138,7 +138,7 @@ public class XSSFFontFormatting implements FontFormatting { if(_font.sizeOfSzArray() == 0) return -1; CTFontSize sz = _font.getSzArray(0); - return (short)(20*sz.getVal()); + return (int)(20*sz.getVal()); } /** diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index fe8cafcaa..06751cf2e 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -876,7 +876,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { font1.setColor((short) 20); Font font2 = wb1.createFont(); font2.setColor(Font.COLOR_RED); - Font font3 = wb1.getFontAt((short) 0); + Font font3 = wb1.getFontAt(0); XSSFRow row = sheet.createRow(2); XSSFCell cell = row.createCell(2); @@ -1750,9 +1750,9 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { // run some method on the font to verify if it is "disconnected" already //for(short i = 0;i < 256;i++) { - Font font = wb.getFontAt((short) 0); + Font font = wb.getFontAt(0); if (font instanceof XSSFFont) { - XSSFFont xfont = (XSSFFont) wb.getFontAt((short) 0); + XSSFFont xfont = (XSSFFont) wb.getFontAt(0); CTFontImpl ctFont = (CTFontImpl) xfont.getCTFont(); assertEquals(0, ctFont.sizeOfBArray()); } diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java index 64d27548d..b9339ba01 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFColor.java @@ -35,7 +35,7 @@ public final class TestXSSFColor { XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48779.xlsx"); // Check the CTColor is as expected - XSSFColor indexed = wb.getCellStyleAt((short)1).getFillBackgroundXSSFColor(); + XSSFColor indexed = wb.getCellStyleAt(1).getFillBackgroundXSSFColor(); assertEquals(true, indexed.getCTColor().isSetIndexed()); assertEquals(64, indexed.getCTColor().getIndexed()); assertEquals(false, indexed.getCTColor().isSetRgb()); diff --git a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java index 3ccf5a337..a88ecf401 100644 --- a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java +++ b/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFFont.java @@ -323,7 +323,7 @@ public final class TestXSSFFont extends BaseTestFont{ Workbook wb = new XSSFWorkbook(); // cannot check on result because on some machines we get back false here! - SheetUtil.canComputeColumnWidth(wb.getFontAt((short)0)); + SheetUtil.canComputeColumnWidth(wb.getFontAt(0)); wb.close(); } @@ -354,16 +354,16 @@ public final class TestXSSFFont extends BaseTestFont{ assertEquals(1, wb.getNumberOfFonts()); - XSSFFont f1 = wb.getFontAt((short) 0); + XSSFFont f1 = wb.getFontAt(0); assertFalse(f1.getBold()); // Check that asking for the same font // multiple times gives you the same thing. // Otherwise, our tests wouldn't work! - assertSame(wb.getFontAt((short) 0), wb.getFontAt((short) 0)); + assertSame(wb.getFontAt(0), wb.getFontAt(0)); assertEquals( - wb.getFontAt((short) 0), - wb.getFontAt((short) 0) + wb.getFontAt(0), + wb.getFontAt(0) ); // Look for a new font we have @@ -384,8 +384,8 @@ public final class TestXSSFFont extends BaseTestFont{ XSSFFont nf = wb.createFont(); assertEquals(2, wb.getNumberOfFonts()); - assertEquals(1, nf.getIndex()); - assertEquals(nf, wb.getFontAt((short) 1)); + assertEquals(1, nf.getIndexAsInt()); + assertEquals(nf, wb.getFontAt(1)); nf.setBold(false); nf.setColor(IndexedColors.INDIGO.getIndex()); @@ -397,12 +397,12 @@ public final class TestXSSFFont extends BaseTestFont{ nf.setUnderline((byte) 2); assertEquals(2, wb.getNumberOfFonts()); - assertEquals(nf, wb.getFontAt((short) 1)); + assertEquals(nf, wb.getFontAt(1)); assertTrue( - wb.getFontAt((short) 0) + wb.getFontAt(0) != - wb.getFontAt((short) 1) + wb.getFontAt(1) ); // Find it now @@ -426,7 +426,7 @@ public final class TestXSSFFont extends BaseTestFont{ assertNotNull(font); assertEquals( 1, - font.getIndex() + font.getIndexAsInt() ); assertEquals(nf, wb.findFont(