From d942e2042d46fe61c6cde20564e187a00c77ef06 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Sun, 30 Dec 2018 10:07:42 +0000 Subject: [PATCH] IDE and JavaDoc fixes, make base test classes abstract git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1849968 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/xssf/model/StylesTable.java | 9 ++++--- .../apache/poi/xssf/usermodel/XSSFColor.java | 12 ++++++--- .../apache/poi/xssf/usermodel/XSSFFont.java | 1 + .../usermodel/extensions/XSSFCellBorder.java | 26 +++++++++---------- .../usermodel/extensions/XSSFCellFill.java | 6 ++--- .../poi/ss/usermodel/BaseTestBorderStyle.java | 2 +- .../apache/poi/ss/util/BaseTestCellUtil.java | 14 +++++----- 7 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java index 843873e114..2c89c2fae3 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/StylesTable.java @@ -184,6 +184,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles { * @param is The input stream containing the XML document. * @throws IOException if an error occurs while reading. */ + @SuppressWarnings("deprecation") public void readFrom(InputStream is) throws IOException { try { doc = StyleSheetDocument.Factory.parse(is, DEFAULT_XML_OPTIONS); @@ -240,7 +241,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles { CTTableStyles ctTableStyles = styleSheet.getTableStyles(); if (ctTableStyles != null) { int idx = 0; - for (CTTableStyle style : Arrays.asList(ctTableStyles.getTableStyleArray())) { + for (CTTableStyle style : ctTableStyles.getTableStyleArray()) { tableStyles.put(style.getName(), new XSSFTableStyle(idx, styleDxfs, style, indexedColors)); idx++; } @@ -670,7 +671,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles { } ctXfs.setCount(xfs.size()); ctXfs.setXfArray( - xfs.toArray(new CTXf[xfs.size()]) + xfs.toArray(new CTXf[0]) ); styleSheet.setCellXfs(ctXfs); } @@ -683,7 +684,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles { } ctSXfs.setCount(styleXfs.size()); ctSXfs.setXfArray( - styleXfs.toArray(new CTXf[styleXfs.size()]) + styleXfs.toArray(new CTXf[0]) ); styleSheet.setCellStyleXfs(ctSXfs); } @@ -695,7 +696,7 @@ public class StylesTable extends POIXMLDocumentPart implements Styles { ctDxfs = CTDxfs.Factory.newInstance(); } ctDxfs.setCount(dxfs.size()); - ctDxfs.setDxfArray(dxfs.toArray(new CTDxf[dxfs.size()])); + ctDxfs.setDxfArray(dxfs.toArray(new CTDxf[0])); styleSheet.setDxfs(ctDxfs); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java index be632b3c46..504a302955 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFColor.java @@ -33,11 +33,12 @@ public class XSSFColor extends ExtendedColor { private final IndexedColorMap indexedColorMap; /** - * @param color - * @param map + * @param color The ooxml color object to use + * @param map The IndexedColorMap to use instead of the default one * @return null if color is null, new instance otherwise */ public static XSSFColor from(CTColor color, IndexedColorMap map) { + //noinspection deprecation return color == null ? null : new XSSFColor(color, map); } @@ -80,9 +81,10 @@ public class XSSFColor extends ExtendedColor { /** * new color with the given indexed color map - * @param colorMap + * @param colorMap The IndexedColorMap to use instead of the default one */ public XSSFColor(IndexedColorMap colorMap) { + //noinspection deprecation this(CTColor.Factory.newInstance(), colorMap); } @@ -100,7 +102,7 @@ public class XSSFColor extends ExtendedColor { /** * TEST ONLY * @param clr awt Color - * @param map + * @param map The IndexedColorMap to use instead of the default one */ public XSSFColor(java.awt.Color clr, IndexedColorMap map) { this(map); @@ -113,6 +115,7 @@ public class XSSFColor extends ExtendedColor { * @param colorMap The IndexedColorMap to use instead of the default one */ public XSSFColor(byte[] rgb, IndexedColorMap colorMap) { + //noinspection deprecation this(CTColor.Factory.newInstance(), colorMap); ctColor.setRgb(rgb); } @@ -122,6 +125,7 @@ public class XSSFColor extends ExtendedColor { * @param colorMap The IndexedColorMap to use instead of the default one */ public XSSFColor(IndexedColors indexedColor, IndexedColorMap colorMap) { + //noinspection deprecation this(CTColor.Factory.newInstance(), colorMap); ctColor.setIndexed(indexedColor.index); } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java index 123200c2ba..3933215ae8 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java @@ -562,6 +562,7 @@ public class XSSFFont implements Font { * @return FontScheme * @see org.apache.poi.xssf.model.StylesTable#createDefaultFont() */ + @SuppressWarnings("JavadocReference") public FontScheme getScheme() { CTFontScheme scheme = _ctFont.sizeOfSchemeArray() == 0 ? null : _ctFont.getSchemeArray(0); return scheme == null ? FontScheme.NONE : FontScheme.valueOf(scheme.getVal().intValue()); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java index a602888c1a..54afd1cd22 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellBorder.java @@ -32,37 +32,37 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle; * Color is optional. */ public class XSSFCellBorder { - private IndexedColorMap _indexedColorMap; + private final IndexedColorMap _indexedColorMap; private ThemesTable _theme; - private CTBorder border; + private final CTBorder border; /** * Creates a Cell Border from the supplied XML definition - * @param border - * @param theme - * @param colorMap + * @param border The ooxml object for the border + * @param theme The related themes + * @param colorMap The global map of colors */ public XSSFCellBorder(CTBorder border, ThemesTable theme, IndexedColorMap colorMap) { - this(border, colorMap); + this.border = border; + this._indexedColorMap = colorMap; this._theme = theme; } /** * Creates a Cell Border from the supplied XML definition - * @param border + * @param border The ooxml object for the border */ public XSSFCellBorder(CTBorder border) { - this(border, null); + this(border, null, null); } /** * - * @param border - * @param colorMap + * @param border The ooxml object for the border + * @param colorMap The global map of colors */ public XSSFCellBorder(CTBorder border, IndexedColorMap colorMap) { - this.border = border; - this._indexedColorMap = colorMap; + this(border, null, colorMap); } /** @@ -70,7 +70,7 @@ public class XSSFCellBorder { * You need to attach this to the Styles Table */ public XSSFCellBorder() { - border = CTBorder.Factory.newInstance(); + this(CTBorder.Factory.newInstance(), null, null); } /** diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java index d460490511..e619065b2f 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFCellFill.java @@ -66,7 +66,7 @@ public final class XSSFCellFill { /** * Set the background fill color represented as a indexed color value. * - * @param index + * @param index - the color to use */ public void setFillBackgroundColor(int index) { CTPatternFill ptrn = ensureCTPatternFill(); @@ -77,7 +77,7 @@ public final class XSSFCellFill { /** * Set the background fill color represented as a {@link XSSFColor} value. * - * @param color + * @param color - background color. null if color should be unset */ public void setFillBackgroundColor(XSSFColor color) { CTPatternFill ptrn = ensureCTPatternFill(); @@ -161,7 +161,7 @@ public final class XSSFCellFill { */ @Internal public CTFill getCTFill() { - return _fill; + return _fill; } diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java index 5ea2280b2a..4a7c3e1784 100644 --- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java +++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBorderStyle.java @@ -31,7 +31,7 @@ import org.junit.Test; /** * Tests of {@link BorderStyle} */ -public class BaseTestBorderStyle { +public abstract class BaseTestBorderStyle { private final ITestDataProvider _testDataProvider; diff --git a/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java b/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java index c4bb0fc88f..fc507c90e0 100644 --- a/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java +++ b/src/testcases/org/apache/poi/ss/util/BaseTestCellUtil.java @@ -46,7 +46,7 @@ import org.junit.Test; * * @see org.apache.poi.ss.util.CellUtil */ -public class BaseTestCellUtil { +public abstract class BaseTestCellUtil { protected final ITestDataProvider _testDataProvider; protected BaseTestCellUtil(ITestDataProvider testDataProvider) { @@ -302,10 +302,10 @@ public class BaseTestCellUtil { Row row = sh.createRow(0); Cell A1 = row.createCell(0); Cell B1 = row.createCell(1); - final short defaultFontIndex = 0; + final int defaultFontIndex = 0; Font font = wb.createFont(); font.setItalic(true); - final short customFontIndex = font.getIndex(); + final int customFontIndex = font.getIndexAsInt(); // Assumptions assertNotEquals(defaultFontIndex, customFontIndex); @@ -313,17 +313,17 @@ public class BaseTestCellUtil { // should be assertSame, but a new HSSFCellStyle is returned for each getCellStyle() call. // HSSFCellStyle wraps an underlying style record, and the underlying // style record is the same between multiple getCellStyle() calls. - assertEquals(defaultFontIndex, A1.getCellStyle().getFontIndex()); - assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndex()); + assertEquals(defaultFontIndex, A1.getCellStyle().getFontIndexAsInt()); + assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndexAsInt()); // get/set alignment modifies the cell's style CellUtil.setFont(A1, font); - assertEquals(customFontIndex, A1.getCellStyle().getFontIndex()); + assertEquals(customFontIndex, A1.getCellStyle().getFontIndexAsInt()); // get/set alignment doesn't affect the style of cells with // the same style prior to modifying the style assertNotEquals(A1.getCellStyle(), B1.getCellStyle()); - assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndex()); + assertEquals(defaultFontIndex, B1.getCellStyle().getFontIndexAsInt()); wb.close(); } -- 2.39.5