diff options
author | Dominik Stadler <centic@apache.org> | 2022-03-20 08:20:00 +0000 |
---|---|---|
committer | Dominik Stadler <centic@apache.org> | 2022-03-20 08:20:00 +0000 |
commit | 9949242022730d5e6f12cfe9dce2001bc85c3212 (patch) | |
tree | 9a1dddd369ec31cc344ab36f861ee8915c7e0bcd | |
parent | 98fbe88d3a7edde2da4bc3694788f3fdfb57fe5b (diff) | |
download | poi-9949242022730d5e6f12cfe9dce2001bc85c3212.tar.gz poi-9949242022730d5e6f12cfe9dce2001bc85c3212.zip |
Remove unused imports, remove unnecessary boxing of int-value and apply some other IDE suggestions
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1899076 13f79535-47bb-0310-9956-ffa450edef68
8 files changed, 38 insertions, 46 deletions
diff --git a/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java b/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java index 30bbe4b264..563d7dce14 100644 --- a/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java +++ b/poi-integration/src/test/java/org/apache/poi/stress/TestAllFiles.java @@ -246,7 +246,8 @@ public class TestAllFiles { } } else { assertNotNull(actMsg, errPrefix); - assertTrue(actMsg.contains(exMessage), errPrefix + "Message: "+actMsg+" - didn't contain: "+exMessage); + assertTrue(actMsg.contains(exMessage), + errPrefix + "Message: " + actMsg + " - didn't contain: " + exMessage); } } else { assertDoesNotThrow(exec, errPrefix); diff --git a/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLProperties.java b/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLProperties.java index daa68d017b..14779374fe 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLProperties.java +++ b/poi-ooxml/src/main/java/org/apache/poi/ooxml/POIXMLProperties.java @@ -41,14 +41,14 @@ import org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProper /** * Wrapper around the three different kinds of OOXML properties - * and metadata a document can have (Core, Extended and Custom), + * and metadata a document can have (Core, Extended and Custom), * as well Thumbnails. */ public class POIXMLProperties { - private OPCPackage pkg; - private CoreProperties core; - private ExtendedProperties ext; - private CustomProperties cust; + private final OPCPackage pkg; + private final CoreProperties core; + private final ExtendedProperties ext; + private final CustomProperties cust; private PackagePart extPart; private PackagePart custPart; @@ -111,7 +111,7 @@ public class POIXMLProperties { /** * Returns the core document properties - * + * * @return the core document properties */ public CoreProperties getCoreProperties() { @@ -120,7 +120,7 @@ public class POIXMLProperties { /** * Returns the extended document properties - * + * * @return the extended document properties */ public ExtendedProperties getExtendedProperties() { @@ -129,7 +129,7 @@ public class POIXMLProperties { /** * Returns the custom document properties - * + * * @return the custom document properties */ public CustomProperties getCustomProperties() { @@ -151,7 +151,7 @@ public class POIXMLProperties { return null; } /** - * Returns the name of the Document thumbnail, eg + * Returns the name of the Document thumbnail, eg * <code>thumbnail.jpeg</code>, or <code>null</code> if there * isn't one. * @@ -167,7 +167,7 @@ public class POIXMLProperties { * Returns the Document thumbnail image data, or {@code null} if there isn't one. * * @return The thumbnail data, or null - * + * * @throws IOException if the thumbnail can't be read */ public InputStream getThumbnailImage() throws IOException { @@ -181,7 +181,7 @@ public class POIXMLProperties { * * @param filename The filename for the thumbnail image, eg {@code thumbnail.jpg} * @param imageData The inputstream to read the thumbnail image from - * + * * @throws IOException if the thumbnail can't be written */ public void setThumbnail(String filename, InputStream imageData) throws IOException { @@ -191,9 +191,9 @@ public class POIXMLProperties { pkg.addThumbnail(filename, imageData); } else { // Change existing - String newType = ContentTypes.getContentTypeFromFileExtension(filename); + String newType = ContentTypes.getContentTypeFromFileExtension(filename); if (! newType.equals(tPart.getContentType())) { - throw new IllegalArgumentException("Can't set a Thumbnail of type " + + throw new IllegalArgumentException("Can't set a Thumbnail of type " + newType + " when existing one is of a different type " + tPart.getContentType()); } @@ -203,7 +203,7 @@ public class POIXMLProperties { /** * Commit changes to the underlying OPC package - * + * * @throws IOException if the properties can't be saved * @throws POIXMLException if the properties are erroneous */ @@ -236,7 +236,7 @@ public class POIXMLProperties { } } if(custPart != null && cust != null && cust.props != null){ - /* bug #60977, when writing a file multiple times, + /* bug #60977, when writing a file multiple times, * and there are custom properties and an existing package part, * replace, don't append to raw document byte array */ @@ -251,7 +251,7 @@ public class POIXMLProperties { * The core document properties */ public static class CoreProperties { - private PackagePropertiesPart part; + private final PackagePropertiesPart part; private CoreProperties(PackagePropertiesPart part) { this.part = part; } @@ -365,7 +365,7 @@ public class POIXMLProperties { * Extended document properties */ public static class ExtendedProperties { - private org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument props; + private final org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument props; private ExtendedProperties(org.openxmlformats.schemas.officeDocument.x2006.extendedProperties.PropertiesDocument props) { this.props = props; } @@ -568,7 +568,7 @@ public class POIXMLProperties { */ public static final String FORMAT_ID = "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}"; - private org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props; + private final org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props; private Integer lastPid = null; private CustomProperties(org.openxmlformats.schemas.officeDocument.x2006.customProperties.PropertiesDocument props) { @@ -601,7 +601,7 @@ public class POIXMLProperties { /** * Add a new string property - * + * * @param name the property name * @param value the property value * @@ -693,11 +693,11 @@ public class POIXMLProperties { * Retrieve the custom property with this name, or null if none exists. * * You will need to test the various isSetX methods to work out - * what the type of the property is, before fetching the + * what the type of the property is, before fetching the * appropriate value for it. * * @param name the name of the property to fetch - * + * * @return the custom property with this name, or null if none exists */ public CTProperty getProperty(String name) { diff --git a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java index 47542bd46c..efdc7f057c 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xslf/usermodel/XMLSlideShow.java @@ -248,7 +248,6 @@ public class XMLSlideShow extends POIXMLDocument CTSlideIdList slideList = _presentation.isSetSldIdLst() ? _presentation.getSldIdLst() : _presentation.addNewSldIdLst(); - @SuppressWarnings("deprecation") OptionalLong maxId = Stream.of(slideList.getSldIdArray()) .mapToLong(CTSlideIdListEntry::getId).max(); @@ -454,7 +453,6 @@ public class XMLSlideShow extends POIXMLDocument // fix ordering in the low-level xml CTSlideIdList sldIdLst = _presentation.getSldIdLst(); - @SuppressWarnings("deprecation") CTSlideIdListEntry[] entries = sldIdLst.getSldIdArray(); CTSlideIdListEntry oldEntry = entries[oldIndex]; if (oldIndex < newIndex) { diff --git a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToConverterSuite.java b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToConverterSuite.java index 0df1b84f6b..a809fa7d5e 100644 --- a/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToConverterSuite.java +++ b/poi-scratchpad/src/test/java/org/apache/poi/hwpf/converter/TestWordToConverterSuite.java @@ -21,11 +21,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.File; import java.io.FilenameFilter; import java.io.StringWriter; -import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; import java.util.stream.Stream; import javax.xml.transform.OutputKeys; diff --git a/poi/src/main/java/org/apache/poi/hssf/model/InternalSheet.java b/poi/src/main/java/org/apache/poi/hssf/model/InternalSheet.java index 37e7595a53..e580fd86ac 100644 --- a/poi/src/main/java/org/apache/poi/hssf/model/InternalSheet.java +++ b/poi/src/main/java/org/apache/poi/hssf/model/InternalSheet.java @@ -70,7 +70,7 @@ public final class InternalSheet { private static final Logger LOGGER = LogManager.getLogger(InternalSheet.class); - private List<RecordBase> _records; + private final List<RecordBase> _records; protected PrintGridlinesRecord printGridlines; protected PrintHeadersRecord printHeaders; protected GridsetRecord gridset; @@ -336,7 +336,7 @@ public final class InternalSheet { LOGGER.atDebug().log("sheet createSheet (existing file) exited"); } private static void spillAggregate(RecordAggregate ra, final List<RecordBase> recs) { - ra.visitContainedRecords(r -> recs.add(r)); + ra.visitContainedRecords(recs::add); } public static class UnsupportedBOFType extends RecordFormatException { @@ -375,14 +375,13 @@ public final class InternalSheet { */ public InternalSheet cloneSheet() { List<Record> clonedRecords = new ArrayList<>(_records.size()); - for (int i = 0; i < _records.size(); i++) { - RecordBase rb = _records.get(i); + for (RecordBase rb : _records) { if (rb instanceof RecordAggregate) { ((RecordAggregate) rb).visitContainedRecords(new RecordCloner(clonedRecords)); continue; } - if (rb instanceof EscherAggregate){ - /** + if (rb instanceof EscherAggregate) { + /* * this record will be removed after reading actual data from EscherAggregate */ rb = new DrawingRecord(); @@ -1047,7 +1046,7 @@ public final class InternalSheet { public void setColumnWidth(int column, int width) { if(width > 255*256) throw new IllegalArgumentException("The maximum column width for an individual cell is 255 characters."); - setColumn(column, null, Integer.valueOf(width), null, null, null); + setColumn(column, null, width, null, null, null); } /** @@ -1072,10 +1071,10 @@ public final class InternalSheet { * @param hidden - whether the column is hidden or not */ public void setColumnHidden(int column, boolean hidden) { - setColumn( column, null, null, null, Boolean.valueOf(hidden), null); + setColumn( column, null, null, null, hidden, null); } public void setDefaultColumnStyle(int column, int styleIndex) { - setColumn(column, Short.valueOf((short)styleIndex), null, null, null, null); + setColumn(column, (short) styleIndex, null, null, null, null); } private void setColumn(int column, Short xfStyle, Integer width, Integer level, Boolean hidden, Boolean collapsed) { diff --git a/poi/src/main/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java b/poi/src/main/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java index eb2cd212a3..deeeff34bb 100644 --- a/poi/src/main/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java +++ b/poi/src/main/java/org/apache/poi/hssf/record/aggregates/RowRecordsAggregate.java @@ -113,6 +113,7 @@ public final class RowRecordsAggregate extends RecordAggregate { _valuesAgg.construct((CellValueRecordInterface)rec, rs, svm); } } + /** * Handles UnknownRecords which appear within the row/cell records */ @@ -128,7 +129,7 @@ public final class RowRecordsAggregate extends RecordAggregate { } public void insertRow(RowRecord row) { // Integer integer = Integer.valueOf(row.getRowNumber()); - _rowRecords.put(Integer.valueOf(row.getRowNumber()), row); + _rowRecords.put(row.getRowNumber(), row); // Clear the cached values _rowRecordValues = null; if ((row.getRowNumber() < _firstrow) || (_firstrow == -1)) { @@ -142,13 +143,12 @@ public final class RowRecordsAggregate extends RecordAggregate { public void removeRow(RowRecord row) { int rowIndex = row.getRowNumber(); _valuesAgg.removeAllCellsValuesForRow(rowIndex); - Integer key = Integer.valueOf(rowIndex); - RowRecord rr = _rowRecords.remove(key); + RowRecord rr = _rowRecords.remove(rowIndex); if (rr == null) { throw new RuntimeException("Invalid row index (" + key.intValue() + ")"); } if (row != rr) { - _rowRecords.put(key, rr); + _rowRecords.put(rowIndex, rr); throw new RuntimeException("Attempt to remove row that does not belong to this sheet"); } @@ -161,7 +161,7 @@ public final class RowRecordsAggregate extends RecordAggregate { if (rowIndex < 0 || rowIndex > maxrow) { throw new IllegalArgumentException("The row number must be between 0 and " + maxrow + ", but had: " + rowIndex); } - return _rowRecords.get(Integer.valueOf(rowIndex)); + return _rowRecords.get(rowIndex); } public int getPhysicalNumberOfRows() diff --git a/poi/src/main/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java b/poi/src/main/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java index 559045f522..8bb572e312 100644 --- a/poi/src/main/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java +++ b/poi/src/main/java/org/apache/poi/poifs/filesystem/POIFSFileSystem.java @@ -454,7 +454,7 @@ public class POIFSFileSystem extends BlockStore // Ensure there's a spot in the file for it ByteBuffer buffer = ByteBuffer.allocate(bigBlockSize.getBigBlockSize()); // Header isn't in BATs - long writeTo = Math.multiplyExact(1L + offset, (long)bigBlockSize.getBigBlockSize()); + long writeTo = Math.multiplyExact(1L + offset, bigBlockSize.getBigBlockSize()); _data.write(buffer, writeTo); // All done return newBAT; diff --git a/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java b/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java index a383fc331d..618200ec65 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/OperationEvaluationContext.java @@ -44,8 +44,6 @@ import org.apache.poi.ss.util.CellReference; import org.apache.poi.ss.util.CellReference.NameType; import org.apache.poi.util.LocaleUtil; -import java.util.Locale; - /** * Contains all the contextual information required to evaluate an operation * within a formula @@ -210,8 +208,7 @@ public final class OperationEvaluationContext { * @param isA1Style specifies the format for {@code refStrPart1} and {@code refStrPart2}. * Pass {@code true} for 'A1' style and {@code false} for 'R1C1' style. * @return a {@link RefEval} or {@link AreaEval} - * @throws IllegalArgumentException - * @throws IllegalStateException + * @throws RuntimeException If invalid parameters are provided */ public ValueEval getDynamicReference(String workbookName, String sheetName, String refStrPart1, String refStrPart2, boolean isA1Style) { |