diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/model/ExternalLinksTable.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/model/ExternalLinksTable.java index b267123e48..db970d3e9f 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/model/ExternalLinksTable.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/model/ExternalLinksTable.java @@ -144,18 +144,21 @@ public class ExternalLinksTable extends POIXMLDocumentPart { protected class ExternalName implements Name { - private CTExternalDefinedName name; + private final CTExternalDefinedName name; protected ExternalName(CTExternalDefinedName name) { this.name = name; } + @Override public String getNameName() { return name.getName(); } + @Override public void setNameName(String name) { this.name.setName(name); } + @Override public String getSheetName() { int sheetId = getSheetIndex(); if (sheetId >= 0) { @@ -164,29 +167,35 @@ public class ExternalLinksTable extends POIXMLDocumentPart { return null; } } + @Override public int getSheetIndex() { if (name.isSetSheetId()) { return (int)name.getSheetId(); } return -1; } + @Override public void setSheetIndex(int sheetId) { name.setSheetId(sheetId); } + @Override public String getRefersToFormula() { // Return, without the leading = return name.getRefersTo().substring(1); } + @Override public void setRefersToFormula(String formulaText) { // Save with leading = name.setRefersTo('=' + formulaText); } + @Override public boolean isFunctionName() { return false; } + @Override public boolean isDeleted() { return false; } @@ -196,12 +205,15 @@ public class ExternalLinksTable extends POIXMLDocumentPart { return false; } + @Override public String getComment() { return null; } + @Override public void setComment(String comment) { throw new IllegalStateException("Not Supported"); } + @Override public void setFunction(boolean value) { throw new IllegalStateException("Not Supported"); } diff --git a/poi/src/main/java/org/apache/poi/hssf/record/SSTRecord.java b/poi/src/main/java/org/apache/poi/hssf/record/SSTRecord.java index ad1b3ae903..75d973aa25 100644 --- a/poi/src/main/java/org/apache/poi/hssf/record/SSTRecord.java +++ b/poi/src/main/java/org/apache/poi/hssf/record/SSTRecord.java @@ -49,9 +49,9 @@ public final class SSTRecord extends ContinuableRecord { * according to docs ONLY SST */ private int field_2_num_unique_strings; - private IntMapper field_3_strings; + private final IntMapper field_3_strings; - private SSTDeserializer deserializer; + private final SSTDeserializer deserializer; /** * Offsets from the beginning of the SST record (even across continuations) @@ -134,6 +134,7 @@ public final class SSTRecord extends ContinuableRecord { return field_3_strings.get( id ); } + @Override public short getSid() { return sid; } @@ -143,8 +144,7 @@ public final class SSTRecord extends ContinuableRecord { *

* The data consists of sets of string data. This string data is * arranged as follows: - *

- *
+     * 
{@code
      * short  string_length;   // length of string data
      * byte   string_flag;     // flag specifying special string
      *                         // handling
@@ -157,12 +157,11 @@ public final class SSTRecord extends ContinuableRecord {
      *                         // array is run_count)
      * byte[] extension;       // optional extension (length of array
      *                         // is extend_length)
-     * 
+ * }
*

* The string_flag is bit mapped as follows: - *

- *

- * + *
+ * * * * @@ -252,6 +251,7 @@ public final class SSTRecord extends ContinuableRecord { return field_3_strings.size(); } + @Override protected void serialize(ContinuableRecordOutput out) { SSTSerializer serializer = new SSTSerializer(field_3_strings, getNumStrings(), getNumUniqueStrings() ); serializer.serialize(out); @@ -313,7 +313,7 @@ public final class SSTRecord extends ContinuableRecord { return GenericRecordUtil.getGenericProperties( "numStrings", this::getNumStrings, "numUniqueStrings", this::getNumUniqueStrings, - "strings", () -> field_3_strings.getElements(), + "strings", field_3_strings::getElements, "bucketAbsoluteOffsets", () -> bucketAbsoluteOffsets, "bucketRelativeOffsets", () -> bucketRelativeOffsets ); diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java index b0fa3e28f7..6220a64d3a 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFEvaluationWorkbook.java @@ -67,7 +67,7 @@ public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E public void clearAllCachedResultValues() { // nothing to do } - + @Override public HSSFName createName() { return _uBook.createName(); @@ -82,7 +82,7 @@ public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E public int getExternalSheetIndex(String workbookName, String sheetName) { return _iBook.getExternalSheetIndex(workbookName, sheetName); } - + @Override public Ptg get3DReferencePtg(CellReference cr, SheetIdentifier sheet) { int extIx = getSheetExtIx(sheet); @@ -107,7 +107,7 @@ public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E * * @param name the name to search * @param sheetIndex the 0-based index of the sheet this formula belongs to. - * The sheet index is required to resolve sheet-level names. -1 means workbook-global names + * The sheet index is required to resolve sheet-level names. {@code -1} means workbook-global names */ @Override public EvaluationName getName(String name, int sheetIndex) { @@ -160,10 +160,10 @@ public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E // Not actually sheet based at all - is workbook scoped return null; } - + // Look up the local sheet String sheetName = getSheetName(localSheetIndex); - + // Is it a single local sheet, or a range? int lastLocalSheetIndex = _iBook.getLastSheetIndexFromExternSheetIndex(externSheetIndex); if (lastLocalSheetIndex == localSheetIndex) { @@ -177,7 +177,7 @@ public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E } /** - * @throws IllegalStateException: XSSF-style external references are not supported for HSSF + * @throws IllegalStateException XSSF-style external references are not supported for HSSF */ @Override public ExternalSheet getExternalSheet(String firstSheetName, String lastSheetName, int externalWorkbookNumber) { @@ -190,7 +190,7 @@ public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E } /** - * @throws IllegalStateException: XSSF-style external names are not supported for HSSF + * @throws IllegalStateException XSSF-style external names are not supported for HSSF */ @Override public ExternalName getExternalName(String nameName, String sheetName, int externalWorkbookNumber) { @@ -275,14 +275,14 @@ public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E if (sheetIden == null) { extIx = -1; } else { - String workbookName = sheetIden.getBookName(); + String workbookName = sheetIden.getBookName(); String firstSheetName = sheetIden.getSheetIdentifier().getName(); String lastSheetName = firstSheetName; - + if (sheetIden instanceof SheetRangeIdentifier) { lastSheetName = ((SheetRangeIdentifier)sheetIden).getLastSheetIdentifier().getName(); } - + if (workbookName == null) { int firstSheetIndex = _uBook.getSheetIndex(firstSheetName); int lastSheetIndex = _uBook.getSheetIndex(lastSheetName); @@ -300,7 +300,7 @@ public final class HSSFEvaluationWorkbook implements FormulaRenderingWorkbook, E } /** - * @throws IllegalStateException: data tables are not supported in Excel 97-2003 format + * @throws IllegalStateException data tables are not supported in Excel 97-2003 format */ @Override public Table getTable(String name) { diff --git a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFName.java b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFName.java index c805c573e9..75d8c0a303 100644 --- a/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFName.java +++ b/poi/src/main/java/org/apache/poi/hssf/usermodel/HSSFName.java @@ -32,12 +32,12 @@ import org.apache.poi.ss.util.CellReference; * 'named range' or name of a user defined function. */ public final class HSSFName implements Name { - - private HSSFWorkbook _book; - private NameRecord _definedNameRec; - private NameCommentRecord _commentRec; - /** + private final HSSFWorkbook _book; + private final NameRecord _definedNameRec; + private final NameCommentRecord _commentRec; + + /** * Creates new HSSFName - called by HSSFWorkbook to create a name from * scratch. * @@ -48,7 +48,7 @@ public final class HSSFName implements Name { /* package */ HSSFName(HSSFWorkbook book, NameRecord name) { this(book, name, null); } - /** + /** * Creates new HSSFName - called by HSSFWorkbook to create a name from * scratch. * @@ -66,6 +66,7 @@ public final class HSSFName implements Name { /** Get the sheets name which this named range is referenced to * @return sheet name, which this named range referred to */ + @Override public String getSheetName() { int indexToExternSheet = _definedNameRec.getExternSheetNumber(); @@ -75,6 +76,7 @@ public final class HSSFName implements Name { /** * @return text name of this defined name */ + @Override public String getNameName(){ return _definedNameRec.getNameText(); } @@ -104,7 +106,7 @@ public final class HSSFName implements Name { *

* A name must always be unique within its scope. POI prevents you from defining a name that is not unique * within its scope. However you can use the same name in different scopes. Example: - *

+ *
{@code
      * //by default names are workbook-global
      * HSSFName name;
      * name = workbook.createName();
@@ -122,12 +124,12 @@ public final class HSSFName implements Name {
      * name.setSheetIndex(0);
      * name.setNameName("sales_08");  //will throw an exception: "The sheet already contains this name (case-insensitive)"
      *
-     * 
- *

+ * } * * @param nameName named range name to set * @throws IllegalArgumentException if the name is invalid or the name already exists (case-insensitive) */ + @Override public void setNameName(String nameName){ validateName(nameName); @@ -149,7 +151,7 @@ public final class HSSFName implements Name { } } } - + // Update our comment, if there is one if(_commentRec != null) { _commentRec.setNameText(nameName); @@ -159,21 +161,21 @@ public final class HSSFName implements Name { /** * https://support.office.com/en-us/article/Define-and-use-names-in-formulas-4D0F13AC-53B7-422E-AFD2-ABD7FF379C64#bmsyntax_rules_for_names - * + * * Valid characters: * First character: { letter | underscore | backslash } * Remaining characters: { letter | number | period | underscore } - * + * * Cell shorthand: cannot be { "C" | "c" | "R" | "r" } - * + * * Cell references disallowed: cannot be a cell reference $A$1 or R1C1 - * + * * Spaces are not valid (follows from valid characters above) - * + * * Name length: (XSSF-specific?) 255 characters maximum - * + * * Case sensitivity: all names are case-insensitive - * + * * Uniqueness: must be unique (for names with the same scope) */ private static void validateName(String name) { @@ -187,7 +189,7 @@ public final class HSSFName implements Name { if (name.equalsIgnoreCase("R") || name.equalsIgnoreCase("C")) { throw new IllegalArgumentException("Invalid name: '"+name+"': cannot be special shorthand R or C"); } - + // is first character valid? char c = name.charAt(0); String allowedSymbols = "_\\"; @@ -195,7 +197,7 @@ public final class HSSFName implements Name { if (!characterIsValid) { throw new IllegalArgumentException("Invalid name: '"+name+"': first character must be underscore or a letter"); } - + // are all other characters valid? allowedSymbols = "_.\\"; //backslashes needed for unicode escape for (final char ch : name.toCharArray()) { @@ -204,7 +206,7 @@ public final class HSSFName implements Name { throw new IllegalArgumentException("Invalid name: '"+name+"': name must be letter, digit, period, or underscore"); } } - + // Is the name a valid $A$1 cell reference // Because $, :, and ! are disallowed characters, A1-style references become just a letter-number combination if (name.matches("[A-Za-z]+\\d+")) { @@ -214,18 +216,20 @@ public final class HSSFName implements Name { throw new IllegalArgumentException("Invalid name: '"+name+"': cannot be $A$1-style cell reference"); } } - + // Is the name a valid R1C1 cell reference? if (name.matches("[Rr]\\d+[Cc]\\d+")) { throw new IllegalArgumentException("Invalid name: '"+name+"': cannot be R1C1-style cell reference"); } } + @Override public void setRefersToFormula(String formulaText) { Ptg[] ptgs = HSSFFormulaParser.parse(formulaText, _book, FormulaType.NAMEDRANGE, getSheetIndex()); _definedNameRec.setNameDefinition(ptgs); } + @Override public String getRefersToFormula() { if (_definedNameRec.isFunctionName()) { throw new IllegalStateException("Only applicable to named ranges"); @@ -240,9 +244,9 @@ public final class HSSFName implements Name { /** - * Sets the NameParsedFormula structure that specifies the formula for the + * Sets the NameParsedFormula structure that specifies the formula for the * defined name. - * + * * @param ptgs the sequence of {@link Ptg}s for the formula. */ void setNameDefinition(Ptg[] ptgs) { @@ -250,6 +254,7 @@ public final class HSSFName implements Name { } + @Override public boolean isDeleted(){ Ptg[] ptgs = _definedNameRec.getNameDefinition(); return Ptg.doesFormulaReferToDeletedCell(ptgs); @@ -260,6 +265,7 @@ public final class HSSFName implements Name { * * @return true if this name is a function name */ + @Override public boolean isFunctionName() { return _definedNameRec.isFunctionName(); } @@ -270,6 +276,7 @@ public final class HSSFName implements Name { * * @return true if this name is a hidden one */ + @Override public boolean isHidden() { return _definedNameRec.isHiddenName(); } @@ -287,6 +294,7 @@ public final class HSSFName implements Name { * to the collection of sheets as they appear in the workbook. * @throws IllegalArgumentException if the sheet index is invalid. */ + @Override public void setSheetIndex(int index){ int lastSheetIx = _book.getNumberOfSheets() - 1; if (index < -1 || index > lastSheetIx) { @@ -302,6 +310,7 @@ public final class HSSFName implements Name { * * @return the sheet index this name applies to, -1 if this name applies to the entire workbook */ + @Override public int getSheetIndex(){ return _definedNameRec.getSheetNumber() - 1; } @@ -311,6 +320,7 @@ public final class HSSFName implements Name { * * @return the user comment for this named range */ + @Override public String getComment() { if(_commentRec != null) { // Prefer the comment record if it has text in it @@ -327,6 +337,7 @@ public final class HSSFName implements Name { * * @param comment the user comment for this named range */ + @Override public void setComment(String comment){ // Update the main record _definedNameRec.setDescriptionText(comment); @@ -340,8 +351,9 @@ public final class HSSFName implements Name { * Indicates that the defined name refers to a user-defined function. * This attribute is used when there is an add-in or other code project associated with the file. * - * @param value true indicates the name refers to a function. + * @param value {@code true} indicates the name refers to a function. */ + @Override public void setFunction(boolean value) { _definedNameRec.setFunction(value); } diff --git a/poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java b/poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java index 369cbd67e4..1cc07539e9 100644 --- a/poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java +++ b/poi/src/main/java/org/apache/poi/poifs/crypt/CryptoFunctions.java @@ -370,7 +370,7 @@ public final class CryptoFunctions { * * @see 2.3.7.1 Binary Document Password Verifier Derivation Method 1 * @see 2.3.7.4 Binary Document Password Verifier Derivation Method 2 - * @see Part 4 - Markup Language Reference - Ecma International - 3.2.12 fileSharing + * @see Part 4 - Markup Language Reference - Ecma International - 3.2.12 fileSharing * * @param password the password * @return the verifier (actually a short value) diff --git a/poi/src/main/java/org/apache/poi/ss/SpreadsheetVersion.java b/poi/src/main/java/org/apache/poi/ss/SpreadsheetVersion.java index 200175d04b..80ca938fc7 100644 --- a/poi/src/main/java/org/apache/poi/ss/SpreadsheetVersion.java +++ b/poi/src/main/java/org/apache/poi/ss/SpreadsheetVersion.java @@ -49,7 +49,7 @@ public enum SpreadsheetVersion { * (actually limited by available memory in Excel) *
  • Number of cell styles is 64000
  • *
  • Length of text cell contents is 32767
  • - *
      + *
    */ EXCEL2007(0x100000, 0x4000, 255, Integer.MAX_VALUE, 64000, 32767); @@ -60,7 +60,7 @@ public enum SpreadsheetVersion { private final int _maxCellStyles; private final int _maxTextLength; - private SpreadsheetVersion(int maxRows, int maxColumns, int maxFunctionArgs, int maxCondFormats, int maxCellStyles, int maxText) { + SpreadsheetVersion(int maxRows, int maxColumns, int maxFunctionArgs, int maxCondFormats, int maxCellStyles, int maxText) { _maxRows = maxRows; _maxColumns = maxColumns; _maxFunctionArgs = maxFunctionArgs; @@ -77,7 +77,7 @@ public enum SpreadsheetVersion { } /** - * @return the last (maximum) valid row index, equals to getMaxRows() - 1 + * @return the last (maximum) valid row index, equals to {@code getMaxRows() - 1 } */ public int getLastRowIndex() { return _maxRows - 1; @@ -91,7 +91,7 @@ public enum SpreadsheetVersion { } /** - * @return the last (maximum) valid column index, equals to getMaxColumns() - 1 + * @return the last (maximum) valid column index, equals to {@code getMaxColumns() - 1 } */ public int getLastColumnIndex() { return _maxColumns - 1; @@ -121,7 +121,7 @@ public enum SpreadsheetVersion { /** * * @return the last valid column index in a ALPHA-26 representation - * (IV or XFD). + * ({@code IV} or {@code XFD}). */ public String getLastColumnName() { return CellReference.convertNumToColString(getLastColumnIndex()); diff --git a/poi/src/main/java/org/apache/poi/ss/format/CellFormatter.java b/poi/src/main/java/org/apache/poi/ss/format/CellFormatter.java index e3ff5c5527..3f92623c57 100644 --- a/poi/src/main/java/org/apache/poi/ss/format/CellFormatter.java +++ b/poi/src/main/java/org/apache/poi/ss/format/CellFormatter.java @@ -17,7 +17,6 @@ package org.apache.poi.ss.format; import java.util.Locale; -import java.util.logging.Logger; import org.apache.poi.util.LocaleUtil; @@ -25,9 +24,6 @@ import org.apache.poi.util.LocaleUtil; * This is the abstract supertype for the various cell formatters. */ public abstract class CellFormatter { - /** The logger to use in the formatting code. */ - private static final Logger LOG = Logger.getLogger(CellFormatter.class.getName()); - /** The original specified format. */ protected final String format; protected final Locale locale; @@ -54,7 +50,7 @@ public abstract class CellFormatter { /** * Format a value according the format string. - *

    + *

    * NOTE: this method must be thread safe! In particular, if it uses a * Format instance that is not thread safe, i.e. DateFormat, this method * must be synchronized, either on the method, if the format is a final @@ -67,7 +63,7 @@ public abstract class CellFormatter { /** * Format a value according to the type, in the most basic way. - *

    + *

    * NOTE: this method must be thread safe! In particular, if it uses a * Format instance that is not thread safe, i.e. DateFormat, this method * must be synchronized, either on the method, if the format is a final diff --git a/poi/src/main/java/org/apache/poi/ss/format/CellGeneralFormatter.java b/poi/src/main/java/org/apache/poi/ss/format/CellGeneralFormatter.java index 79fedf4539..c502d1ba42 100644 --- a/poi/src/main/java/org/apache/poi/ss/format/CellGeneralFormatter.java +++ b/poi/src/main/java/org/apache/poi/ss/format/CellGeneralFormatter.java @@ -41,6 +41,7 @@ public class CellGeneralFormatter extends CellFormatter { * @param toAppendTo The buffer to append to. * @param value The value to format. */ + @Override public void formatValue(StringBuffer toAppendTo, Object value) { if (value instanceof Number) { double val = ((Number) value).doubleValue(); @@ -86,6 +87,7 @@ public class CellGeneralFormatter extends CellFormatter { } /** Equivalent to {@link #formatValue(StringBuffer,Object)}. {@inheritDoc}. */ + @Override public void simpleValue(StringBuffer toAppendTo, Object value) { formatValue(toAppendTo, value); } diff --git a/poi/src/main/java/org/apache/poi/ss/format/CellTextFormatter.java b/poi/src/main/java/org/apache/poi/ss/format/CellTextFormatter.java index f815407561..7179e95a0f 100644 --- a/poi/src/main/java/org/apache/poi/ss/format/CellTextFormatter.java +++ b/poi/src/main/java/org/apache/poi/ss/format/CellTextFormatter.java @@ -50,7 +50,7 @@ public class CellTextFormatter extends CellFormatter { } } - /** {@inheritDoc} */ + @Override public void formatValue(StringBuffer toAppendTo, Object obj) { int start = toAppendTo.length(); String text = obj.toString(); @@ -69,6 +69,7 @@ public class CellTextFormatter extends CellFormatter { *

    * For text, this is just printing the text. */ + @Override public void simpleValue(StringBuffer toAppendTo, Object value) { SIMPLE_TEXT.formatValue(toAppendTo, value); } diff --git a/poi/src/main/java/org/apache/poi/ss/formula/EvaluationWorkbook.java b/poi/src/main/java/org/apache/poi/ss/formula/EvaluationWorkbook.java index 39a11e1259..c0469f7e5d 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/EvaluationWorkbook.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/EvaluationWorkbook.java @@ -81,7 +81,7 @@ public interface EvaluationWorkbook { * * @since POI 3.15 beta 3 */ - public void clearAllCachedResultValues(); + void clearAllCachedResultValues(); class ExternalSheet { private final String _workbookName; diff --git a/poi/src/main/java/org/apache/poi/ss/formula/FormulaRenderingWorkbook.java b/poi/src/main/java/org/apache/poi/ss/formula/FormulaRenderingWorkbook.java index 50c93a7531..a9d365aeec 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/FormulaRenderingWorkbook.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/FormulaRenderingWorkbook.java @@ -28,7 +28,7 @@ import org.apache.poi.util.Internal; @Internal public interface FormulaRenderingWorkbook { /** - * @return null if externSheetIndex refers to a sheet inside the current workbook + * @return {@code null} if externSheetIndex refers to a sheet inside the current workbook */ ExternalSheet getExternalSheet(int externSheetIndex); diff --git a/poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java b/poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java index f60c7855ff..03f22788ff 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/eval/TwoOperandNumericOperation.java @@ -20,8 +20,6 @@ package org.apache.poi.ss.formula.eval; import org.apache.poi.ss.formula.functions.ArrayFunction; import org.apache.poi.ss.formula.functions.Fixed2ArgFunction; import org.apache.poi.ss.formula.functions.Function; -import org.apache.poi.ss.formula.functions.MatrixFunction.MutableValueCollector; -import org.apache.poi.ss.formula.functions.MatrixFunction.TwoArrayArg; public abstract class TwoOperandNumericOperation extends Fixed2ArgFunction implements ArrayFunction { @@ -30,7 +28,8 @@ public abstract class TwoOperandNumericOperation extends Fixed2ArgFunction imple return OperandResolver.coerceValueToDouble(ve); } - public ValueEval evaluateArray(ValueEval[] args, int srcRowIndex, int srcColumnIndex) { + @Override + public ValueEval evaluateArray(ValueEval[] args, int srcRowIndex, int srcColumnIndex) { if (args.length != 2) { return ErrorEval.VALUE_INVALID; } @@ -50,6 +49,7 @@ public abstract class TwoOperandNumericOperation extends Fixed2ArgFunction imple } + @Override public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) { double result; try { @@ -73,35 +73,14 @@ public abstract class TwoOperandNumericOperation extends Fixed2ArgFunction imple protected abstract double evaluate(double d0, double d1) throws EvaluationException; - private final class ArrayEval extends TwoArrayArg { - private final MutableValueCollector instance = new MutableValueCollector(true, true); - - protected double[] collectValues(ValueEval arg) throws EvaluationException { - return instance.collectValues(arg); - } - - protected double[][] evaluate(double[][] d1, double[][] d2) throws IllegalArgumentException, EvaluationException { - int width = (d1[0].length < d2[0].length) ? d1[0].length : d2[0].length; - int height = (d1.length < d2.length) ? d1.length : d2.length; - - double[][] result = new double[height][width]; - - for (int j = 0; j < height; j++) { - for (int i = 0; i < width; i++) { - result[j][i] = TwoOperandNumericOperation.this.evaluate(d1[j][i], d2[j][i]); - } - } - - return result; - } - } - public static final Function AddEval = new TwoOperandNumericOperation() { + @Override protected double evaluate(double d0, double d1) { return d0+d1; } }; public static final Function DivideEval = new TwoOperandNumericOperation() { + @Override protected double evaluate(double d0, double d1) throws EvaluationException { if (d1 == 0.0) { throw new EvaluationException(ErrorEval.DIV_ZERO); @@ -110,11 +89,13 @@ public abstract class TwoOperandNumericOperation extends Fixed2ArgFunction imple } }; public static final Function MultiplyEval = new TwoOperandNumericOperation() { + @Override protected double evaluate(double d0, double d1) { return d0*d1; } }; public static final Function PowerEval = new TwoOperandNumericOperation() { + @Override protected double evaluate(double d0, double d1) { if(d0 < 0 && Math.abs(d1) > 0.0 && Math.abs(d1) < 1.0) { return -1 * Math.pow(d0 * -1, d1); @@ -126,6 +107,7 @@ public abstract class TwoOperandNumericOperation extends Fixed2ArgFunction imple public SubtractEvalClass() { // } + @Override protected double evaluate(double d0, double d1) { return d0-d1; } diff --git a/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java b/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java index 8ba3aeef75..564b5da403 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/eval/forked/ForkedEvaluationWorkbook.java @@ -36,7 +36,7 @@ import org.apache.poi.util.Internal; * Represents a workbook being used for forked evaluation. Most operations are delegated to the * shared master workbook, except those that potentially involve cell values that may have been * updated after a call to {@link #getOrCreateUpdatableCell(String, int, int)}.
    - * + * * For POI internal use only */ @Internal @@ -117,7 +117,7 @@ final class ForkedEvaluationWorkbook implements EvaluationWorkbook { public EvaluationSheet getSheet(int sheetIndex) { return getSharedSheet(getSheetName(sheetIndex)); } - + @Override public ExternalName getExternalName(int externSheetIndex, int externNameIndex) { return _masterBook.getExternalName(externSheetIndex, externNameIndex); @@ -155,15 +155,16 @@ final class ForkedEvaluationWorkbook implements EvaluationWorkbook { public UDFFinder getUDFFinder() { return _masterBook.getUDFFinder(); } - + + @Override public SpreadsheetVersion getSpreadsheetVersion() { return _masterBook.getSpreadsheetVersion(); } - + /* (non-Javadoc) * leave the map alone, if it needs resetting, reusing this class is probably a bad idea. * @see org.apache.poi.ss.formula.EvaluationSheet#clearAllCachedResultValues() - * + * * @since POI 3.15 beta 3 */ @Override diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/ArrayFunction.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/ArrayFunction.java index aa896ecc32..ea59d630c9 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/functions/ArrayFunction.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/ArrayFunction.java @@ -48,7 +48,7 @@ public interface ArrayFunction { * @param arg0 the first function argument. Empty values are represented with * {@link BlankEval} or {@link MissingArgEval}, never {@code null} * @param arg1 the first function argument. Empty values are represented with - * @link BlankEval} or {@link MissingArgEval}, never {@code null} + * {@link BlankEval} or {@link MissingArgEval}, never {@code null} * * @param srcRowIndex row index of the cell containing the formula under evaluation * @param srcColumnIndex column index of the cell containing the formula under evaluation diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/Countblank.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/Countblank.java index 1963071686..8183579223 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/functions/Countblank.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/Countblank.java @@ -29,7 +29,6 @@ import org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate; *

    * *
    string_flag mapping
    Bit numberMeaning if 0
    Parameter descriptions
    range   is the range of cells to count blanks
    - *

    */ public final class Countblank extends Fixed1ArgFunction { diff --git a/poi/src/main/java/org/apache/poi/ss/formula/functions/TextFunction.java b/poi/src/main/java/org/apache/poi/ss/formula/functions/TextFunction.java index d934825d54..d170d0fdbf 100644 --- a/poi/src/main/java/org/apache/poi/ss/formula/functions/TextFunction.java +++ b/poi/src/main/java/org/apache/poi/ss/formula/functions/TextFunction.java @@ -197,7 +197,7 @@ public abstract class TextFunction implements Function { * MID returns a specific number of * characters from a text string, starting at the specified position.

    * - * Syntax:
    MID(text, start_num, + * Syntax:
    MID(text, start_num, * num_chars)
    * * Author: Manda Wilson < wilson at c bio dot msk cc dot org > @@ -335,7 +335,7 @@ public abstract class TextFunction implements Function { * {@link DataFormatter} to be done, as this works much the same as the * display focused work that that does. * - * Syntax:
    TEXT(value, format_text)
    + * Syntax:
    TEXT(value, format_text)
    */ public static final Function TEXT = new Fixed2ArgFunction() { diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/HorizontalAlignment.java b/poi/src/main/java/org/apache/poi/ss/usermodel/HorizontalAlignment.java index 6b9a313261..b845870808 100644 --- a/poi/src/main/java/org/apache/poi/ss/usermodel/HorizontalAlignment.java +++ b/poi/src/main/java/org/apache/poi/ss/usermodel/HorizontalAlignment.java @@ -62,7 +62,6 @@ public enum HorizontalAlignment { * left/right edge, don't append the additional occurrence of the value. *

  • The display value of the cell is filled, not the underlying raw number.
  • * - *

    */ FILL, @@ -92,7 +91,7 @@ public enum HorizontalAlignment { *

    Two lines inside a cell are separated by a carriage return.

    */ DISTRIBUTED; - + public short getCode() { return (short) ordinal(); } diff --git a/poi/src/main/java/org/apache/poi/ss/usermodel/Name.java b/poi/src/main/java/org/apache/poi/ss/usermodel/Name.java index 65ca8e3f92..ec4b2d3434 100644 --- a/poi/src/main/java/org/apache/poi/ss/usermodel/Name.java +++ b/poi/src/main/java/org/apache/poi/ss/usermodel/Name.java @@ -90,7 +90,7 @@ public interface Name { *

    * A name must always be unique within its scope. POI prevents you from defining a name that is not unique * within its scope. However you can use the same name in different scopes. Example: - *

    + *
    {@code
          * //by default names are workbook-global
          * Name name;
          * name = workbook.createName();
    @@ -108,8 +108,8 @@ public interface Name {
          * name.setSheetIndex(0);
          * name.setNameName("sales_08");  //will throw an exception: "The sheet already contains this name (case-insensitive)"
          *
    -     * 
    - *

    + * } + * * @param name named range name to set * @throws IllegalArgumentException if the name is invalid or the already exists within its scope (case-insensitive) */ @@ -118,7 +118,7 @@ public interface Name { /** * Returns the formula that the name is defined to refer to. * - * @return the reference for this name, null if it has not been set yet. Never empty string + * @return the reference for this name, {@code null} if it has not been set yet. Never empty string * @see #setRefersToFormula(String) */ String getRefersToFormula(); @@ -127,11 +127,11 @@ public interface Name { * Sets the formula that the name is defined to refer to. The following are representative examples: * *
      - *
    • 'My Sheet'!$A$3
    • - *
    • 8.3
    • - *
    • HR!$A$1:$Z$345
    • - *
    • SUM(Sheet1!A1,Sheet2!B2)
    • - *
    • -PMT(Interest_Rate/12,Number_of_Payments,Loan_Amount)
    • + *
    • {@code 'My Sheet'!$A$3}
    • + *
    • {@code 8.3}
    • + *
    • {@code HR!$A$1:$Z$345}
    • + *
    • {@code SUM(Sheet1!A1,Sheet2!B2)}
    • + *
    • {@code -PMT(Interest_Rate/12,Number_of_Payments,Loan_Amount)}
    • *
    * * Note: Using relative values like 'A1:B1' can lead to unexpected moving of @@ -154,7 +154,7 @@ public interface Name { /** * Checks if this name points to a cell that no longer exists * - * @return true if the name refers to a deleted cell, false otherwise + * @return {@code true} if the name refers to a deleted cell, {@code false} otherwise */ boolean isDeleted(); @@ -162,7 +162,7 @@ public interface Name { * Checks if this name is hidden, eg one of the built-in Excel * internal names * - * @return true if the name is a hidden name, false otherwise + * @return {@code true} if the name is a hidden name, {@code false} otherwise */ boolean isHidden(); @@ -172,34 +172,34 @@ public interface Name { * @param sheetId the sheet index this name applies to, -1 unsets this property making the name workbook-global * @throws IllegalArgumentException if the sheet index is invalid. */ - public void setSheetIndex(int sheetId); + void setSheetIndex(int sheetId); /** * Returns the sheet index this name applies to. * * @return the sheet index this name applies to, -1 if this name applies to the entire workbook */ - public int getSheetIndex(); + int getSheetIndex(); /** * Returns the comment the user provided when the name was created. * * @return the user comment for this named range */ - public String getComment(); + String getComment(); /** * Sets the comment the user provided when the name was created. * * @param comment the user comment for this named range */ - public void setComment(String comment); + void setComment(String comment); /** * Indicates that the defined name refers to a user-defined function. * This attribute is used when there is an add-in or other code project associated with the file. * - * @param value true indicates the name refers to a function. + * @param value {@code true} indicates the name refers to a function. */ void setFunction(boolean value); } diff --git a/poi/src/main/java/org/apache/poi/ss/util/AreaReference.java b/poi/src/main/java/org/apache/poi/ss/util/AreaReference.java index 97c2016e7c..ff9482c25f 100644 --- a/poi/src/main/java/org/apache/poi/ss/util/AreaReference.java +++ b/poi/src/main/java/org/apache/poi/ss/util/AreaReference.java @@ -385,7 +385,7 @@ public class AreaReference { * Example return values: * * - * + * * * * diff --git a/poi/src/main/java/org/apache/poi/ss/util/CellReference.java b/poi/src/main/java/org/apache/poi/ss/util/CellReference.java index 75bc7ec7b0..4a40f8dfef 100644 --- a/poi/src/main/java/org/apache/poi/ss/util/CellReference.java +++ b/poi/src/main/java/org/apache/poi/ss/util/CellReference.java @@ -300,8 +300,8 @@ public class CellReference implements GenericRecord { * * POI currently targets BIFF8 (Excel 97-2003), so the following behaviour can be observed for * this method: - *
    Example return values
    ResultComment
    ResultComment
    A1:A1Single cell area reference without sheet
    A1:$C$1Multi-cell area reference without sheet
    Sheet1!A$1:B4Standard sheet name
    + *
    + * * * * @@ -313,7 +313,7 @@ public class CellReference implements GenericRecord { * * * - *
    Notable cases
    Input           Result 
    "A", "1"true
    "AAA", "1"false
    "a", "111"true
    "Sheet", "1"false
    + * * * @param colStr a string of only letter characters * @param rowStr a string of only digit characters @@ -485,7 +485,7 @@ public class CellReference implements GenericRecord { * Example return values: * * - * + * * * * @@ -502,8 +502,9 @@ public class CellReference implements GenericRecord { * *

    * Example return values: - *

    Example return values
    ResultComment
    ResultComment
    A1Cell reference without sheet
    Sheet1!A1Standard sheet name
    'O''Brien''s Sales'!A1' Sheet name with special characters
    - * + *
    ResultComment
    + * + * * * * @@ -583,9 +584,7 @@ public class CellReference implements GenericRecord { && _colIndex == cr._colIndex && _isRowAbs == cr._isRowAbs && _isColAbs == cr._isColAbs - && ((_sheetName == null) - ? (cr._sheetName == null) - : _sheetName.equals(cr._sheetName)); + && Objects.equals(_sheetName, cr._sheetName); } @Override
    Example return values
    ResultComment
    A1Cell reference without sheet
    Sheet1!A1Standard sheet name
    'O''Brien''s Sales'!A1' Sheet name with special characters