aboutsummaryrefslogtreecommitdiffstats
path: root/src/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java')
-rw-r--r--src/java/org/apache/poi/ddf/EscherChildAnchorRecord.java2
-rw-r--r--src/java/org/apache/poi/ddf/EscherDgRecord.java2
-rw-r--r--src/java/org/apache/poi/ddf/EscherSpRecord.java2
-rw-r--r--src/java/org/apache/poi/hpsf/CustomProperties.java14
-rw-r--r--src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java2
-rw-r--r--src/java/org/apache/poi/hpsf/MutableSection.java2
-rw-r--r--src/java/org/apache/poi/hpsf/Section.java2
-rw-r--r--src/java/org/apache/poi/hpsf/Variant.java100
-rw-r--r--src/java/org/apache/poi/hpsf/extractor/HPSFPropertiesExtractor.java23
-rw-r--r--src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java4
-rw-r--r--src/java/org/apache/poi/hssf/dev/ReSave.java41
-rw-r--r--src/java/org/apache/poi/hssf/model/DrawingManager2.java4
-rw-r--r--src/java/org/apache/poi/hssf/model/RecordStream.java4
-rw-r--r--src/java/org/apache/poi/hssf/record/TextObjectRecord.java2
-rw-r--r--src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java30
-rw-r--r--src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java12
-rw-r--r--src/java/org/apache/poi/hssf/record/aggregates/DataValidityTable.java11
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/DVConstraint.java12
-rw-r--r--src/java/org/apache/poi/ss/formula/constant/ErrorConstant.java21
-rw-r--r--src/java/org/apache/poi/ss/formula/eval/ErrorEval.java7
-rw-r--r--src/java/org/apache/poi/ss/formula/ptg/ErrPtg.java7
-rw-r--r--src/java/org/apache/poi/ss/util/AreaReference.java13
-rw-r--r--src/java/org/apache/poi/ss/util/CellRangeAddressList.java12
-rw-r--r--src/java/org/apache/poi/util/BinaryTree.java1
24 files changed, 189 insertions, 141 deletions
diff --git a/src/java/org/apache/poi/ddf/EscherChildAnchorRecord.java b/src/java/org/apache/poi/ddf/EscherChildAnchorRecord.java
index 6aa0efde93..b6193cea4e 100644
--- a/src/java/org/apache/poi/ddf/EscherChildAnchorRecord.java
+++ b/src/java/org/apache/poi/ddf/EscherChildAnchorRecord.java
@@ -40,7 +40,7 @@ public class EscherChildAnchorRecord
private int field_4_dy2;
public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
- int bytesRemaining = readHeader( data, offset );
+ /*int bytesRemaining =*/ readHeader( data, offset );
int pos = offset + 8;
int size = 0;
field_1_dx1 = LittleEndian.getInt( data, pos + size );size+=4;
diff --git a/src/java/org/apache/poi/ddf/EscherDgRecord.java b/src/java/org/apache/poi/ddf/EscherDgRecord.java
index a4447dc016..c269ad4461 100644
--- a/src/java/org/apache/poi/ddf/EscherDgRecord.java
+++ b/src/java/org/apache/poi/ddf/EscherDgRecord.java
@@ -37,7 +37,7 @@ public class EscherDgRecord
private int field_2_lastMSOSPID;
public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
- int bytesRemaining = readHeader( data, offset );
+ /*int bytesRemaining =*/ readHeader( data, offset );
int pos = offset + 8;
int size = 0;
field_1_numShapes = LittleEndian.getInt( data, pos + size ); size += 4;
diff --git a/src/java/org/apache/poi/ddf/EscherSpRecord.java b/src/java/org/apache/poi/ddf/EscherSpRecord.java
index 7d4dd5cfba..870bf575e1 100644
--- a/src/java/org/apache/poi/ddf/EscherSpRecord.java
+++ b/src/java/org/apache/poi/ddf/EscherSpRecord.java
@@ -49,7 +49,7 @@ public class EscherSpRecord
private int field_2_flags;
public int fillFields(byte[] data, int offset, EscherRecordFactory recordFactory) {
- int bytesRemaining = readHeader( data, offset );
+ /*int bytesRemaining =*/ readHeader( data, offset );
int pos = offset + 8;
int size = 0;
field_1_shapeId = LittleEndian.getInt( data, pos + size ); size += 4;
diff --git a/src/java/org/apache/poi/hpsf/CustomProperties.java b/src/java/org/apache/poi/hpsf/CustomProperties.java
index 83858eb736..9642e0dbcf 100644
--- a/src/java/org/apache/poi/hpsf/CustomProperties.java
+++ b/src/java/org/apache/poi/hpsf/CustomProperties.java
@@ -131,7 +131,7 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
final String name = customProperty.getName();
/* Check whether a property with this name is in the map already. */
- final Long oldId = (Long) dictionaryNameToID.get(name);
+ final Long oldId = dictionaryNameToID.get(name);
if (oldId != null)
customProperty.setID(oldId.longValue());
else
@@ -159,7 +159,7 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
*/
public Object remove(final String name)
{
- final Long id = (Long) dictionaryNameToID.get(name);
+ final Long id = dictionaryNameToID.get(name);
if (id == null)
return null;
dictionaryIDToName.remove(id);
@@ -267,8 +267,8 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
*/
public Object get(final String name)
{
- final Long id = (Long) dictionaryNameToID.get(name);
- final CustomProperty cp = (CustomProperty) super.get(id);
+ final Long id = dictionaryNameToID.get(name);
+ final CustomProperty cp = super.get(id);
return cp != null ? cp.getValue() : null;
}
@@ -351,10 +351,10 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
*/
public boolean containsKey(Object key) {
if(key instanceof Long) {
- return super.containsKey((Long)key);
+ return super.containsKey(key);
}
if(key instanceof String) {
- return super.containsKey((Long)dictionaryNameToID.get(key));
+ return super.containsKey(dictionaryNameToID.get(key));
}
return false;
}
@@ -364,7 +364,7 @@ public class CustomProperties extends HashMap<Object,CustomProperty>
*/
public boolean containsValue(Object value) {
if(value instanceof CustomProperty) {
- return super.containsValue((CustomProperty)value);
+ return super.containsValue(value);
} else {
for(CustomProperty cp : super.values()) {
if(cp.getValue() == value) {
diff --git a/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java b/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
index 4a8303098a..0dacd0d97c 100644
--- a/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
+++ b/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
@@ -569,7 +569,7 @@ public class DocumentSummaryInformation extends SpecialPropertySet
if (getSectionCount() >= 2)
{
cps = new CustomProperties();
- final Section section = (Section) getSections().get(1);
+ final Section section = getSections().get(1);
final Map<Long,String> dictionary = section.getDictionary();
final Property[] properties = section.getProperties();
int propertyCount = 0;
diff --git a/src/java/org/apache/poi/hpsf/MutableSection.java b/src/java/org/apache/poi/hpsf/MutableSection.java
index 49eaa32272..a1b3824666 100644
--- a/src/java/org/apache/poi/hpsf/MutableSection.java
+++ b/src/java/org/apache/poi/hpsf/MutableSection.java
@@ -576,7 +576,7 @@ public class MutableSection extends Section
*/
public Property[] getProperties()
{
- properties = (Property[]) preprops.toArray(new Property[0]);
+ properties = preprops.toArray(new Property[0]);
return properties;
}
diff --git a/src/java/org/apache/poi/hpsf/Section.java b/src/java/org/apache/poi/hpsf/Section.java
index 945cdf567c..0c97a0e68a 100644
--- a/src/java/org/apache/poi/hpsf/Section.java
+++ b/src/java/org/apache/poi/hpsf/Section.java
@@ -448,7 +448,7 @@ public class Section
{
String s = null;
if (dictionary != null)
- s = (String) dictionary.get(Long.valueOf(pid));
+ s = dictionary.get(Long.valueOf(pid));
if (s == null)
s = SectionIDMap.getPIDString(getFormatID().getBytes(), pid);
if (s == null)
diff --git a/src/java/org/apache/poi/hpsf/Variant.java b/src/java/org/apache/poi/hpsf/Variant.java
index 8330a6d5a9..fd1539ec0f 100644
--- a/src/java/org/apache/poi/hpsf/Variant.java
+++ b/src/java/org/apache/poi/hpsf/Variant.java
@@ -352,9 +352,9 @@ public class Variant
* <p>Maps the numbers denoting the variant types to their corresponding
* variant type names.</p>
*/
- private static Map numberToName;
+ private static Map<Long,String> numberToName;
- private static Map numberToLength;
+ private static Map<Long,Integer> numberToLength;
/**
* <p>Denotes a variant type with a length that is unknown to HPSF yet.</p>
@@ -391,7 +391,7 @@ public class Variant
static
{
/* Initialize the number-to-name map: */
- Map tm1 = new HashMap();
+ Map<Long,String> tm1 = new HashMap<Long,String>();
tm1.put(Long.valueOf(0), "VT_EMPTY");
tm1.put(Long.valueOf(1), "VT_NULL");
tm1.put(Long.valueOf(2), "VT_I2");
@@ -432,55 +432,55 @@ public class Variant
tm1.put(Long.valueOf(70), "VT_BLOB_OBJECT");
tm1.put(Long.valueOf(71), "VT_CF");
tm1.put(Long.valueOf(72), "VT_CLSID");
- Map tm2 = new HashMap(tm1.size(), 1.0F);
+ Map<Long,String> tm2 = new HashMap<Long,String>(tm1.size(), 1.0F);
tm2.putAll(tm1);
numberToName = Collections.unmodifiableMap(tm2);
/* Initialize the number-to-length map: */
- tm1.clear();
- tm1.put(Long.valueOf(0), LENGTH_0);
- tm1.put(Long.valueOf(1), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(2), LENGTH_2);
- tm1.put(Long.valueOf(3), LENGTH_4);
- tm1.put(Long.valueOf(4), LENGTH_4);
- tm1.put(Long.valueOf(5), LENGTH_8);
- tm1.put(Long.valueOf(6), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(7), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(8), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(9), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(10), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(11), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(12), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(13), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(14), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(16), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(17), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(18), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(19), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(20), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(21), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(22), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(23), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(24), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(25), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(26), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(27), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(28), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(29), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(30), LENGTH_VARIABLE);
- tm1.put(Long.valueOf(31), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(64), LENGTH_8);
- tm1.put(Long.valueOf(65), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(66), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(67), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(68), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(69), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(70), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(71), LENGTH_UNKNOWN);
- tm1.put(Long.valueOf(72), LENGTH_UNKNOWN);
- tm2 = new HashMap(tm1.size(), 1.0F);
- tm2.putAll(tm1);
- numberToLength = Collections.unmodifiableMap(tm2);
+ Map<Long,Integer> tm3 = new HashMap<Long,Integer>();
+ tm3.put(Long.valueOf(0), LENGTH_0);
+ tm3.put(Long.valueOf(1), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(2), LENGTH_2);
+ tm3.put(Long.valueOf(3), LENGTH_4);
+ tm3.put(Long.valueOf(4), LENGTH_4);
+ tm3.put(Long.valueOf(5), LENGTH_8);
+ tm3.put(Long.valueOf(6), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(7), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(8), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(9), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(10), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(11), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(12), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(13), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(14), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(16), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(17), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(18), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(19), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(20), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(21), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(22), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(23), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(24), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(25), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(26), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(27), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(28), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(29), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(30), LENGTH_VARIABLE);
+ tm3.put(Long.valueOf(31), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(64), LENGTH_8);
+ tm3.put(Long.valueOf(65), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(66), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(67), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(68), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(69), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(70), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(71), LENGTH_UNKNOWN);
+ tm3.put(Long.valueOf(72), LENGTH_UNKNOWN);
+ Map<Long,Integer> tm4 = new HashMap<Long,Integer>(tm1.size(), 1.0F);
+ tm4.putAll(tm3);
+ numberToLength = Collections.unmodifiableMap(tm4);
}
@@ -494,7 +494,7 @@ public class Variant
*/
public static String getVariantName(final long variantType)
{
- final String name = (String) numberToName.get(Long.valueOf(variantType));
+ final String name = numberToName.get(Long.valueOf(variantType));
return name != null ? name : "unknown variant type";
}
@@ -510,7 +510,7 @@ public class Variant
public static int getVariantLength(final long variantType)
{
final Long key = Long.valueOf((int) variantType);
- final Long length = (Long) numberToLength.get(key);
+ final Integer length = numberToLength.get(key);
if (length == null)
return -2;
return length.intValue();
diff --git a/src/java/org/apache/poi/hpsf/extractor/HPSFPropertiesExtractor.java b/src/java/org/apache/poi/hpsf/extractor/HPSFPropertiesExtractor.java
index 7150b6c1c9..ce5301ac60 100644
--- a/src/java/org/apache/poi/hpsf/extractor/HPSFPropertiesExtractor.java
+++ b/src/java/org/apache/poi/hpsf/extractor/HPSFPropertiesExtractor.java
@@ -17,6 +17,7 @@
package org.apache.poi.hpsf.extractor;
+import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.util.Iterator;
@@ -39,6 +40,8 @@ import org.apache.poi.poifs.filesystem.POIFSFileSystem;
* textual form.
*/
public class HPSFPropertiesExtractor extends POITextExtractor {
+ private Closeable toClose;
+
public HPSFPropertiesExtractor(POITextExtractor mainExtractor) {
super(mainExtractor);
}
@@ -50,6 +53,7 @@ public class HPSFPropertiesExtractor extends POITextExtractor {
}
public HPSFPropertiesExtractor(NPOIFSFileSystem fs) {
super(new HPSFPropertiesOnlyDocument(fs));
+ this.toClose = fs;
}
public String getDocumentSummaryInformationText() {
@@ -119,6 +123,19 @@ public class HPSFPropertiesExtractor extends POITextExtractor {
throw new IllegalStateException("You already have the Metadata Text Extractor, not recursing!");
}
+
+
+ public void close() throws IOException {
+ super.close();
+
+ if(toClose != null) {
+ toClose.close();
+ toClose = null;
+ }
+ }
+
+
+
private static abstract class HelperPropertySet extends SpecialPropertySet {
public HelperPropertySet() {
super(null);
@@ -135,7 +152,11 @@ public class HPSFPropertiesExtractor extends POITextExtractor {
for (String file : args) {
HPSFPropertiesExtractor ext = new HPSFPropertiesExtractor(
new NPOIFSFileSystem(new File(file)));
- System.out.println(ext.getText());
+ try {
+ System.out.println(ext.getText());
+ } finally {
+ ext.close();
+ }
}
}
}
diff --git a/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java b/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java
index 4eef8c4b02..02b73f329e 100644
--- a/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java
+++ b/src/java/org/apache/poi/hpsf/wellknown/PropertyIDMap.java
@@ -34,7 +34,7 @@ import java.util.Map;
* @author Rainer Klute <a
* href="mailto:klute@rainer-klute.de">&lt;klute@rainer-klute.de&gt;</a>
*/
-public class PropertyIDMap extends HashMap {
+public class PropertyIDMap extends HashMap<Long,String> {
/*
* The following definitions are for property IDs in the first
@@ -271,7 +271,7 @@ public class PropertyIDMap extends HashMap {
*
* @param map The instance to be created is backed by this map.
*/
- public PropertyIDMap(final Map map)
+ public PropertyIDMap(final Map<Long,String> map)
{
super(map);
}
diff --git a/src/java/org/apache/poi/hssf/dev/ReSave.java b/src/java/org/apache/poi/hssf/dev/ReSave.java
index 340d7b987c..7e74b7a3a6 100644
--- a/src/java/org/apache/poi/hssf/dev/ReSave.java
+++ b/src/java/org/apache/poi/hssf/dev/ReSave.java
@@ -17,13 +17,12 @@
package org.apache.poi.hssf.dev;
-import org.apache.poi.hssf.usermodel.HSSFPatriarch;
-import org.apache.poi.hssf.usermodel.HSSFSheet;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+
/**
* Utility to test that POI produces readable output
* after re-saving xls files.
@@ -40,22 +39,28 @@ public class ReSave {
System.out.print("reading " + arg + "...");
FileInputStream is = new FileInputStream(arg);
HSSFWorkbook wb = new HSSFWorkbook(is);
- is.close();
- System.out.println("done");
-
- for(int i = 0; i < wb.getNumberOfSheets(); i++){
- HSSFSheet sheet = wb.getSheetAt(i);
- if(initDrawing) {
- HSSFPatriarch dg = sheet.getDrawingPatriarch();
+ try {
+ System.out.println("done");
+
+ for(int i = 0; i < wb.getNumberOfSheets(); i++){
+ HSSFSheet sheet = wb.getSheetAt(i);
+ if(initDrawing) {
+ /*HSSFPatriarch dg =*/ sheet.getDrawingPatriarch();
+ }
}
+
+ String outputFile = arg.replace(".xls", "-saved.xls");
+ System.out.print("saving to " + outputFile + "...");
+ FileOutputStream out = new FileOutputStream(outputFile);
+ try {
+ wb.write(out);
+ } finally {
+ out.close();
+ }
+ System.out.println("done");
+ } finally {
+ wb.close();
}
-
- String outputFile = arg.replace(".xls", "-saved.xls");
- System.out.print("saving to " + outputFile + "...");
- FileOutputStream out = new FileOutputStream(outputFile);
- wb.write(out);
- out.close();
- System.out.println("done");
}
}
}
diff --git a/src/java/org/apache/poi/hssf/model/DrawingManager2.java b/src/java/org/apache/poi/hssf/model/DrawingManager2.java
index 8b2292e951..51abcde5b9 100644
--- a/src/java/org/apache/poi/hssf/model/DrawingManager2.java
+++ b/src/java/org/apache/poi/hssf/model/DrawingManager2.java
@@ -30,7 +30,7 @@ import java.util.ArrayList;
public class DrawingManager2
{
EscherDggRecord dgg;
- List drawingGroups = new ArrayList( );
+ List<EscherDgRecord> drawingGroups = new ArrayList<EscherDgRecord>();
public DrawingManager2( EscherDggRecord dgg )
@@ -120,7 +120,7 @@ public class DrawingManager2
EscherDgRecord getDrawingGroup(int drawingGroupId)
{
- return (EscherDgRecord) drawingGroups.get(drawingGroupId-1);
+ return drawingGroups.get(drawingGroupId-1);
}
boolean drawingGroupExists( short dgId )
diff --git a/src/java/org/apache/poi/hssf/model/RecordStream.java b/src/java/org/apache/poi/hssf/model/RecordStream.java
index d9f04f7e6e..7c9dc8a60f 100644
--- a/src/java/org/apache/poi/hssf/model/RecordStream.java
+++ b/src/java/org/apache/poi/hssf/model/RecordStream.java
@@ -53,7 +53,7 @@ public final class RecordStream {
throw new RuntimeException("Attempt to read past end of record stream");
}
_countRead ++;
- return (Record) _list.get(_nextIndex++);
+ return _list.get(_nextIndex++);
}
/**
@@ -73,7 +73,7 @@ public final class RecordStream {
if(!hasNext()) {
return -1;
}
- return ((Record)_list.get(_nextIndex)).getSid();
+ return _list.get(_nextIndex).getSid();
}
public int getCountRead() {
diff --git a/src/java/org/apache/poi/hssf/record/TextObjectRecord.java b/src/java/org/apache/poi/hssf/record/TextObjectRecord.java
index 8bc254855f..56bc7bf8d2 100644
--- a/src/java/org/apache/poi/hssf/record/TextObjectRecord.java
+++ b/src/java/org/apache/poi/hssf/record/TextObjectRecord.java
@@ -212,7 +212,7 @@ public final class TextObjectRecord extends ContinuableRecord {
for (int i = 0; i < nRuns; i++) {
out.writeShort(str.getIndexOfFormattingRun(i));
int fontIndex = str.getFontOfFormattingRun(i);
- out.writeShort(fontIndex == str.NO_FONT ? 0 : fontIndex);
+ out.writeShort(fontIndex == HSSFRichTextString.NO_FONT ? 0 : fontIndex);
out.writeInt(0); // skip reserved
}
out.writeShort(str.length());
diff --git a/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java b/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java
index 1ad0488ce7..6aed70faa1 100644
--- a/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java
+++ b/src/java/org/apache/poi/hssf/record/aggregates/ColumnInfoRecordsAggregate.java
@@ -32,16 +32,16 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
/**
* List of {@link ColumnInfoRecord}s assumed to be in order
*/
- private final List records;
+ private final List<ColumnInfoRecord> records;
- private static final class CIRComparator implements Comparator {
- public static final Comparator instance = new CIRComparator();
+ private static final class CIRComparator implements Comparator<ColumnInfoRecord> {
+ public static final Comparator<ColumnInfoRecord> instance = new CIRComparator();
private CIRComparator() {
// enforce singleton
}
- public int compare(Object a, Object b) {
- return compareColInfos((ColumnInfoRecord)a, (ColumnInfoRecord)b);
+ public int compare(ColumnInfoRecord a, ColumnInfoRecord b) {
+ return compareColInfos(a, b);
}
public static int compareColInfos(ColumnInfoRecord a, ColumnInfoRecord b) {
return a.getFirstColumn()-b.getFirstColumn();
@@ -52,7 +52,7 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
* Creates an empty aggregate
*/
public ColumnInfoRecordsAggregate() {
- records = new ArrayList();
+ records = new ArrayList<ColumnInfoRecord>();
}
public ColumnInfoRecordsAggregate(RecordStream rs) {
this();
@@ -81,8 +81,8 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
public Object clone() {
ColumnInfoRecordsAggregate rec = new ColumnInfoRecordsAggregate();
for (int k = 0; k < records.size(); k++) {
- ColumnInfoRecord ci = ( ColumnInfoRecord ) records.get(k);
- rec.records.add(ci.clone());
+ ColumnInfoRecord ci = records.get(k);
+ rec.records.add((ColumnInfoRecord) ci.clone());
}
return rec;
}
@@ -114,7 +114,7 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
}
ColumnInfoRecord cirPrev = null;
for(int i=0; i<nItems; i++) {
- ColumnInfoRecord cir = (ColumnInfoRecord)records.get(i);
+ ColumnInfoRecord cir = records.get(i);
rv.visitRecord(cir);
if (cirPrev != null && CIRComparator.compareColInfos(cirPrev, cir) > 0) {
// Excel probably wouldn't mind, but there is much logic in this class
@@ -127,11 +127,11 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
private int findStartOfColumnOutlineGroup(int pIdx) {
// Find the start of the group.
- ColumnInfoRecord columnInfo = (ColumnInfoRecord) records.get(pIdx);
+ ColumnInfoRecord columnInfo = records.get(pIdx);
int level = columnInfo.getOutlineLevel();
int idx = pIdx;
while (idx != 0) {
- ColumnInfoRecord prevColumnInfo = (ColumnInfoRecord) records.get(idx - 1);
+ ColumnInfoRecord prevColumnInfo = records.get(idx - 1);
if (!prevColumnInfo.isAdjacentBefore(columnInfo)) {
break;
}
@@ -147,11 +147,11 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
private int findEndOfColumnOutlineGroup(int colInfoIndex) {
// Find the end of the group.
- ColumnInfoRecord columnInfo = (ColumnInfoRecord) records.get(colInfoIndex);
+ ColumnInfoRecord columnInfo = records.get(colInfoIndex);
int level = columnInfo.getOutlineLevel();
int idx = colInfoIndex;
while (idx < records.size() - 1) {
- ColumnInfoRecord nextColumnInfo = (ColumnInfoRecord) records.get(idx + 1);
+ ColumnInfoRecord nextColumnInfo = records.get(idx + 1);
if (!columnInfo.isAdjacentBefore(nextColumnInfo)) {
break;
}
@@ -165,7 +165,7 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
}
private ColumnInfoRecord getColInfo(int idx) {
- return (ColumnInfoRecord) records.get( idx );
+ return records.get( idx );
}
/**
@@ -305,7 +305,7 @@ public final class ColumnInfoRecordsAggregate extends RecordAggregate {
int k = 0;
for (k = 0; k < records.size(); k++) {
- ColumnInfoRecord tci = (ColumnInfoRecord) records.get(k);
+ ColumnInfoRecord tci = records.get(k);
if (tci.containsColumn(targetColumnIx)) {
ci = tci;
break;
diff --git a/src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java b/src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java
index cffa34173c..33a2f7b294 100644
--- a/src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java
+++ b/src/java/org/apache/poi/hssf/record/aggregates/ConditionalFormattingTable.java
@@ -33,18 +33,18 @@ import org.apache.poi.ss.formula.FormulaShifter;
*/
public final class ConditionalFormattingTable extends RecordAggregate {
- private final List _cfHeaders;
+ private final List<CFRecordsAggregate> _cfHeaders;
/**
* Creates an empty ConditionalFormattingTable
*/
public ConditionalFormattingTable() {
- _cfHeaders = new ArrayList();
+ _cfHeaders = new ArrayList<CFRecordsAggregate>();
}
public ConditionalFormattingTable(RecordStream rs) {
- List temp = new ArrayList();
+ List<CFRecordsAggregate> temp = new ArrayList<CFRecordsAggregate>();
while (rs.peekNextClass() == CFHeaderRecord.class) {
temp.add(CFRecordsAggregate.createCFAggregate(rs));
}
@@ -53,7 +53,7 @@ public final class ConditionalFormattingTable extends RecordAggregate {
public void visitContainedRecords(RecordVisitor rv) {
for (int i = 0; i < _cfHeaders.size(); i++) {
- CFRecordsAggregate subAgg = (CFRecordsAggregate) _cfHeaders.get(i);
+ CFRecordsAggregate subAgg = _cfHeaders.get(i);
subAgg.visitContainedRecords(rv);
}
}
@@ -72,7 +72,7 @@ public final class ConditionalFormattingTable extends RecordAggregate {
public CFRecordsAggregate get(int index) {
checkIndex(index);
- return (CFRecordsAggregate) _cfHeaders.get(index);
+ return _cfHeaders.get(index);
}
public void remove(int index) {
@@ -89,7 +89,7 @@ public final class ConditionalFormattingTable extends RecordAggregate {
public void updateFormulasAfterCellShift(FormulaShifter shifter, int externSheetIndex) {
for (int i = 0; i < _cfHeaders.size(); i++) {
- CFRecordsAggregate subAgg = (CFRecordsAggregate) _cfHeaders.get(i);
+ CFRecordsAggregate subAgg = _cfHeaders.get(i);
boolean shouldKeep = subAgg.updateFormulasAfterCellShift(shifter, externSheetIndex);
if (!shouldKeep) {
_cfHeaders.remove(i);
diff --git a/src/java/org/apache/poi/hssf/record/aggregates/DataValidityTable.java b/src/java/org/apache/poi/hssf/record/aggregates/DataValidityTable.java
index e2dfcd6d35..ff5b9604b6 100644
--- a/src/java/org/apache/poi/hssf/record/aggregates/DataValidityTable.java
+++ b/src/java/org/apache/poi/hssf/record/aggregates/DataValidityTable.java
@@ -23,7 +23,6 @@ import java.util.List;
import org.apache.poi.hssf.model.RecordStream;
import org.apache.poi.hssf.record.DVALRecord;
import org.apache.poi.hssf.record.DVRecord;
-import org.apache.poi.hssf.record.Record;
/**
* Manages the DVALRecord and DVRecords for a single sheet<br/>
@@ -37,20 +36,20 @@ public final class DataValidityTable extends RecordAggregate {
* The list of data validations for the current sheet.
* Note - this may be empty (contrary to OOO documentation)
*/
- private final List _validationList;
+ private final List<DVRecord> _validationList;
public DataValidityTable(RecordStream rs) {
_headerRec = (DVALRecord) rs.getNext();
- List temp = new ArrayList();
+ List<DVRecord> temp = new ArrayList<DVRecord>();
while (rs.peekNextClass() == DVRecord.class) {
- temp.add(rs.getNext());
+ temp.add((DVRecord) rs.getNext());
}
_validationList = temp;
}
public DataValidityTable() {
_headerRec = new DVALRecord();
- _validationList = new ArrayList();
+ _validationList = new ArrayList<DVRecord>();
}
public void visitContainedRecords(RecordVisitor rv) {
@@ -59,7 +58,7 @@ public final class DataValidityTable extends RecordAggregate {
}
rv.visitRecord(_headerRec);
for (int i = 0; i < _validationList.size(); i++) {
- rv.visitRecord((Record) _validationList.get(i));
+ rv.visitRecord(_validationList.get(i));
}
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java b/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java
index 8b6f564188..8e322ce803 100644
--- a/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java
+++ b/src/java/org/apache/poi/hssf/usermodel/DVConstraint.java
@@ -162,7 +162,7 @@ public class DVConstraint implements DataValidationConstraint {
// formula2 and value2 are mutually exclusive
String formula2 = getFormulaFromTextExpression(expr2);
Double value2 = formula2 == null ? convertTime(expr2) : null;
- return new DVConstraint(VT.TIME, comparisonOperator, formula1, formula2, value1, value2, null);
+ return new DVConstraint(ValidationType.TIME, comparisonOperator, formula1, formula2, value1, value2, null);
}
/**
@@ -192,7 +192,7 @@ public class DVConstraint implements DataValidationConstraint {
// formula2 and value2 are mutually exclusive
String formula2 = getFormulaFromTextExpression(expr2);
Double value2 = formula2 == null ? convertDate(expr2, df) : null;
- return new DVConstraint(VT.DATE, comparisonOperator, formula1, formula2, value1, value2, null);
+ return new DVConstraint(ValidationType.DATE, comparisonOperator, formula1, formula2, value1, value2, null);
}
/**
@@ -270,7 +270,7 @@ public class DVConstraint implements DataValidationConstraint {
if (formula == null) {
throw new IllegalArgumentException("formula must be supplied");
}
- return new DVConstraint(VT.FORMULA, OperatorType.IGNORED, formula, null, null, null, null);
+ return new DVConstraint(ValidationType.FORMULA, OperatorType.IGNORED, formula, null, null, null, null);
}
/* (non-Javadoc)
@@ -284,14 +284,14 @@ public class DVConstraint implements DataValidationConstraint {
* @return <code>true</code> if this constraint is a 'list' validation
*/
public boolean isListValidationType() {
- return _validationType == VT.LIST;
+ return _validationType == ValidationType.LIST;
}
/**
* Convenience method
* @return <code>true</code> if this constraint is a 'list' validation with explicit values
*/
public boolean isExplicitList() {
- return _validationType == VT.LIST && _explicitListValues != null;
+ return _validationType == ValidationType.LIST && _explicitListValues != null;
}
/* (non-Javadoc)
* @see org.apache.poi.hssf.usermodel.DataValidationConstraint#getOperator()
@@ -316,7 +316,7 @@ public class DVConstraint implements DataValidationConstraint {
* @see org.apache.poi.hssf.usermodel.DataValidationConstraint#setExplicitListValues(java.lang.String[])
*/
public void setExplicitListValues(String[] explicitListValues) {
- if (_validationType != VT.LIST) {
+ if (_validationType != ValidationType.LIST) {
throw new RuntimeException("Cannot setExplicitListValues on non-list constraint");
}
_formula1 = null;
diff --git a/src/java/org/apache/poi/ss/formula/constant/ErrorConstant.java b/src/java/org/apache/poi/ss/formula/constant/ErrorConstant.java
index b3c7ee7207..67b8769231 100644
--- a/src/java/org/apache/poi/ss/formula/constant/ErrorConstant.java
+++ b/src/java/org/apache/poi/ss/formula/constant/ErrorConstant.java
@@ -33,13 +33,20 @@ public class ErrorConstant {
// convenient access to name space
private static final ErrorConstants EC = null;
- private static final ErrorConstant NULL = new ErrorConstant(EC.ERROR_NULL);
- private static final ErrorConstant DIV_0 = new ErrorConstant(EC.ERROR_DIV_0);
- private static final ErrorConstant VALUE = new ErrorConstant(EC.ERROR_VALUE);
- private static final ErrorConstant REF = new ErrorConstant(EC.ERROR_REF);
- private static final ErrorConstant NAME = new ErrorConstant(EC.ERROR_NAME);
- private static final ErrorConstant NUM = new ErrorConstant(EC.ERROR_NUM);
- private static final ErrorConstant NA = new ErrorConstant(EC.ERROR_NA);
+ @SuppressWarnings("static-access")
+ private static final ErrorConstant NULL = new ErrorConstant(EC.ERROR_NULL);
+ @SuppressWarnings("static-access")
+ private static final ErrorConstant DIV_0 = new ErrorConstant(EC.ERROR_DIV_0);
+ @SuppressWarnings("static-access")
+ private static final ErrorConstant VALUE = new ErrorConstant(EC.ERROR_VALUE);
+ @SuppressWarnings("static-access")
+ private static final ErrorConstant REF = new ErrorConstant(EC.ERROR_REF);
+ @SuppressWarnings("static-access")
+ private static final ErrorConstant NAME = new ErrorConstant(EC.ERROR_NAME);
+ @SuppressWarnings("static-access")
+ private static final ErrorConstant NUM = new ErrorConstant(EC.ERROR_NUM);
+ @SuppressWarnings("static-access")
+ private static final ErrorConstant NA = new ErrorConstant(EC.ERROR_NA);
private final int _errorCode;
diff --git a/src/java/org/apache/poi/ss/formula/eval/ErrorEval.java b/src/java/org/apache/poi/ss/formula/eval/ErrorEval.java
index 6cc8136b37..b2a46d831b 100644
--- a/src/java/org/apache/poi/ss/formula/eval/ErrorEval.java
+++ b/src/java/org/apache/poi/ss/formula/eval/ErrorEval.java
@@ -29,18 +29,25 @@ public final class ErrorEval implements ValueEval {
private static final ErrorConstants EC = null;
/** <b>#NULL!</b> - Intersection of two cell ranges is empty */
+ @SuppressWarnings("static-access")
public static final ErrorEval NULL_INTERSECTION = new ErrorEval(EC.ERROR_NULL);
/** <b>#DIV/0!</b> - Division by zero */
+ @SuppressWarnings("static-access")
public static final ErrorEval DIV_ZERO = new ErrorEval(EC.ERROR_DIV_0);
/** <b>#VALUE!</b> - Wrong type of operand */
+ @SuppressWarnings("static-access")
public static final ErrorEval VALUE_INVALID = new ErrorEval(EC.ERROR_VALUE);
/** <b>#REF!</b> - Illegal or deleted cell reference */
+ @SuppressWarnings("static-access")
public static final ErrorEval REF_INVALID = new ErrorEval(EC.ERROR_REF);
/** <b>#NAME?</b> - Wrong function or range name */
+ @SuppressWarnings("static-access")
public static final ErrorEval NAME_INVALID = new ErrorEval(EC.ERROR_NAME);
/** <b>#NUM!</b> - Value range overflow */
+ @SuppressWarnings("static-access")
public static final ErrorEval NUM_ERROR = new ErrorEval(EC.ERROR_NUM);
/** <b>#N/A</b> - Argument or function not available */
+ @SuppressWarnings("static-access")
public static final ErrorEval NA = new ErrorEval(EC.ERROR_NA);
diff --git a/src/java/org/apache/poi/ss/formula/ptg/ErrPtg.java b/src/java/org/apache/poi/ss/formula/ptg/ErrPtg.java
index 2e38c33083..ebe656f397 100644
--- a/src/java/org/apache/poi/ss/formula/ptg/ErrPtg.java
+++ b/src/java/org/apache/poi/ss/formula/ptg/ErrPtg.java
@@ -30,18 +30,25 @@ public final class ErrPtg extends ScalarConstantPtg {
private static final ErrorConstants EC = null;
/** <b>#NULL!</b> - Intersection of two cell ranges is empty */
+ @SuppressWarnings("static-access")
public static final ErrPtg NULL_INTERSECTION = new ErrPtg(EC.ERROR_NULL);
/** <b>#DIV/0!</b> - Division by zero */
+ @SuppressWarnings("static-access")
public static final ErrPtg DIV_ZERO = new ErrPtg(EC.ERROR_DIV_0);
/** <b>#VALUE!</b> - Wrong type of operand */
+ @SuppressWarnings("static-access")
public static final ErrPtg VALUE_INVALID = new ErrPtg(EC.ERROR_VALUE);
/** <b>#REF!</b> - Illegal or deleted cell reference */
+ @SuppressWarnings("static-access")
public static final ErrPtg REF_INVALID = new ErrPtg(EC.ERROR_REF);
/** <b>#NAME?</b> - Wrong function or range name */
+ @SuppressWarnings("static-access")
public static final ErrPtg NAME_INVALID = new ErrPtg(EC.ERROR_NAME);
/** <b>#NUM!</b> - Value range overflow */
+ @SuppressWarnings("static-access")
public static final ErrPtg NUM_ERROR = new ErrPtg(EC.ERROR_NUM);
/** <b>#N/A</b> - Argument or function not available */
+ @SuppressWarnings("static-access")
public static final ErrPtg N_A = new ErrPtg(EC.ERROR_NA);
diff --git a/src/java/org/apache/poi/ss/util/AreaReference.java b/src/java/org/apache/poi/ss/util/AreaReference.java
index 5d747c59ca..d593888730 100644
--- a/src/java/org/apache/poi/ss/util/AreaReference.java
+++ b/src/java/org/apache/poi/ss/util/AreaReference.java
@@ -17,11 +17,12 @@
package org.apache.poi.ss.util;
-import org.apache.poi.ss.SpreadsheetVersion;
-
import java.util.ArrayList;
+import java.util.List;
import java.util.StringTokenizer;
+import org.apache.poi.ss.SpreadsheetVersion;
+
public class AreaReference {
/** The character (!) that separates sheet names from cell references */
@@ -199,14 +200,14 @@ public class AreaReference {
* returns an array of contiguous area references.
*/
public static AreaReference[] generateContiguous(String reference) {
- ArrayList refs = new ArrayList();
+ List<AreaReference> refs = new ArrayList<AreaReference>();
StringTokenizer st = new StringTokenizer(reference, ",");
while(st.hasMoreTokens()) {
refs.add(
new AreaReference(st.nextToken())
);
}
- return (AreaReference[])refs.toArray(new AreaReference[refs.size()]);
+ return refs.toArray(new AreaReference[refs.size()]);
}
/**
@@ -250,14 +251,14 @@ public class AreaReference {
int maxCol = Math.max(_firstCell.getCol(), _lastCell.getCol());
String sheetName = _firstCell.getSheetName();
- ArrayList refs = new ArrayList();
+ List<CellReference> refs = new ArrayList<CellReference>();
for(int row=minRow; row<=maxRow; row++) {
for(int col=minCol; col<=maxCol; col++) {
CellReference ref = new CellReference(sheetName, row, col, _firstCell.isRowAbsolute(), _firstCell.isColAbsolute());
refs.add(ref);
}
}
- return (CellReference[])refs.toArray(new CellReference[refs.size()]);
+ return refs.toArray(new CellReference[refs.size()]);
}
/**
diff --git a/src/java/org/apache/poi/ss/util/CellRangeAddressList.java b/src/java/org/apache/poi/ss/util/CellRangeAddressList.java
index 54112c7d1c..8d99198234 100644
--- a/src/java/org/apache/poi/ss/util/CellRangeAddressList.java
+++ b/src/java/org/apache/poi/ss/util/CellRangeAddressList.java
@@ -42,10 +42,10 @@ public class CellRangeAddressList {
/**
* List of <tt>CellRangeAddress</tt>es. Each structure represents a cell range
*/
- protected final List _list;
+ protected final List<CellRangeAddress> _list;
public CellRangeAddressList() {
- _list = new ArrayList();
+ _list = new ArrayList<CellRangeAddress>();
}
/**
* Convenience constructor for creating a <tt>CellRangeAddressList</tt> with a single
@@ -101,14 +101,14 @@ public class CellRangeAddressList {
throw new RuntimeException("Range index (" + rangeIndex
+ ") is outside allowable range (0.." + (_list.size()-1) + ")");
}
- return (CellRangeAddress) _list.remove(rangeIndex);
+ return _list.remove(rangeIndex);
}
/**
* @return <tt>CellRangeAddress</tt> at the given index
*/
public CellRangeAddress getCellRangeAddress(int index) {
- return (CellRangeAddress) _list.get(index);
+ return _list.get(index);
}
public int getSize() {
@@ -131,7 +131,7 @@ public class CellRangeAddressList {
int nItems = _list.size();
out.writeShort(nItems);
for (int k = 0; k < nItems; k++) {
- CellRangeAddress region = (CellRangeAddress) _list.get(k);
+ CellRangeAddress region = _list.get(k);
region.serialize(out);
}
}
@@ -142,7 +142,7 @@ public class CellRangeAddressList {
int nItems = _list.size();
for (int k = 0; k < nItems; k++) {
- CellRangeAddress region = (CellRangeAddress) _list.get(k);
+ CellRangeAddress region = _list.get(k);
result.addCellRangeAddress(region.copy());
}
return result;
diff --git a/src/java/org/apache/poi/util/BinaryTree.java b/src/java/org/apache/poi/util/BinaryTree.java
index 551d588789..e2ae5e58c0 100644
--- a/src/java/org/apache/poi/util/BinaryTree.java
+++ b/src/java/org/apache/poi/util/BinaryTree.java
@@ -88,6 +88,7 @@ import java.util.*;
* @author Marc Johnson (mjohnson at apache dot org)
*/
//for performance
+@SuppressWarnings("rawtypes")
public class BinaryTree extends AbstractMap {
final Node[] _root;
int _size = 0;