aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi/hssf
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2017-09-17 11:08:23 +0000
committerDominik Stadler <centic@apache.org>2017-09-17 11:08:23 +0000
commit467053d91cf5ec1d48cfa979f82032ca7267f441 (patch)
tree9a3e8f3de0249ac1a8b5eec1defae2f8947fa880 /src/java/org/apache/poi/hssf
parentec42ec1053cdd849923bcbc0ad99ec0613a34af5 (diff)
downloadpoi-467053d91cf5ec1d48cfa979f82032ca7267f441.tar.gz
poi-467053d91cf5ec1d48cfa979f82032ca7267f441.zip
Various code cleanups, "final" for static methods is useless, for-loops, simplify boolean conditions, try-with-resource, javadoc, ...
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1808620 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/hssf')
-rw-r--r--src/java/org/apache/poi/hssf/record/CFHeaderBase.java10
-rw-r--r--src/java/org/apache/poi/hssf/record/ExtSSTRecord.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/GridsetRecord.java32
-rw-r--r--src/java/org/apache/poi/hssf/record/HCenterRecord.java30
-rw-r--r--src/java/org/apache/poi/hssf/record/NameRecord.java2
-rw-r--r--src/java/org/apache/poi/hssf/record/PrecisionRecord.java36
-rw-r--r--src/java/org/apache/poi/hssf/record/PrintGridlinesRecord.java37
-rw-r--r--src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java36
-rw-r--r--src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java28
-rw-r--r--src/java/org/apache/poi/hssf/util/HSSFColor.java4
10 files changed, 67 insertions, 152 deletions
diff --git a/src/java/org/apache/poi/hssf/record/CFHeaderBase.java b/src/java/org/apache/poi/hssf/record/CFHeaderBase.java
index 015917e25e..f4c1fbe87f 100644
--- a/src/java/org/apache/poi/hssf/record/CFHeaderBase.java
+++ b/src/java/org/apache/poi/hssf/record/CFHeaderBase.java
@@ -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");
diff --git a/src/java/org/apache/poi/hssf/record/ExtSSTRecord.java b/src/java/org/apache/poi/hssf/record/ExtSSTRecord.java
index 8660d97895..e0b975d088 100644
--- a/src/java/org/apache/poi/hssf/record/ExtSSTRecord.java
+++ b/src/java/org/apache/poi/hssf/record/ExtSSTRecord.java
@@ -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;
}
diff --git a/src/java/org/apache/poi/hssf/record/GridsetRecord.java b/src/java/org/apache/poi/hssf/record/GridsetRecord.java
index 14f04ab2ab..570ebe2867 100644
--- a/src/java/org/apache/poi/hssf/record/GridsetRecord.java
+++ b/src/java/org/apache/poi/hssf/record/GridsetRecord.java
@@ -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) {
diff --git a/src/java/org/apache/poi/hssf/record/HCenterRecord.java b/src/java/org/apache/poi/hssf/record/HCenterRecord.java
index 604ddeae28..d050823a6f 100644
--- a/src/java/org/apache/poi/hssf/record/HCenterRecord.java
+++ b/src/java/org/apache/poi/hssf/record/HCenterRecord.java
@@ -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) {
diff --git a/src/java/org/apache/poi/hssf/record/NameRecord.java b/src/java/org/apache/poi/hssf/record/NameRecord.java
index 050745b259..e4331c00f5 100644
--- a/src/java/org/apache/poi/hssf/record/NameRecord.java
+++ b/src/java/org/apache/poi/hssf/record/NameRecord.java
@@ -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;
}
}
diff --git a/src/java/org/apache/poi/hssf/record/PrecisionRecord.java b/src/java/org/apache/poi/hssf/record/PrecisionRecord.java
index 0dede18379..74bf8cf916 100644
--- a/src/java/org/apache/poi/hssf/record/PrecisionRecord.java
+++ b/src/java/org/apache/poi/hssf/record/PrecisionRecord.java
@@ -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) {
diff --git a/src/java/org/apache/poi/hssf/record/PrintGridlinesRecord.java b/src/java/org/apache/poi/hssf/record/PrintGridlinesRecord.java
index b22e244853..2563f34326 100644
--- a/src/java/org/apache/poi/hssf/record/PrintGridlinesRecord.java
+++ b/src/java/org/apache/poi/hssf/record/PrintGridlinesRecord.java
@@ -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) {
diff --git a/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java b/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java
index f2287ee6fc..607c4a8b7c 100644
--- a/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java
+++ b/src/java/org/apache/poi/hssf/record/PrintHeadersRecord.java
@@ -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) {
diff --git a/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java b/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java
index 96cfde27c7..05c66f78f0 100644
--- a/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java
+++ b/src/java/org/apache/poi/hssf/record/SaveRecalcRecord.java
@@ -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) {
diff --git a/src/java/org/apache/poi/hssf/util/HSSFColor.java b/src/java/org/apache/poi/hssf/util/HSSFColor.java
index 1490abf791..3c0ba6a9ce 100644
--- a/src/java/org/apache/poi/hssf/util/HSSFColor.java
+++ b/src/java/org/apache/poi/hssf/util/HSSFColor.java
@@ -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();
}