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
This commit is contained in:
Dominik Stadler 2022-03-20 08:20:00 +00:00
parent 98fbe88d3a
commit 9949242022
8 changed files with 38 additions and 46 deletions

View File

@ -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);

View File

@ -45,10 +45,10 @@ import org.openxmlformats.schemas.officeDocument.x2006.customProperties.CTProper
* 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;
@ -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) {

View File

@ -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) {

View File

@ -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;

View File

@ -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) {

View File

@ -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()

View File

@ -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;

View File

@ -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) {