From: Dominik Stadler Date: Fri, 1 Jan 2021 15:51:30 +0000 (+0000) Subject: Apply some IDE suggestions and fix some JavaDoc X-Git-Tag: REL_5_0_0~55 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8347bb64ac06f8aeb7711d106e663a5a2587cc0d;p=poi.git Apply some IDE suggestions and fix some JavaDoc git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1885012 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/ss/formula/BaseFormulaEvaluator.java b/src/java/org/apache/poi/ss/formula/BaseFormulaEvaluator.java index f9ec1e839d..fa9989c02b 100644 --- a/src/java/org/apache/poi/ss/formula/BaseFormulaEvaluator.java +++ b/src/java/org/apache/poi/ss/formula/BaseFormulaEvaluator.java @@ -70,7 +70,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook protected EvaluationWorkbook getEvaluationWorkbook() { return _bookEvaluator.getWorkbook(); } - + /** * Should be called whenever there are major changes (e.g. moving sheets) to input cells * in the evaluated workbook. If performance is not critical, a single call to this method @@ -117,7 +117,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")"); } } - + /** * If cell contains formula, it evaluates the formula, and * puts the formula result back into the cell, in place @@ -188,9 +188,11 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook } /** - * set the cell type - * @param cell - * @param cv + * Set the cell type based on the computed cell type as + * part of a formula evaluation. + * + * @param cell The Cell to populate + * @param cv The CellValue to read the result type from */ protected void setCellType(Cell cell, CellValue cv) { CellType cellType = cv.getCellType(); @@ -214,15 +216,17 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook /** * Override if a different variation is needed, e.g. passing the evaluator to the cell method - * @param cell - * @param cellType + * + * @param cell The Cell to populate + * @param cellType The wanted type for this Cell */ protected void setCellType(Cell cell, CellType cellType) { + //noinspection deprecation cell.setCellType(cellType); } - + protected abstract RichTextString createRichTextString(String str); - + protected void setCellValue(Cell cell, CellValue cv) { CellType cellType = cv.getCellType(); switch (cellType) { @@ -246,7 +250,7 @@ public abstract class BaseFormulaEvaluator implements FormulaEvaluator, Workbook throw new IllegalStateException("Unexpected cell value type (" + cellType + ")"); } } - + /** * Loops over all cells in all sheets of the supplied diff --git a/src/java/org/apache/poi/ss/util/SheetUtil.java b/src/java/org/apache/poi/ss/util/SheetUtil.java index d26e2c2a26..06d3aa1f70 100644 --- a/src/java/org/apache/poi/ss/util/SheetUtil.java +++ b/src/java/org/apache/poi/ss/util/SheetUtil.java @@ -39,7 +39,6 @@ import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.util.Internal; -import org.apache.poi.util.Removal; /** diff --git a/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocument.java b/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocument.java index 75895b7edb..216ff803e6 100644 --- a/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocument.java +++ b/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocument.java @@ -60,15 +60,15 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close super(pkg); init(pkg); } - + protected POIXMLDocument(OPCPackage pkg, String coreDocumentRel) { super(pkg, coreDocumentRel); init(pkg); } - + private void init(OPCPackage p) { this.pkg = p; - + // Workaround for XMLBEANS-512 - ensure that when we parse // the file, we start with a fresh XML Parser each time, // and avoid the risk of getting a SaxHandler that's in error @@ -77,10 +77,10 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close /** * Wrapper to open a package, which works around shortcomings in java's this() constructor calls - * + * * @param path the path to the document * @return the new OPCPackage - * + * * @exception IOException if there was a problem opening the document */ public static OPCPackage openPackage(String path) throws IOException { @@ -107,13 +107,13 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close /** * Retrieves all the PackageParts which are defined as relationships of the base document with the * specified content type. - * + * * @param contentType the content type - * + * * @return all the base document PackageParts which match the content type - * + * * @throws InvalidFormatException when the relationships or the parts contain errors - * + * * @see org.apache.poi.xssf.usermodel.XSSFRelation * @see org.apache.poi.xslf.usermodel.XSLFRelation * @see org.apache.poi.xwpf.usermodel.XWPFRelation @@ -135,7 +135,7 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close /** * Get the document properties. This gives you access to the * core ooxml properties, and the extended ooxml properties. - * + * * @return the document properties */ public POIXMLProperties getProperties() { @@ -169,7 +169,7 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close onDocumentRead(); context.clear(); } - + /** * Closes the underlying {@link OPCPackage} from which this * document was read, if there is one @@ -193,17 +193,17 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close } /** - * Write out this document to an Outputstream. + * Write out this document to an {@link OutputStream}. * * Note - if the Document was opened from a {@link File} rather * than an {@link InputStream}, you must write out to * a different file, overwriting via an OutputStream isn't possible. - * + * * If {@code stream} is a {@link java.io.FileOutputStream} on a networked drive * or has a high cost/latency associated with each written byte, * consider wrapping the OutputStream in a {@link java.io.BufferedOutputStream} * to improve write performance. - * + * * @param stream - the java OutputStream you wish to write the file to * * @exception IOException if anything can't be written. @@ -214,7 +214,7 @@ public abstract class POIXMLDocument extends POIXMLDocumentPart implements Close if(p == null) { throw new IOException("Cannot write data, document seems to have been closed already"); } - + //force all children to commit their changes into the underlying OOXML Package // TODO Shouldn't they be committing to the new one instead? Set context = new HashSet<>(); diff --git a/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java b/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java index 1f90ae842f..49add44ceb 100644 --- a/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java +++ b/src/ooxml/java/org/apache/poi/ooxml/POIXMLDocumentPart.java @@ -57,7 +57,7 @@ public class POIXMLDocumentPart { private String coreDocumentRel = PackageRelationshipTypes.CORE_DOCUMENT; private PackagePart packagePart; private POIXMLDocumentPart parent; - private Map relations = new LinkedHashMap<>(); + private final Map relations = new LinkedHashMap<>(); private boolean isCommitted = false; /** @@ -361,7 +361,7 @@ public class POIXMLDocumentPart { *

* If there are multiple relationships to the same part, this will only * remove the first relationship in the order of creation. The removal - * via the part id ({@link #removeRelation(String)} is preferred. + * via the part id ({@link #removeRelation(POIXMLDocumentPart)} is preferred. * * @param partId the part id which relation is to be removed from this document * @since 4.0.0 @@ -380,7 +380,7 @@ public class POIXMLDocumentPart { * @return true, if the relation was removed * @since 4.0.0 */ - private final boolean removeRelation(String partId, boolean removeUnusedParts) { + private boolean removeRelation(String partId, boolean removeUnusedParts) { RelationPart rp = relations.get(partId); if (rp == null) { // part is not related with this POIXMLDocumentPart diff --git a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java index f93320084b..b65996b53d 100644 --- a/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java +++ b/src/ooxml/java/org/apache/poi/openxml4j/opc/ZipPackage.java @@ -379,7 +379,7 @@ public final class ZipPackage extends OPCPackage { * Delete a part from the package * * @throws IllegalArgumentException - * Throws if the part URI is nulll or invalid. + * Throws if the part URI is null or invalid. */ @Override protected void removePartImpl(PackagePartName partName) { diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java index 017056debb..ccd1799955 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java @@ -32,7 +32,7 @@ import org.apache.poi.ss.usermodel.Cell; * calls to evaluate~ methods on this class. */ public final class XSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator { - private XSSFWorkbook _book; + private final XSSFWorkbook _book; public XSSFFormulaEvaluator(XSSFWorkbook workbook) { this(workbook, null, null); @@ -79,12 +79,12 @@ public final class XSSFFormulaEvaluator extends BaseXSSFFormulaEvaluator { public static void evaluateAllFormulaCells(XSSFWorkbook wb) { BaseFormulaEvaluator.evaluateAllFormulaCells(wb); } - + @Override public XSSFCell evaluateInCell(Cell cell) { return (XSSFCell) super.evaluateInCell(cell); } - + /** * Loops over all cells in all sheets of the supplied * workbook. diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index 5f60b7fa62..f60c8a9d84 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -172,7 +172,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su * The locator of user-defined functions. * By default includes functions from the Excel Analysis Toolpack */ - private IndexedUDFFinder _udfFinder = new IndexedUDFFinder(AggregatingUDFFinder.DEFAULT); + private final IndexedUDFFinder _udfFinder = new IndexedUDFFinder(AggregatingUDFFinder.DEFAULT); /** * TODO @@ -214,7 +214,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su */ private List pictures; - private static POILogger logger = POILogFactory.getLogger(XSSFWorkbook.class); + private static final POILogger logger = POILogFactory.getLogger(XSSFWorkbook.class); /** * cached instance of XSSFCreationHelper for this workbook @@ -404,7 +404,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su // Load individual sheets. The order of sheets is defined by the order // of CTSheet elements in the workbook sheets = new ArrayList<>(shIdMap.size()); - //noinspection deprecation for (CTSheet ctSheet : this.workbook.getSheets().getSheetArray()) { parseSheet(shIdMap, ctSheet); } @@ -1604,7 +1603,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su newcts.set(cts); //notify sheets - //noinspection deprecation CTSheet[] sheetArray = ct.getSheetArray(); for(int i=0; i < sheetArray.length; i++) { sheets.get(i).sheet = sheetArray[i]; @@ -1773,7 +1771,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su * @return true if the sheet contains the name, false otherwise. */ private boolean containsSheet(String name, int excludeSheetIdx) { - //noinspection deprecation CTSheet[] ctSheetArray = workbook.getSheets().getSheetArray(); if (name.length() > MAX_SENSITIVE_SHEET_NAME_LEN) {