]> source.dussan.org Git - poi.git/commitdiff
Various code cleanups, "final" for static methods is useless, for-loops, simplify...
authorDominik Stadler <centic@apache.org>
Sun, 17 Sep 2017 11:08:23 +0000 (11:08 +0000)
committerDominik Stadler <centic@apache.org>
Sun, 17 Sep 2017 11:08:23 +0000 (11:08 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808620 13f79535-47bb-0310-9956-ffa450edef68

47 files changed:
src/examples/src/org/apache/poi/hssf/view/SVTableUtils.java
src/examples/src/org/apache/poi/ss/examples/LinkedDropDownLists.java
src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java
src/java/org/apache/poi/hssf/record/CFHeaderBase.java
src/java/org/apache/poi/hssf/record/ExtSSTRecord.java
src/java/org/apache/poi/hssf/record/GridsetRecord.java
src/java/org/apache/poi/hssf/record/HCenterRecord.java
src/java/org/apache/poi/hssf/record/NameRecord.java
src/java/org/apache/poi/hssf/record/PrecisionRecord.java
src/java/org/apache/poi/hssf/record/PrintGridlinesRecord.java
src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java
src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java
src/java/org/apache/poi/hssf/util/HSSFColor.java
src/java/org/apache/poi/ss/formula/functions/DStarRunner.java
src/java/org/apache/poi/ss/formula/functions/ImReal.java
src/java/org/apache/poi/ss/formula/functions/Imaginary.java
src/java/org/apache/poi/ss/formula/functions/MatrixFunction.java
src/java/org/apache/poi/ss/formula/functions/NumericFunction.java
src/java/org/apache/poi/ss/formula/functions/Rate.java
src/java/org/apache/poi/ss/formula/ptg/AbstractFunctionPtg.java
src/java/org/apache/poi/ss/usermodel/DataFormatter.java
src/java/org/apache/poi/ss/usermodel/FormulaError.java
src/java/org/apache/poi/ss/util/SheetBuilder.java
src/java/org/apache/poi/ss/util/WorkbookUtil.java
src/ooxml/java/org/apache/poi/POIXMLTypeLoader.java
src/ooxml/java/org/apache/poi/openxml4j/opc/PackagePart.java
src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/RevocationData.java
src/ooxml/java/org/apache/poi/xdgf/usermodel/XDGFShape.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTextRun.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFGraphicFrame.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFDocument.java
src/ooxml/java/org/apache/poi/xwpf/usermodel/XWPFSDTContent.java
src/ooxml/testcases/org/apache/poi/xssf/model/TestStylesTable.java
src/scratchpad/src/org/apache/poi/hslf/record/RecordContainer.java
src/scratchpad/src/org/apache/poi/hslf/usermodel/HSLFSlideShowImpl.java
src/scratchpad/src/org/apache/poi/hsmf/MAPIMessage.java
src/scratchpad/src/org/apache/poi/hsmf/datatypes/Chunks.java
src/scratchpad/src/org/apache/poi/hwpf/converter/AbstractWordConverter.java
src/scratchpad/src/org/apache/poi/hwpf/converter/WordToFoConverter.java
src/scratchpad/src/org/apache/poi/hwpf/converter/WordToHtmlConverter.java
src/testcases/org/apache/poi/hssf/eventusermodel/TestHSSFEventFactory.java
src/testcases/org/apache/poi/hssf/record/TestFormulaRecord.java
src/testcases/org/apache/poi/poifs/filesystem/TestNotOLE2Exception.java
src/testcases/org/apache/poi/poifs/filesystem/TestOfficeXMLException.java
src/testcases/org/apache/poi/ss/formula/eval/forked/TestForkedEvaluator.java
src/testcases/org/apache/poi/ss/formula/ptg/AbstractPtgTestCase.java

index 4ec32944d55a0fbf3cdcdda6a97e8d45afd9febf..1a9fbf813af78c47496e6c0d2f0bbedbb08eb08b 100644 (file)
@@ -70,7 +70,7 @@ public class SVTableUtils {
   /** This method retrieves the AWT Color representation from the colour hash table
    *
    */
-  /* package */ static final Color getAWTColor(int index, Color deflt) {
+  /* package */ static Color getAWTColor(int index, Color deflt) {
     HSSFColor clr = colors.get(index);
     if (clr == null) {
       return deflt;
@@ -79,7 +79,7 @@ public class SVTableUtils {
     return new Color(rgb[0],rgb[1],rgb[2]);
   }
 
-  /* package */ static final Color getAWTColor(HSSFColorPredefined clr) {
+  /* package */ static Color getAWTColor(HSSFColorPredefined clr) {
     short[] rgb = clr.getTriplet();
     return new Color(rgb[0],rgb[1],rgb[2]);
   }
index 8f43b4bf664e6b414b5d4329e7a54c110c80c5ad..4e29e8f8529b194349499160865e88d04e997600 100644 (file)
@@ -132,7 +132,7 @@ public class LinkedDropDownLists {
      * @param dataSheet An instance of a class that implements the Sheet Sheet
      *        interface (HSSFSheet or XSSFSheet).
      */
-    private static final void buildDataSheet(Sheet dataSheet) {
+    private static void buildDataSheet(Sheet dataSheet) {
         Row row = null;
         Cell cell = null;
         Name name = null;
index 2bad961bdbaf397516dca809aae55816be20a0b8..e348d964e061cc89b7867fdc9f267006a71a99c0 100644 (file)
@@ -62,7 +62,7 @@ public class HPSFFileHandler extends POIFSFileHandler {
     );
         
     
-    private static final Set<String> unmodifiableHashSet(String... a) {
+    private static Set<String> unmodifiableHashSet(String... a) {
         return Collections.unmodifiableSet(new HashSet<>(Arrays.asList(a)));
     }
 
index 015917e25e51ba8a1ed287e18b1fbdbfdee8ec3e..f4c1fbe87f04858a54e2459181d34b36739ce155 100644 (file)
@@ -67,7 +67,9 @@ public abstract class CFHeaderBase extends StandardRecord implements Cloneable {
         // held on the first bit
         if (b == getNeedRecalculation()) {
             return;
-        } else if (b) {
+        }
+
+        if (b) {
             field_2_need_recalculation_and_id++;
         } else {
             field_2_need_recalculation_and_id--;
@@ -105,8 +107,7 @@ public abstract class CFHeaderBase extends StandardRecord implements Cloneable {
         }
         CellRangeAddressList cral = new CellRangeAddressList();
         CellRangeAddress enclosingRange = null;
-        for (int i = 0; i < cellRanges.length; i++) {
-            CellRangeAddress cr = cellRanges[i];
+        for (CellRangeAddress cr : cellRanges) {
             enclosingRange = CellRangeUtil.createEnclosingCellRange(cr, enclosingRange);
             cral.addCellRangeAddress(cr);
         }
@@ -119,8 +120,9 @@ public abstract class CFHeaderBase extends StandardRecord implements Cloneable {
     }
 
     protected abstract String getRecordName();
+
     public String toString() {
-        StringBuffer buffer = new StringBuffer();
+        StringBuilder buffer = new StringBuilder();
 
         buffer.append("[").append(getRecordName()).append("]\n");
         buffer.append("\t.numCF             = ").append(getNumberOfConditionalFormats()).append("\n");
index 8660d978957b661919b1ff030f8eb592822c9c34..e0b975d0880fbbe9752ed5a1794dd3fa4f9ae6a7 100644 (file)
@@ -148,7 +148,7 @@ public final class ExtSSTRecord extends ContinuableRecord {
         return _sstInfos;
     }
 
-    public static final int getNumberOfInfoRecsForStrings(int numStrings) {
+    public static int getNumberOfInfoRecsForStrings(int numStrings) {
       int infoRecs = (numStrings / DEFAULT_BUCKET_SIZE);
       if ((numStrings % DEFAULT_BUCKET_SIZE) != 0)
         infoRecs ++;
@@ -166,7 +166,7 @@ public final class ExtSSTRecord extends ContinuableRecord {
      * 
      * @return the size of the extsst record
      */
-    public static final int getRecordSizeForStrings(int numStrings) {
+    public static int getRecordSizeForStrings(int numStrings) {
         return 4 + 2 + getNumberOfInfoRecsForStrings(numStrings) * 8;
     }
 
index 14f04ab2ab66cf81579698314c7e19a4576694cc..570ebe2867ef40cb4afc24768661ac6915018fda 100644 (file)
@@ -15,8 +15,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 package org.apache.poi.hssf.record;
 
 import org.apache.poi.util.LittleEndianOutput;
@@ -33,13 +31,11 @@ import org.apache.poi.util.LittleEndianOutput;
  *
  * @version 2.0-pre
  */
-
 public final class GridsetRecord extends StandardRecord implements Cloneable {
     public final static short sid = 0x82;
     public short              field_1_gridset_flag;
 
-    public GridsetRecord()
-    {
+    public GridsetRecord() {
     }
 
     public GridsetRecord(RecordInputStream in)
@@ -52,15 +48,10 @@ public final class GridsetRecord extends StandardRecord implements Cloneable {
      *
      * @param gridset - <b>true</b> if no gridlines are print, <b>false</b> if gridlines are not print.
      */
-
-    public void setGridset(boolean gridset)
-    {
-        if (gridset == true)
-        {
+    public void setGridset(boolean gridset) {
+        if (gridset) {
             field_1_gridset_flag = 1;
-        }
-        else
-        {
+        } else {
             field_1_gridset_flag = 0;
         }
     }
@@ -70,21 +61,16 @@ public final class GridsetRecord extends StandardRecord implements Cloneable {
      *
      * @return gridset - true if gridlines are NOT printed, false if they are.
      */
-
     public boolean getGridset()
     {
         return (field_1_gridset_flag == 1);
     }
 
-    public String toString()
-    {
-        StringBuffer buffer = new StringBuffer();
-
-        buffer.append("[GRIDSET]\n");
-        buffer.append("    .gridset        = ").append(getGridset())
-            .append("\n");
-        buffer.append("[/GRIDSET]\n");
-        return buffer.toString();
+    public String toString() {
+        return "[GRIDSET]\n" +
+                "    .gridset        = " + getGridset() +
+                "\n" +
+                "[/GRIDSET]\n";
     }
 
     public void serialize(LittleEndianOutput out) {
index 604ddeae28a390ff0021aad1d3af7c59f57655c9..d050823a6fae11a92de80e9968d03ae56ed93430 100644 (file)
@@ -14,7 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-
 package org.apache.poi.hssf.record;
 
 import org.apache.poi.util.LittleEndianOutput;
@@ -31,8 +30,7 @@ public final class HCenterRecord extends StandardRecord implements Cloneable {
     public final static short sid = 0x0083;
     private short             field_1_hcenter;
 
-    public HCenterRecord()
-    {
+    public HCenterRecord() {
     }
 
     public HCenterRecord(RecordInputStream in)
@@ -44,15 +42,10 @@ public final class HCenterRecord extends StandardRecord implements Cloneable {
      * set whether or not to horizonatally center this sheet.
      * @param hc  center - t/f
      */
-
-    public void setHCenter(boolean hc)
-    {
-        if (hc == true)
-        {
+    public void setHCenter(boolean hc) {
+        if (hc) {
             field_1_hcenter = 1;
-        }
-        else
-        {
+        } else {
             field_1_hcenter = 0;
         }
     }
@@ -61,21 +54,16 @@ public final class HCenterRecord extends StandardRecord implements Cloneable {
      * get whether or not to horizonatally center this sheet.
      * @return center - t/f
      */
-
     public boolean getHCenter()
     {
         return (field_1_hcenter == 1);
     }
 
-    public String toString()
-    {
-        StringBuffer buffer = new StringBuffer();
-
-        buffer.append("[HCENTER]\n");
-        buffer.append("    .hcenter        = ").append(getHCenter())
-            .append("\n");
-        buffer.append("[/HCENTER]\n");
-        return buffer.toString();
+    public String toString() {
+        return "[HCENTER]\n" +
+                "    .hcenter        = " + getHCenter() +
+                "\n" +
+                "[/HCENTER]\n";
     }
 
     public void serialize(LittleEndianOutput out) {
index 050745b25997a3a4626a15d8f617563b5677c3f2..e4331c00f5ae62e5355a020dd8ff3b2220e3d694 100644 (file)
@@ -66,7 +66,7 @@ public final class NameRecord extends ContinuableRecord {
                public static final int OPT_COMPLEX =       0x0010;
                public static final int OPT_BUILTIN =       0x0020;
                public static final int OPT_BINDATA =       0x1000;
-               public static final boolean isFormula(int optValue) {
+               public static boolean isFormula(int optValue) {
                        return (optValue & 0x0F) == 0;
                }
        }
index 0dede18379eac75d1fc8271e6ce1191d0b3e2433..74bf8cf916b42fe03f943de3614399cd665fb289 100644 (file)
@@ -15,8 +15,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 package org.apache.poi.hssf.record;
 
 import org.apache.poi.util.LittleEndianOutput;
@@ -28,15 +26,11 @@ import org.apache.poi.util.LittleEndianOutput;
  * REFERENCE:  PG 372 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
  * @version 2.0-pre
  */
-
-public final class PrecisionRecord
-    extends StandardRecord
-{
+public final class PrecisionRecord extends StandardRecord {
     public final static short sid = 0xE;
     public short              field_1_precision;
 
-    public PrecisionRecord()
-    {
+    public PrecisionRecord() {
     }
 
     public PrecisionRecord(RecordInputStream in)
@@ -49,15 +43,10 @@ public final class PrecisionRecord
      *
      * @param fullprecision - or not
      */
-
-    public void setFullPrecision(boolean fullprecision)
-    {
-        if (fullprecision == true)
-        {
+    public void setFullPrecision(boolean fullprecision) {
+        if (fullprecision) {
             field_1_precision = 1;
-        }
-        else
-        {
+        } else {
             field_1_precision = 0;
         }
     }
@@ -67,21 +56,16 @@ public final class PrecisionRecord
      *
      * @return fullprecision - or not
      */
-
     public boolean getFullPrecision()
     {
         return (field_1_precision == 1);
     }
 
-    public String toString()
-    {
-        StringBuffer buffer = new StringBuffer();
-
-        buffer.append("[PRECISION]\n");
-        buffer.append("    .precision       = ").append(getFullPrecision())
-            .append("\n");
-        buffer.append("[/PRECISION]\n");
-        return buffer.toString();
+    public String toString() {
+        return "[PRECISION]\n" +
+                "    .precision       = " + getFullPrecision() +
+                "\n" +
+                "[/PRECISION]\n";
     }
 
     public void serialize(LittleEndianOutput out) {
index b22e244853ec31b87b59b689cb4f63dc5d357027..2563f3432689895a1939a1b8c2870947e38f1f65 100644 (file)
@@ -1,4 +1,3 @@
-
 /* ====================================================================
    Licensed to the Apache Software Foundation (ASF) under one or more
    contributor license agreements.  See the NOTICE file distributed with
@@ -15,8 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 package org.apache.poi.hssf.record;
 
 import org.apache.poi.util.LittleEndianOutput;
@@ -29,15 +26,11 @@ import org.apache.poi.util.LittleEndianOutput;
  * @author Jason Height (jheight at chariot dot net dot au)
  * @version 2.0-pre
  */
-
-public final class PrintGridlinesRecord
-    extends StandardRecord
-{
+public final class PrintGridlinesRecord extends StandardRecord {
     public final static short sid = 0x2b;
     private short             field_1_print_gridlines;
 
-    public PrintGridlinesRecord()
-    {
+    public PrintGridlinesRecord() {
     }
 
     public PrintGridlinesRecord(RecordInputStream in)
@@ -50,15 +43,10 @@ public final class PrintGridlinesRecord
      *
      * @param pg  make spreadsheet ugly - Y/N
      */
-
-    public void setPrintGridlines(boolean pg)
-    {
-        if (pg == true)
-        {
+    public void setPrintGridlines(boolean pg) {
+        if (pg) {
             field_1_print_gridlines = 1;
-        }
-        else
-        {
+        } else {
             field_1_print_gridlines = 0;
         }
     }
@@ -68,21 +56,16 @@ public final class PrintGridlinesRecord
      *
      * @return make spreadsheet ugly - Y/N
      */
-
     public boolean getPrintGridlines()
     {
         return (field_1_print_gridlines == 1);
     }
 
-    public String toString()
-    {
-        StringBuffer buffer = new StringBuffer();
-
-        buffer.append("[PRINTGRIDLINES]\n");
-        buffer.append("    .printgridlines = ").append(getPrintGridlines())
-            .append("\n");
-        buffer.append("[/PRINTGRIDLINES]\n");
-        return buffer.toString();
+    public String toString() {
+        return "[PRINTGRIDLINES]\n" +
+                "    .printgridlines = " + getPrintGridlines() +
+                "\n" +
+                "[/PRINTGRIDLINES]\n";
     }
 
     public void serialize(LittleEndianOutput out) {
index f2287ee6fc54699701b00c8ba2840be7eca98e3f..607c4a8b7c98fafe5965a42017522c48094ced54 100644 (file)
@@ -15,8 +15,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 package org.apache.poi.hssf.record;
 
 import org.apache.poi.util.LittleEndianOutput;
@@ -30,15 +28,11 @@ import org.apache.poi.util.LittleEndianOutput;
  * @author Jason Height (jheight at chariot dot net dot au)
  * @version 2.0-pre
  */
-
-public final class PrintHeadersRecord
-    extends StandardRecord
-{
+public final class PrintHeadersRecord extends StandardRecord {
     public final static short sid = 0x2a;
     private short             field_1_print_headers;
 
-    public PrintHeadersRecord()
-    {
+    public PrintHeadersRecord() {
     }
 
     public PrintHeadersRecord(RecordInputStream in)
@@ -50,15 +44,10 @@ public final class PrintHeadersRecord
      * set to print the headers - y/n
      * @param p printheaders or not
      */
-
-    public void setPrintHeaders(boolean p)
-    {
-        if (p == true)
-        {
+    public void setPrintHeaders(boolean p) {
+        if (p) {
             field_1_print_headers = 1;
-        }
-        else
-        {
+        } else {
             field_1_print_headers = 0;
         }
     }
@@ -67,21 +56,16 @@ public final class PrintHeadersRecord
      * get whether to print the headers - y/n
      * @return printheaders or not
      */
-
     public boolean getPrintHeaders()
     {
         return (field_1_print_headers == 1);
     }
 
-    public String toString()
-    {
-        StringBuffer buffer = new StringBuffer();
-
-        buffer.append("[PRINTHEADERS]\n");
-        buffer.append("    .printheaders   = ").append(getPrintHeaders())
-            .append("\n");
-        buffer.append("[/PRINTHEADERS]\n");
-        return buffer.toString();
+    public String toString() {
+        return "[PRINTHEADERS]\n" +
+                "    .printheaders   = " + getPrintHeaders() +
+                "\n" +
+                "[/PRINTHEADERS]\n";
     }
 
     public void serialize(LittleEndianOutput out) {
index 96cfde27c7532a332d9fb764a7a6e5d00316994d..05c66f78f0a5eda81f3c284783146e0fbd105b2b 100644 (file)
@@ -15,8 +15,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
-
 package org.apache.poi.hssf.record;
 
 import org.apache.poi.util.LittleEndianOutput;
@@ -29,15 +27,13 @@ import org.apache.poi.util.LittleEndianOutput;
  * @author Jason Height (jheight at chariot dot net dot au)
  * @version 2.0-pre
  */
-
 public final class SaveRecalcRecord
     extends StandardRecord
 {
     public final static short sid = 0x5f;
     private short             field_1_recalc;
 
-    public SaveRecalcRecord()
-    {
+    public SaveRecalcRecord() {
     }
 
     public SaveRecalcRecord(RecordInputStream in)
@@ -49,32 +45,24 @@ public final class SaveRecalcRecord
      * set whether to recalculate formulas/etc before saving or not
      * @param recalc - whether to recalculate or not
      */
-
-    public void setRecalc(boolean recalc)
-    {
-        field_1_recalc = ( short ) ((recalc == true) ? 1
-                                                     : 0);
+    public void setRecalc(boolean recalc) {
+        field_1_recalc = ( short ) (recalc ? 1 : 0);
     }
 
     /**
      * get whether to recalculate formulas/etc before saving or not
      * @return recalc - whether to recalculate or not
      */
-
     public boolean getRecalc()
     {
         return (field_1_recalc == 1);
     }
 
-    public String toString()
-    {
-        StringBuffer buffer = new StringBuffer();
-
-        buffer.append("[SAVERECALC]\n");
-        buffer.append("    .recalc         = ").append(getRecalc())
-            .append("\n");
-        buffer.append("[/SAVERECALC]\n");
-        return buffer.toString();
+    public String toString() {
+        return "[SAVERECALC]\n" +
+                "    .recalc         = " + getRecalc() +
+                "\n" +
+                "[/SAVERECALC]\n";
     }
 
     public void serialize(LittleEndianOutput out) {
index 1490abf791f33ea540d23a587b91e51cc6ba05f1..3c0ba6a9cecc7e14d90657cdbc5d78a69f7f9b70 100644 (file)
@@ -168,7 +168,7 @@ public class HSSFColor implements Color {
      *
      * @return a Map containing all colours keyed by <tt>Integer</tt> excel-style palette indexes
      */
-    public static final synchronized Map<Integer,HSSFColor> getIndexHash() {
+    public static synchronized Map<Integer,HSSFColor> getIndexHash() {
         if(indexHash == null) {
            indexHash = Collections.unmodifiableMap( createColorsByIndexMap() );
         }
@@ -181,7 +181,7 @@ public class HSSFColor implements Color {
      *  the table, then call {@link #getIndexHash()} which returns a
      *  statically cached immutable map of colours.
      */
-    public static final Map<Integer,HSSFColor> getMutableIndexHash() {
+    public static Map<Integer,HSSFColor> getMutableIndexHash() {
        return createColorsByIndexMap();
     }
 
index f2cc9c2aa0aebec2a0205c0d002764409c9f0180..6a43a62047c43b6e53b3d4734ce1ac3161ea8255 100644 (file)
@@ -86,7 +86,7 @@ public final class DStarRunner implements Function3Arg {
         }
 
         // Create an algorithm runner.
-        IDStarAlgorithm algorithm = null;
+        IDStarAlgorithm algorithm;
         switch(algoType) {
             case DGET: algorithm = new DGet(); break;
             case DMIN: algorithm = new DMin(); break;
@@ -97,7 +97,7 @@ public final class DStarRunner implements Function3Arg {
         // Iterate over all DB entries.
         final int height = db.getHeight();
         for(int row = 1; row < height; ++row) {
-            boolean matches = true;
+            boolean matches;
             try {
                 matches = fullfillsConditions(db, row, cdb);
             }
@@ -133,7 +133,7 @@ public final class DStarRunner implements Function3Arg {
      * @param nameValueEval Must not be a RefEval or AreaEval. Thus make sure resolveReference() is called on the value first!
      * @param db Database
      * @return Corresponding column number.
-     * @throws EvaluationException
+     * @throws EvaluationException If it's not possible to turn all headings into strings.
      */
     private static int getColumnForName(ValueEval nameValueEval, AreaEval db)
             throws EvaluationException {
@@ -193,7 +193,7 @@ public final class DStarRunner implements Function3Arg {
                 // Whether the condition column matches a database column, if not it's a
                 // special column that accepts formulas.
                 boolean columnCondition = true;
-                ValueEval condition = null;
+                ValueEval condition;
                 
                 // The condition to apply.
                 condition = resolveReference(cdb, conditionRow, column);
@@ -212,7 +212,7 @@ public final class DStarRunner implements Function3Arg {
                     // No column found, it's again a special column that accepts formulas.
                     columnCondition = false;
 
-                if(columnCondition == true) { // normal column condition
+                if(columnCondition) { // normal column condition
                     // Should not throw, checked above.
                     ValueEval value = resolveReference(db, row, getColumnForName(targetHeader, db));
                     if(!testNormalCondition(value, condition)) {
@@ -228,7 +228,7 @@ public final class DStarRunner implements Function3Arg {
                             "D* function with formula conditions");
                 }
             }
-            if (matches == true) {
+            if (matches) {
                 return true;
             }
         }
@@ -256,8 +256,7 @@ public final class DStarRunner implements Function3Arg {
                 } else {
                     return testNumericCondition(value, operator.smallerThan, number);
                 }
-            }
-            else if(conditionString.startsWith(">")) { // It's a >/>= condition.
+            } else if(conditionString.startsWith(">")) { // It's a >/>= condition.
                 String number = conditionString.substring(1);
                 if(number.startsWith("=")) {
                     number = number.substring(1);
@@ -265,15 +264,14 @@ public final class DStarRunner implements Function3Arg {
                 } else {
                     return testNumericCondition(value, operator.largerThan, number);
                 }
-            }
-            else if(conditionString.startsWith("=")) { // It's a = condition.
+            } else if(conditionString.startsWith("=")) { // It's a = condition.
                 String stringOrNumber = conditionString.substring(1);
 
                 if(stringOrNumber.isEmpty()) {
                     return value instanceof BlankEval;
                 }
                 // Distinguish between string and number.
-                boolean itsANumber = false;
+                boolean itsANumber;
                 try {
                     Integer.parseInt(stringOrNumber);
                     itsANumber = true;
@@ -300,25 +298,17 @@ public final class DStarRunner implements Function3Arg {
                     return valueString.startsWith(conditionString);
                 }
             }
-        }
-        else if(condition instanceof NumericValueEval) {
-            double conditionNumber = ((NumericValueEval)condition).getNumberValue();
+        } else if(condition instanceof NumericValueEval) {
+            double conditionNumber = ((NumericValueEval) condition).getNumberValue();
             Double valueNumber = getNumberFromValueEval(value);
-            if(valueNumber == null) {
-                return false;
-            }
-            
-            return conditionNumber == valueNumber;
-        }
-        else if(condition instanceof ErrorEval) {
+            return valueNumber != null && conditionNumber == valueNumber;
+        } else if(condition instanceof ErrorEval) {
             if(value instanceof ErrorEval) {
                 return ((ErrorEval)condition).getErrorCode() == ((ErrorEval)value).getErrorCode();
-            }
-            else {
+            } else {
                 return false;
             }
-        }
-        else {
+        } else {
             return false;
         }
     }
@@ -340,7 +330,7 @@ public final class DStarRunner implements Function3Arg {
         double value = ((NumericValueEval)valueEval).getNumberValue();
 
         // Construct double from condition.
-        double conditionValue = 0.0;
+        double conditionValue;
         try {
             conditionValue = Integer.parseInt(condition);
         } catch (NumberFormatException e) { // It's not an int.
index 0c7b81ada7181e5fc2434d24c5c45e6760f4518f..c5a6e15a512851f4ddb362d69111c352dbdd3cbc 100644 (file)
@@ -60,7 +60,7 @@ public class ImReal extends Fixed1ArgFunction implements FreeRefFunction {
         boolean result = m.matches();
 
         String real = "";
-        if (result == true) {
+        if (result) {
             String realGroup = m.group(2);
             boolean hasRealPart = realGroup.length() != 0;
 
index 4c8b82423e6ee9fca5be556596afc295b9dd224c..a0301072072660bea169815465a2087aea85eb89 100644 (file)
@@ -71,7 +71,7 @@ public class Imaginary extends Fixed1ArgFunction implements FreeRefFunction {
         boolean result = m.matches();
 
         String imaginary = "";
-        if (result == true) {
+        if (result) {
             String imaginaryGroup = m.group(5);
             boolean hasImaginaryPart = imaginaryGroup.equals("i") || imaginaryGroup.equals("j");
 
index 403877443764578f34f5c49534f0b752d7d898ba..f079e15c414e6a7d8bacbb1f85330804d6932730 100644 (file)
@@ -34,7 +34,7 @@ import org.apache.commons.math3.linear.MatrixUtils;
  */
 public abstract class MatrixFunction implements Function{
     
-    public static final void checkValues(double[] results) throws EvaluationException {
+    public static void checkValues(double[] results) throws EvaluationException {
         for (int idx = 0; idx < results.length; idx++) {
             if (Double.isNaN(results[idx]) || Double.isInfinite(results[idx])) {
                 throw new EvaluationException(ErrorEval.NUM_ERROR);
index 184ccdaa4eba33b9e0196f94c54b7337255d63b1..19278485559d44481903c605f124965056d67bf3 100644 (file)
@@ -30,7 +30,7 @@ public abstract class NumericFunction implements Function {
        static final double TEN = 10.0;
        static final double LOG_10_TO_BASE_e = Math.log(TEN);
 
-       protected static final double singleOperandEvaluate(ValueEval arg, int srcRowIndex, int srcColumnIndex) throws EvaluationException {
+       protected static double singleOperandEvaluate(ValueEval arg, int srcRowIndex, int srcColumnIndex) throws EvaluationException {
                if (arg == null) {
                        throw new IllegalArgumentException("arg must not be null");
                }
@@ -43,7 +43,7 @@ public abstract class NumericFunction implements Function {
        /**
         * @throws EvaluationException (#NUM!) if <tt>result</tt> is <tt>NaN</> or <tt>Infinity</tt>
         */
-       public static final void checkValue(double result) throws EvaluationException {
+       public static void checkValue(double result) throws EvaluationException {
                if (Double.isNaN(result) || Double.isInfinite(result)) {
                        throw new EvaluationException(ErrorEval.NUM_ERROR);
                }
index a9e8d5d78b35bdbf3d4f40cf54a4767a6ba6dec6..3b9de86dce45a287cb679f5aef6e211417b8b569 100644 (file)
@@ -115,7 +115,7 @@ public class Rate implements Function {
     * 
     * @throws EvaluationException (#NUM!) if <tt>result</tt> is <tt>NaN</> or <tt>Infinity</tt>
     */
-   static final void checkValue(double result) throws EvaluationException {
+   static void checkValue(double result) throws EvaluationException {
       if (Double.isNaN(result) || Double.isInfinite(result)) {
          throw new EvaluationException(ErrorEval.NUM_ERROR);
       }
index 1823698cda4a53b3e95f698313d1712feefb85bc..888868715789e01cff46f7d441306032034999af 100644 (file)
@@ -123,7 +123,7 @@ public abstract class AbstractFunctionPtg extends OperationPtg {
      * @return <code>true</code> if the name specifies a standard worksheet function,
      *  <code>false</code> if the name should be assumed to be an external function.
      */
-    public static final boolean isBuiltInFunctionName(String name) {
+    public static boolean isBuiltInFunctionName(String name) {
         short ix = FunctionMetadataRegistry.lookupIndexByName(name.toUpperCase(Locale.ROOT));
         return ix >= 0;
     }
index 66e8c2834435537335e38624cd33ef081b3353c1..7b557fd6587330e8144d959508b8784818f6e4ff 100644 (file)
@@ -693,7 +693,7 @@ public class DataFormatter implements Observer {
         private BigDecimal divider;
         private static final BigDecimal ONE_THOUSAND = new BigDecimal(1000);
         private final DecimalFormat df;
-        private static final String trimTrailingCommas(String s) {
+        private static String trimTrailingCommas(String s) {
             return s.replaceAll(",+$", "");
         }
 
index 2ce1e44fe244c17b02294ac6e5b315eb99e02b0d..996861e75ad1b1bc0f94a79e9f90449725ad59d9 100644 (file)
@@ -158,7 +158,7 @@ public enum FormulaError {
         }
     }
     
-    public static final boolean isValidCode(int errorCode) {
+    public static boolean isValidCode(int errorCode) {
         for (FormulaError error : values()) {
             if (error.getCode() == errorCode) return true;
             if (error.getLongCode() == errorCode) return true;
index 9dc0c6096f3e1158a4dd7063511709b23e1830e2..32fdb134a3a60d9c9fd32ea423377a7992314e71 100644 (file)
@@ -98,8 +98,8 @@ public class SheetBuilder {
      */
     public Sheet build() {
         Sheet sheet = (sheetName == null) ? workbook.createSheet() : workbook.createSheet(sheetName);
-        Row currentRow = null;
-        Cell currentCell = null;
+        Row currentRow;
+        Cell currentCell;
 
         for (int rowIndex = 0; rowIndex < cells.length; ++rowIndex) {
             Object[] rowArray = cells[rowIndex];
@@ -125,7 +125,9 @@ public class SheetBuilder {
     private void setCellValue(Cell cell, Object value) {
         if (value == null || cell == null) {
             return;
-        } else if (value instanceof Number) {
+        }
+
+        if (value instanceof Number) {
             double doubleValue = ((Number) value).doubleValue();
             cell.setCellValue(doubleValue);
         } else if (value instanceof Date) {
@@ -142,11 +144,7 @@ public class SheetBuilder {
     private boolean isFormulaDefinition(Object obj) {
         if (obj instanceof String) {
             String str = (String) obj;
-            if (str.length() < 2) {
-                return false;
-            } else {
-                return ((String) obj).charAt(0) == '=';
-            }
+            return str.length() >= 2 && str.charAt(0) == '=';
         } else {
             return false;
         }
@@ -155,4 +153,4 @@ public class SheetBuilder {
     private String getFormula(Object obj) {
         return ((String) obj).substring(1);
     }
-}
\ No newline at end of file
+}
index 012312a9c649a88bab9b71262d410a47f0c5af7a..8475a0d53c2cfa18b696cebad483ecac5c7622c0 100644 (file)
@@ -41,7 +41,7 @@ public class WorkbookUtil {
         *        allowed to be null
         * @return a valid string, "empty" if to short, "null" if null         
         */
-       public final static String createSafeSheetName(final String nameProposal) {
+       public static String createSafeSheetName(final String nameProposal) {
                return createSafeSheetName(nameProposal, ' ');
        }
 
@@ -64,7 +64,7 @@ public class WorkbookUtil {
      * @param replaceChar the char to replace invalid characters.
      * @return a valid string, "empty" if to short, "null" if null
      */
-    public final static String createSafeSheetName(final String nameProposal, char replaceChar) {
+    public static String createSafeSheetName(final String nameProposal, char replaceChar) {
         if (nameProposal == null) {
             return "null";
         }
index fa3d608c0ad55315586da31bb09cfcf79d7f0ad8..fedd27acac26067b9c10976dc1aace276053b4c4 100644 (file)
@@ -141,20 +141,14 @@ public class POIXMLTypeLoader {
     }
 
     public static XmlObject parse(File file, SchemaType type, XmlOptions options) throws XmlException, IOException {
-        InputStream is = new FileInputStream(file);
-        try {
+        try (InputStream is = new FileInputStream(file)) {
             return parse(is, type, options);
-        } finally {
-            is.close();
         }
     }
 
     public static XmlObject parse(URL file, SchemaType type, XmlOptions options) throws XmlException, IOException {
-        InputStream is = file.openStream();
-        try {
+        try (InputStream is = file.openStream()) {
             return parse(is, type, options);
-        } finally {
-            is.close();
         }
     }
 
index 8cd1c9f5de0763d7c580b4def00c560d8604373f..09fb30f70bede63db424f4dc48d9f7edcf9af97e 100644 (file)
@@ -22,7 +22,6 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.net.URI;
 import java.net.URISyntaxException;
-import java.util.HashMap;
 
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
index ca89ba4c9959cc4fe5bceba6cb7d9da1a0dff7fa..aa40675322d08a70134c718be4a6cd06b65590f3 100644 (file)
@@ -109,7 +109,7 @@ public class RevocationData {
      * responses.
      */
     public boolean hasOCSPs() {
-        return false == this.ocsps.isEmpty();
+        return !this.ocsps.isEmpty();
     }
 
     /**
@@ -118,7 +118,7 @@ public class RevocationData {
      * @return <code>true</code> if this revocation data set holds CRLs.
      */
     public boolean hasCRLs() {
-        return false == this.crls.isEmpty();
+        return !this.crls.isEmpty();
     }
 
     /**
index f997c3b0fd732993542d927360b9cda9d211df58..607c5bb1508dd6642e7d4538eb71d9570bd17ba1 100644 (file)
@@ -819,7 +819,7 @@ public class XDGFShape extends XDGFSheet {
      */
     public Path2D.Double getPath() {
         for (GeometrySection geoSection : getGeometrySections()) {
-            if (geoSection.getNoShow() == true)
+            if (geoSection.getNoShow())
                 continue;
 
             return geoSection.getPath(this);
@@ -833,7 +833,7 @@ public class XDGFShape extends XDGFSheet {
      */
     public boolean hasGeometry() {
         for (GeometrySection geoSection : getGeometrySections()) {
-            if (geoSection.getNoShow() == false)
+            if (!geoSection.getNoShow())
                 return true;
         }
         return false;
index 8124ccff1c23c440c86ebaff2cca9e3da5a7193e..ea533600840cbe234585b9b7862bc31be3b79675 100644 (file)
@@ -96,7 +96,7 @@ public class XSLFTextRun implements TextRun {
 
         String txt = ((CTRegularTextRun)_r).getT();
         TextCap cap = getTextCap();
-        StringBuffer buf = new StringBuffer();
+        StringBuilder buf = new StringBuilder();
         for(int i = 0; i < txt.length(); i++) {
             char c = txt.charAt(i);
             if(c == '\t') {
@@ -123,10 +123,7 @@ public class XSLFTextRun implements TextRun {
     public void setText(String text){
         if (_r instanceof CTTextField) {
             ((CTTextField)_r).setT(text);
-        } else if (_r instanceof CTTextLineBreak) {
-            // ignored
-            return;
-        } else {
+        } else if (!(_r instanceof CTTextLineBreak)) {
             ((CTRegularTextRun)_r).setT(text);
         }
     }
index 440aaf69b74d8329742e98022ad964085c1d400e..84a5e916b3f42bb250f029e19d24d1935209ef60 100644 (file)
@@ -369,7 +369,7 @@ public enum XSSFBuiltinTableStyle {
      * Public so clients can initialize the map on startup rather than lazily
      * during evaluation if desired.
      */
-    public static final synchronized void init() {
+    public static synchronized void init() {
         if (! styleMap.isEmpty()) return; 
         
         /*
index a2e95c3ea7c677feeb87a874642bc693f5a6ad53..20c6e9264224fd34533e9c332f109a569104bdd8 100644 (file)
@@ -158,7 +158,6 @@ public final class XSSFGraphicFrame extends XSSFShape {
                CTGraphicalObjectData data = graphicFrame.getGraphic().addNewGraphicData();
                appendChartElement(data, relId);
                chart.setGraphicFrame(this);
-               return;
        }
 
        /**
index 904fb3845dda4ffb3ac88fd3f7e187b85e71b0f6..7cea879cbc3d17cc002e81f16fa1107e14d9db21 100644 (file)
@@ -242,10 +242,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
         // Get the hyperlinks
         // TODO: make me optional/separated in private function
         try {
-            Iterator<PackageRelationship> relIter =
-                    getPackagePart().getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation()).iterator();
-            while (relIter.hasNext()) {
-                PackageRelationship rel = relIter.next();
+            for (PackageRelationship rel : getPackagePart().getRelationshipsByType(XWPFRelation.HYPERLINK.getRelation())) {
                 hyperlinks.add(new XWPFHyperlink(rel.getId(), rel.getTargetURI().toString()));
             }
         } catch (InvalidFormatException e) {
@@ -453,7 +450,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
         // TODO this needs to be migrated out into section code
         if (type == HeaderFooterType.FIRST) {
             CTSectPr ctSectPr = getSection();
-            if (ctSectPr.isSetTitlePg() == false) {
+            if (!ctSectPr.isSetTitlePg()) {
                 CTOnOff titlePg = ctSectPr.addNewTitlePg();
                 titlePg.setVal(STOnOff.ON);
             }
@@ -475,7 +472,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
         // TODO this needs to be migrated out into section code
         if (type == HeaderFooterType.FIRST) {
             CTSectPr ctSectPr = getSection();
-            if (ctSectPr.isSetTitlePg() == false) {
+            if (!ctSectPr.isSetTitlePg()) {
                 CTOnOff titlePg = ctSectPr.addNewTitlePg();
                 titlePg.setVal(STOnOff.ON);
             }
@@ -600,7 +597,7 @@ public class XWPFDocument extends POIXMLDocument implements Document, IBody {
      * parameter points to the {@link org.apache.xmlbeans.XmlCursor.TokenType#END}
      * of the newly inserted paragraph.
      *
-     * @param cursor
+     * @param cursor The cursor-position where the new paragraph should be added.
      * @return the {@link XWPFParagraph} object representing the newly inserted
      * CTP object
      */
index 185e453aa050994d91d7dc65db05a0b1c036f134..587674edc3d66de9b955c74ce06d2d54a9301210 100644 (file)
@@ -98,7 +98,7 @@ public class XWPFSDTContent implements ISDTContent {
                 text.append(o);
                 addNewLine = false;
             }
-            if (addNewLine == true && i < bodyElements.size() - 1) {
+            if (addNewLine && i < bodyElements.size() - 1) {
                 text.append("\n");
             }
         }
index 652d40fbcb32011eb8d594ee2634846580e5477b..8cbdfe270d6646895086d98b2cd518a6d5ba278a 100644 (file)
@@ -207,10 +207,10 @@ public final class TestStylesTable {
         }
     }
     
-    private static final <K,V> void assertNotContainsKey(Map<K,V> map, K key) {
+    private static <K,V> void assertNotContainsKey(Map<K,V> map, K key) {
         assertFalse(map.containsKey(key));
     }
-    private static final <K,V> void assertNotContainsValue(Map<K,V> map, V value) {
+    private static <K,V> void assertNotContainsValue(Map<K,V> map, V value) {
         assertFalse(map.containsValue(value));
     }
     
index d4bf8ab3378cb5b564270d14769c659ba05c8507..a714f1950b2e1467d8183c626641c544e8b2748c 100644 (file)
@@ -86,8 +86,9 @@ public abstract class RecordContainer extends Record
        /**
         * Adds the given new Child Record at the given location,
         *  shuffling everything from there on down by one
-        * @param newChild
-        * @param position
+        *
+        * @param newChild The record to be added as child-record.
+        * @param position The index where the child should be added, 0-based
         */
        private void addChildAt(Record newChild, int position) {
                // Firstly, have the child added in at the end
@@ -168,8 +169,8 @@ public abstract class RecordContainer extends Record
 
        /**
         * Adds the given Child Record after the supplied record
-        * @param newChild
-        * @param after
+        * @param newChild The record to add as new child.
+        * @param after The record after which the given record should be added.
         * @return the position of the added child within the list
         */
        public int addChildAfter(Record newChild, Record after) {
@@ -186,8 +187,8 @@ public abstract class RecordContainer extends Record
 
        /**
         * Adds the given Child Record before the supplied record
-        * @param newChild
-        * @param before
+        * @param newChild The record to add as new child.
+        * @param before The record before which the given record should be added.
      * @return the position of the added child within the list
         */
        public int addChildBefore(Record newChild, Record before) {
@@ -309,8 +310,8 @@ public abstract class RecordContainer extends Record
                        mout.write(new byte[4]);
 
                        // Write out the children
-                       for(int i=0; i<children.length; i++) {
-                               children[i].writeOut(mout);
+                       for (Record aChildren : children) {
+                               aChildren.writeOut(mout);
                        }
 
                        // Update our header with the size
@@ -335,8 +336,8 @@ public abstract class RecordContainer extends Record
                        baos.write(new byte[] {0,0,0,0});
 
                        // Write out our children
-                       for(int i=0; i<children.length; i++) {
-                               children[i].writeOut(baos);
+                       for (Record aChildren : children) {
+                               aChildren.writeOut(baos);
                        }
 
                        // Grab the bytes back
index 1dde0d03d490874d0a6be053a6d01746e6eb24f4..5eb222b9007712eff086809200fbdfab6a9c61c0 100644 (file)
@@ -169,7 +169,7 @@ public final class HSLFSlideShowImpl extends POIDocument implements Closeable {
     /**
      * Constructs a new, empty, Powerpoint document.
      */
-    public static final HSLFSlideShowImpl create() {
+    public static HSLFSlideShowImpl create() {
         InputStream is = HSLFSlideShowImpl.class.getResourceAsStream("/org/apache/poi/hslf/data/empty.ppt");
         if (is == null) {
             throw new HSLFException("Missing resource 'empty.ppt'");
index 1f4505613d7540a162ad2f7a5a5b4eb0bc1df52a..ce10b6dab8030773c9bf0d969b9d162cfe3530f8 100644 (file)
@@ -100,7 +100,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
     * Constructor for reading MSG Files from the file system.
     * 
     * @param filename Name of the file to read
-    * @throws IOException
+    * @exception IOException on errors reading, or invalid data
     */
    public MAPIMessage(String filename) throws IOException {
       this(new File(filename));
@@ -109,7 +109,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
     * Constructor for reading MSG Files from the file system.
     * 
     * @param file The file to read from
-    * @throws IOException
+    * @exception IOException on errors reading, or invalid data
     */
    public MAPIMessage(File file) throws IOException {
       this(new NPOIFSFileSystem(file));
@@ -122,7 +122,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
     *  in order to process. For lower memory use, use {@link #MAPIMessage(File)}
     *  
     * @param in The InputStream to buffer then read from
-    * @throws IOException
+    * @exception IOException on errors reading, or invalid data
     */
    public MAPIMessage(InputStream in) throws IOException {
       this(new NPOIFSFileSystem(in));
@@ -131,7 +131,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
     * Constructor for reading MSG Files from a POIFS filesystem
     * 
     * @param fs Open POIFS FileSystem containing the message
-    * @throws IOException
+    * @exception IOException on errors reading, or invalid data
     */
    public MAPIMessage(NPOIFSFileSystem fs) throws IOException {
       this(fs.getRoot());
@@ -140,7 +140,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
     * Constructor for reading MSG Files from a certain
     *  point within a POIFS filesystem
     * @param poifsDir Directory containing the message
-    * @throws IOException
+    * @exception IOException on errors reading, or invalid data
     */
    public MAPIMessage(DirectoryNode poifsDir) throws IOException {
       super(poifsDir);
@@ -195,7 +195,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
    /**
     * Gets the plain text body of this Outlook Message
     * @return The string representation of the 'text' version of the body, if available.
-    * @throws ChunkNotFoundException
+    * @throws ChunkNotFoundException If the text-body chunk does not exist and
+    *       returnNullOnMissingChunk is set
     */
    public String getTextBody() throws ChunkNotFoundException {
       return getStringFromChunk(mainChunks.getTextBodyChunk());
@@ -205,7 +206,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
     * Gets the html body of this Outlook Message, if this email
     *  contains a html version.
     * @return The string representation of the 'html' version of the body, if available.
-    * @throws ChunkNotFoundException
+    * @throws ChunkNotFoundException If the html-body chunk does not exist and
+    *       returnNullOnMissingChunk is set
     */
    public String getHtmlBody() throws ChunkNotFoundException {
       if(mainChunks.getHtmlBodyChunkBinary() != null) {
@@ -218,7 +220,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
     * Gets the RTF Rich Message body of this Outlook Message, if this email
     *  contains a RTF (rich) version.
     * @return The string representation of the 'RTF' version of the body, if available.
-    * @throws ChunkNotFoundException
+    * @throws ChunkNotFoundException If the rtf-body chunk does not exist and
+    *       returnNullOnMissingChunk is set
     */
    public String getRtfBody() throws ChunkNotFoundException {
       ByteChunk chunk = mainChunks.getRtfBodyChunk();
@@ -242,7 +245,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
 
    /**
     * Gets the subject line of the Outlook Message
-    * @throws ChunkNotFoundException
+    * @throws ChunkNotFoundException If the subject-chunk does not exist and
+    *       returnNullOnMissingChunk is set
     */
    public String getSubject() throws ChunkNotFoundException {
       return getStringFromChunk(mainChunks.getSubjectChunk());
@@ -251,7 +255,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
    /**
     * Gets the display value of the "FROM" line of the outlook message
     * This is not the actual address that was sent from but the formated display of the user name.
-    * @throws ChunkNotFoundException
+    * @throws ChunkNotFoundException If the from-chunk does not exist and
+    *       returnNullOnMissingChunk is set
     */
    public String getDisplayFrom() throws ChunkNotFoundException {
       return getStringFromChunk(mainChunks.getDisplayFromChunk());
@@ -264,7 +269,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
     * This is not the actual list of addresses/values that will be 
     *  sent to if you click Reply in the email - those are stored
     *  in {@link RecipientChunks}.
-    * @throws ChunkNotFoundException
+    * @throws ChunkNotFoundException If the to-chunk does not exist and
+    *       returnNullOnMissingChunk is set
     */
    public String getDisplayTo() throws ChunkNotFoundException {
       return getStringFromChunk(mainChunks.getDisplayToChunk());
@@ -277,7 +283,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
     * This is not the actual list of addresses/values that will be 
     *  sent to if you click Reply in the email - those are stored
     *  in {@link RecipientChunks}.
-    * @throws ChunkNotFoundException
+    * @throws ChunkNotFoundException If the cc-chunk does not exist and
+    *       returnNullOnMissingChunk is set
     */
    public String getDisplayCC() throws ChunkNotFoundException {
       return getStringFromChunk(mainChunks.getDisplayCCChunk());
@@ -291,7 +298,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
     *  sent to if you click Reply in the email - those are stored
     *  in {@link RecipientChunks}.
     * This will only be present in sent emails, not received ones!
-    * @throws ChunkNotFoundException
+    * @throws ChunkNotFoundException If the bcc-chunk does not exist and
+    *       returnNullOnMissingChunk is set
     */
    public String getDisplayBCC() throws ChunkNotFoundException {
       return getStringFromChunk(mainChunks.getDisplayBCCChunk());
@@ -440,7 +448,6 @@ public class MAPIMessage extends POIReadOnlyDocument {
                // Found it! Tell all the string chunks
                String charset = m.group(1);
                set7BitEncoding(charset);
-               return;
             }
          }
       } catch(ChunkNotFoundException e) {}
@@ -529,7 +536,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
    /**
     * Gets the conversation topic of the parsed Outlook Message.
     * This is the part of the subject line that is after the RE: and FWD:
-    * @throws ChunkNotFoundException
+    * @throws ChunkNotFoundException If the conversation-topic chunk does not exist and
+    *       returnNullOnMissingChunk is set
     */
    public String getConversationTopic() throws ChunkNotFoundException {
       return getStringFromChunk(mainChunks.getConversationTopic());
@@ -541,7 +549,8 @@ public class MAPIMessage extends POIReadOnlyDocument {
     *  item, note, or actual outlook Message)
     * For emails the class will be IPM.Note
     *
-    * @throws ChunkNotFoundException
+    * @throws ChunkNotFoundException If the message-class chunk does not exist and
+    *       returnNullOnMissingChunk is set
     */
    public MESSAGE_CLASS getMessageClassEnum() throws ChunkNotFoundException {
       String mc = getStringFromChunk(mainChunks.getMessageClass());
@@ -643,7 +652,7 @@ public class MAPIMessage extends POIReadOnlyDocument {
 
 
    private String toSemicolonList(String[] l) {
-      StringBuffer list = new StringBuffer();
+      StringBuilder list = new StringBuilder();
       boolean first = true;
 
       for(String s : l) {
index b3f3cf5c5cc9050b3f4c3af1a3d4920e52a3428d..dacf09ed27d4961cd72f624b07683bbc0e35e822 100644 (file)
@@ -207,9 +207,9 @@ public final class Chunks implements ChunkGroupWithProperties {
             conversationTopic = (StringChunk) chunk;
         } else if (prop == MAPIProperty.SUBJECT) {
             subjectChunk = (StringChunk) chunk;
-        } else if (prop == MAPIProperty.ORIGINAL_SUBJECT) {
+        } /*else if (prop == MAPIProperty.ORIGINAL_SUBJECT) {
             // TODO
-        }
+        }*/
 
         else if (prop == MAPIProperty.DISPLAY_TO) {
             displayToChunk = (StringChunk) chunk;
index b5ec864ff19215eb8cf32fc1fdc573e77c08f343..d43266b40e62685bd10f0a900fcf94a45d4d8a7b 100644 (file)
@@ -691,8 +691,6 @@ public abstract class AbstractWordConverter
         if ( separatorMark + 1 < endMark )
             processCharacters( wordDocument, currentTableLevel,
                     deadFieldValueSubrage, currentBlock );
-
-        return;
     }
 
     public void processDocument( HWPFDocumentCore wordDocument )
@@ -1106,7 +1104,7 @@ public abstract class AbstractWordConverter
                 }
             }
 
-            if ( processed == false )
+            if (!processed)
             {
                 processParagraph( wordDocument, flow, currentTableLevel,
                         paragraph, AbstractWordUtils.EMPTY );
index 7ce31b13a5f93b1ee2b19b3bb7823b2d4c4e6b83..e050cfa59a279ff17ae844f90a371f22a1720a0d 100644 (file)
@@ -462,7 +462,6 @@ public class WordToFoConverter extends AbstractWordConverter
         }
 
         WordToFoUtils.compactInlines( block );
-        return;
     }
 
     protected void processSection( HWPFDocumentCore wordDocument,
index 3ea2c596a0b00021b9c5c7ce13313c58c2a0c97a..38c45361b088f00e923af18bd7f3516e2157f6ff 100644 (file)
@@ -202,11 +202,11 @@ public class WordToHtmlConverter extends AbstractWordConverter
                 && !AbstractWordUtils.equals( triplet.fontName,
                         blockProperies.pFontName ) )
         {
-            style.append( "font-family:" + triplet.fontName + ";" );
+            style.append("font-family:").append(triplet.fontName).append(";");
         }
         if ( characterRun.getFontSize() / 2 != blockProperies.pFontSize )
         {
-            style.append( "font-size:" + characterRun.getFontSize() / 2 + "pt;" );
+            style.append("font-size:").append(characterRun.getFontSize() / 2).append("pt;");
         }
         if ( triplet.bold )
         {
@@ -593,7 +593,6 @@ public class WordToHtmlConverter extends AbstractWordConverter
         }
 
         WordToHtmlUtils.compactSpans( pElement );
-        return;
     }
 
     @Override
index e57118b835979baca1899ceda0d66352459cb21b..bf66cecef449efd58a41ddf5e7b1e6a935190dcc 100644 (file)
@@ -42,7 +42,7 @@ import org.junit.After;
  * Testing for {@link HSSFEventFactory}
  */
 public final class TestHSSFEventFactory extends TestCase {
-    private static final InputStream openSample(String sampleFileName) {
+    private static InputStream openSample(String sampleFileName) {
         return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
     }
 
index 2f6a14b76910fb9e5c08c70f6bddb4b9d4968f38..e0d14b8da95c0f1ae2e8d9c5abcd0d377501b770 100644 (file)
@@ -184,7 +184,7 @@ public final class TestFormulaRecord extends TestCase {
 
                fr0.setCachedResultBoolean(false);
                fr1.setCachedResultBoolean(true);
-               if (fr0.getCachedBooleanValue() == true && fr1.getCachedBooleanValue() == false) {
+               if (fr0.getCachedBooleanValue() && !fr1.getCachedBooleanValue()) {
                        throw new AssertionFailedError("Identified bug 46479c");
                }
                assertEquals(false, fr0.getCachedBooleanValue());
index cb156728eb776102c359c7e6bf986ae4bb76e646..cb61e98ed8faf294c39c57159c59402f9694091b 100644 (file)
@@ -34,10 +34,10 @@ import org.apache.poi.hssf.OldExcelFormatException;
  *  checks 
  */
 public class TestNotOLE2Exception extends TestCase {
-       private static final InputStream openXLSSampleStream(String sampleFileName) {
+       private static InputStream openXLSSampleStream(String sampleFileName) {
                return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
        }
-    private static final InputStream openDOCSampleStream(String sampleFileName) {
+    private static InputStream openDOCSampleStream(String sampleFileName) {
         return POIDataSamples.getDocumentInstance().openResourceAsStream(sampleFileName);
     }
     
index e78e19f37560b396ba617e3bf3093a1afb6e724a..8b53738030ca921b2f9cdb702dcd74d637d46026 100644 (file)
@@ -34,7 +34,7 @@ import junit.framework.TestCase;
  */
 public class TestOfficeXMLException extends TestCase {
 
-       private static final InputStream openSampleStream(String sampleFileName) {
+       private static InputStream openSampleStream(String sampleFileName) {
                return HSSFTestDataSamples.openSampleFileStream(sampleFileName);
        }
        public void testOOXMLException() throws IOException
index 804fcb20fcc437176963e152e86fd8938e5ac441..3b9a53ff48a188d08a2e082c801c05dddd79dc65 100644 (file)
@@ -108,15 +108,11 @@ public class TestForkedEvaluator {
        public void testMissingInputCellH() throws IOException {
            expectedEx.expect(UnsupportedOperationException.class);
            expectedEx.expectMessage("Underlying cell 'A2' is missing in master sheet.");
-           
-               Workbook wb = createWorkbook();
 
-               try {
-               ForkedEvaluator fe = ForkedEvaluator.create(wb, null, null);
-               // attempt update input at cell A2 (which is missing)
-            fe.updateCell("Inputs", 1, 0, new NumberEval(4.0));
-               } finally {
-                   wb.close();
+               try (Workbook wb = createWorkbook()) {
+                       ForkedEvaluator fe = ForkedEvaluator.create(wb, null, null);
+                       // attempt update input at cell A2 (which is missing)
+                       fe.updateCell("Inputs", 1, 0, new NumberEval(4.0));
                }
        }
 }
index 202a9e06c7a3b6e3afb601f3b236820d269410da..1e4abfae085277996a422f7ffb5798c9355acc6e 100644 (file)
@@ -36,14 +36,14 @@ public abstract class AbstractPtgTestCase extends TestCase {
      * @param sampleFileName the filename.
      * @return the loaded workbook.
      */
-    protected static final HSSFWorkbook loadWorkbook(String sampleFileName) {
+    protected static HSSFWorkbook loadWorkbook(String sampleFileName) {
         return HSSFTestDataSamples.openSampleWorkbook(sampleFileName);
     }
 
     /**
      * Creates a new Workbook and adds one sheet with the specified name
      */
-    protected static final HSSFWorkbook createWorkbookWithSheet(String sheetName) {
+    protected static HSSFWorkbook createWorkbookWithSheet(String sheetName) {
         HSSFWorkbook book = new HSSFWorkbook();
         book.createSheet(sheetName);
         return book;