From 1b4e8ba77ba7a09978370c3864c5b4436788981d Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Mon, 12 Dec 2022 18:14:49 +0000 Subject: [PATCH] remove unnecessary short casts for getCellStyleAt git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1905938 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/poi/examples/ss/html/ToHtml.java | 2 +- .../main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java | 2 +- .../java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java | 2 +- .../org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java | 2 +- .../test/java/org/apache/poi/hssf/usermodel/TestBugs.java | 6 +++--- .../test/java/org/apache/poi/ss/usermodel/BaseTestCell.java | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/poi-examples/src/main/java/org/apache/poi/examples/ss/html/ToHtml.java b/poi-examples/src/main/java/org/apache/poi/examples/ss/html/ToHtml.java index cf9eeaf5c0..004400c1ec 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/ss/html/ToHtml.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/ss/html/ToHtml.java @@ -320,7 +320,7 @@ public final class ToHtml { private String styleName(CellStyle style) { if (style == null) { - style = wb.getCellStyleAt((short) 0); + style = wb.getCellStyleAt(0); } StringBuilder sb = new StringBuilder(); try (Formatter fmt = new Formatter(sb, Locale.ROOT)) { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java index 081adc516a..7dec278354 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFSheet.java @@ -989,7 +989,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet, OoxmlSheetEx @Override public CellStyle getColumnStyle(int column) { int idx = columnHelper.getColDefaultStyle(column); - return getWorkbook().getCellStyleAt((short)(idx == -1 ? 0 : idx)); + return getWorkbook().getCellStyleAt(idx == -1 ? 0 : idx); } /** diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java index 8a2802f1b9..f700d98a93 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFBugs.java @@ -1094,7 +1094,7 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues { try (XSSFWorkbook wb = new XSSFWorkbook()) { XSSFSheet s = wb.createSheet(); - CellStyle defaultStyle = wb.getCellStyleAt((short) 0); + CellStyle defaultStyle = wb.getCellStyleAt(0); assertEquals(0, defaultStyle.getIndex()); CellStyle blueStyle = wb.createCellStyle(); diff --git a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java index b21ff6ec4a..9a48429f0b 100644 --- a/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java +++ b/poi-ooxml/src/test/java/org/apache/poi/xssf/usermodel/TestXSSFCellStyle.java @@ -597,7 +597,7 @@ class TestXSSFCellStyle { assertEquals(1, wb.getNumCellStyles()); assertEquals(2, styles.getFills().size()); - XSSFCellStyle defaultStyle = wb.getCellStyleAt((short)0); + XSSFCellStyle defaultStyle = wb.getCellStyleAt(0); assertEquals(IndexedColors.AUTOMATIC.getIndex(), defaultStyle.getFillForegroundColor()); assertNull(defaultStyle.getFillForegroundXSSFColor()); assertEquals(FillPatternType.NO_FILL, defaultStyle.getFillPattern()); diff --git a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestBugs.java b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestBugs.java index 4a11860161..c9cc7c748a 100644 --- a/poi/src/test/java/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/poi/src/test/java/org/apache/poi/hssf/usermodel/TestBugs.java @@ -1541,9 +1541,9 @@ final class TestBugs extends BaseTestBugzillaIssues { // Write out and read back try (HSSFWorkbook wb2 = writeOutAndReadBack(wb1)) { // Re-check - assertEquals("Testing", wb2.getCellStyleAt((short) 21).getUserStyleName()); - assertEquals("Testing 2", wb2.getCellStyleAt((short) 22).getUserStyleName()); - assertEquals("Testing 3", wb2.getCellStyleAt((short) 23).getUserStyleName()); + assertEquals("Testing", wb2.getCellStyleAt(21).getUserStyleName()); + assertEquals("Testing 2", wb2.getCellStyleAt(22).getUserStyleName()); + assertEquals("Testing 3", wb2.getCellStyleAt(23).getUserStyleName()); } } } diff --git a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java index 55f0343511..71cbfbb7e9 100644 --- a/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java +++ b/poi/src/test/java/org/apache/poi/ss/usermodel/BaseTestCell.java @@ -844,7 +844,7 @@ public abstract class BaseTestCell { Cell cell = row.createCell(0); // different default style indexes for HSSF and XSSF/SXSSF - CellStyle defaultStyle = wb.getCellStyleAt(wb instanceof HSSFWorkbook ? (short) 15 : (short) 0); + CellStyle defaultStyle = wb.getCellStyleAt(wb instanceof HSSFWorkbook ? 15 : 0); // Starts out with the default style assertEquals(defaultStyle, cell.getCellStyle());