aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/poi
diff options
context:
space:
mode:
authorAndreas Beeker <kiwiwings@apache.org>2015-09-12 18:45:07 +0000
committerAndreas Beeker <kiwiwings@apache.org>2015-09-12 18:45:07 +0000
commitfbcf869f48e696a28ea364b8ff394476a96cdd21 (patch)
tree636ea213a2b2f8c826ee4ba8f1ac650d918869e3 /src/java/org/apache/poi
parentf580fb0d728ad52873fb28be121e436f92fadfbb (diff)
downloadpoi-fbcf869f48e696a28ea364b8ff394476a96cdd21.tar.gz
poi-fbcf869f48e696a28ea364b8ff394476a96cdd21.zip
fix eclipse warning - mostly generics cosmetics
close resources in tests junit4 conversions convert spreadsheet based formular test to junit parameterized tests git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1702659 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi')
-rw-r--r--src/java/org/apache/poi/hssf/model/InternalSheet.java10
-rw-r--r--src/java/org/apache/poi/hssf/record/Record.java16
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java12
-rw-r--r--src/java/org/apache/poi/hssf/util/HSSFColor.java16
-rw-r--r--src/java/org/apache/poi/poifs/eventfilesystem/POIFSReaderRegistry.java43
-rw-r--r--src/java/org/apache/poi/sl/draw/geom/ExpressionParser.java8
-rw-r--r--src/java/org/apache/poi/ss/formula/Formula.java26
-rw-r--r--src/java/org/apache/poi/ss/formula/eval/OperandResolver.java44
8 files changed, 88 insertions, 87 deletions
diff --git a/src/java/org/apache/poi/hssf/model/InternalSheet.java b/src/java/org/apache/poi/hssf/model/InternalSheet.java
index 078cfaa3df..7eb76c43b3 100644
--- a/src/java/org/apache/poi/hssf/model/InternalSheet.java
+++ b/src/java/org/apache/poi/hssf/model/InternalSheet.java
@@ -254,12 +254,12 @@ public final class InternalSheet {
if (recSid == BOFRecord.sid) {
ChartSubstreamRecordAggregate chartAgg = new ChartSubstreamRecordAggregate(rs);
- if (false) {
- // TODO - would like to keep the chart aggregate packed, but one unit test needs attention
- records.add(chartAgg);
- } else {
+// if (false) {
+// // TODO - would like to keep the chart aggregate packed, but one unit test needs attention
+// records.add(chartAgg);
+// } else {
spillAggregate(chartAgg, records);
- }
+// }
continue;
}
diff --git a/src/java/org/apache/poi/hssf/record/Record.java b/src/java/org/apache/poi/hssf/record/Record.java
index b81a666f00..e1d54a01cb 100644
--- a/src/java/org/apache/poi/hssf/record/Record.java
+++ b/src/java/org/apache/poi/hssf/record/Record.java
@@ -62,14 +62,14 @@ public abstract class Record extends RecordBase {
@Override
public Object clone() {
- if (false) {
- // TODO - implement clone in a more standardised way
- try {
- return super.clone();
- } catch (CloneNotSupportedException e) {
- throw new RuntimeException(e);
- }
- }
+// if (false) {
+// // TODO - implement clone in a more standardised way
+// try {
+// return super.clone();
+// } catch (CloneNotSupportedException e) {
+// throw new RuntimeException(e);
+// }
+// }
throw new RuntimeException("The class "+getClass().getName()+" needs to define a clone method");
}
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java b/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java
index 5c3be7a119..502312417d 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.java
@@ -54,9 +54,9 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
@Deprecated
public HSSFFormulaEvaluator(HSSFSheet sheet, HSSFWorkbook workbook) {
this(workbook);
- if (false) {
- sheet.toString(); // suppress unused parameter compiler warning
- }
+// if (false) {
+// sheet.toString(); // suppress unused parameter compiler warning
+// }
this._book = workbook;
}
public HSSFFormulaEvaluator(HSSFWorkbook workbook) {
@@ -122,9 +122,9 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator, WorkbookEvaluator
@Deprecated
public void setCurrentRow(HSSFRow row) {
// do nothing
- if (false) {
- row.getClass(); // suppress unused parameter compiler warning
- }
+// if (false) {
+// row.getClass(); // suppress unused parameter compiler warning
+// }
}
/**
diff --git a/src/java/org/apache/poi/hssf/util/HSSFColor.java b/src/java/org/apache/poi/hssf/util/HSSFColor.java
index d7a1cb587e..f6af086580 100644
--- a/src/java/org/apache/poi/hssf/util/HSSFColor.java
+++ b/src/java/org/apache/poi/hssf/util/HSSFColor.java
@@ -90,14 +90,14 @@ public class HSSFColor implements Color {
// most colors don't have a second index
continue;
}
- if (result.containsKey(index2)) {
- if (false) { // Many of the second indexes clash
- HSSFColor prevColor = (HSSFColor)result.get(index2);
- throw new RuntimeException("Dup color index (" + index2
- + ") for colors (" + prevColor.getClass().getName()
- + "),(" + color.getClass().getName() + ")");
- }
- }
+// if (result.containsKey(index2)) {
+// if (false) { // Many of the second indexes clash
+// HSSFColor prevColor = (HSSFColor)result.get(index2);
+// throw new RuntimeException("Dup color index (" + index2
+// + ") for colors (" + prevColor.getClass().getName()
+// + "),(" + color.getClass().getName() + ")");
+// }
+// }
result.put(index2, color);
}
return result;
diff --git a/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReaderRegistry.java b/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReaderRegistry.java
index 86a40c131c..1ea85f7c81 100644
--- a/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReaderRegistry.java
+++ b/src/java/org/apache/poi/poifs/eventfilesystem/POIFSReaderRegistry.java
@@ -36,20 +36,20 @@ class POIFSReaderRegistry
{
// the POIFSReaderListeners who listen to all POIFSReaderEvents
- private Set omnivorousListeners;
+ private Set<POIFSReaderListener> omnivorousListeners;
// Each mapping in this Map has a key consisting of a
// POIFSReaderListener and a value cosisting of a Set of
// DocumentDescriptors for the documents that POIFSReaderListener
// is interested in; used to efficiently manage the registry
- private Map selectiveListeners;
+ private Map<POIFSReaderListener, Set<DocumentDescriptor>> selectiveListeners;
// Each mapping in this Map has a key consisting of a
// DocumentDescriptor and a value consisting of a Set of
// POIFSReaderListeners for the document matching that
// DocumentDescriptor; used when a document is found, to quickly
// get the listeners interested in that document
- private Map chosenDocumentDescriptors;
+ private Map<DocumentDescriptor,Set<POIFSReaderListener>> chosenDocumentDescriptors;
/**
* Construct the registry
@@ -57,9 +57,9 @@ class POIFSReaderRegistry
POIFSReaderRegistry()
{
- omnivorousListeners = new HashSet();
- selectiveListeners = new HashMap();
- chosenDocumentDescriptors = new HashMap();
+ omnivorousListeners = new HashSet<POIFSReaderListener>();
+ selectiveListeners = new HashMap<POIFSReaderListener, Set<DocumentDescriptor>>();
+ chosenDocumentDescriptors = new HashMap<DocumentDescriptor,Set<POIFSReaderListener>>();
}
/**
@@ -79,13 +79,13 @@ class POIFSReaderRegistry
// not an omnivorous listener (if it was, this method is a
// no-op)
- Set descriptors = ( Set ) selectiveListeners.get(listener);
+ Set<DocumentDescriptor> descriptors = selectiveListeners.get(listener);
if (descriptors == null)
{
// this listener has not registered before
- descriptors = new HashSet();
+ descriptors = new HashSet<DocumentDescriptor>();
selectiveListeners.put(listener, descriptors);
}
DocumentDescriptor descriptor = new DocumentDescriptor(path,
@@ -97,14 +97,14 @@ class POIFSReaderRegistry
// this listener wasn't already listening for this
// document -- add the listener to the set of
// listeners for this document
- Set listeners =
- ( Set ) chosenDocumentDescriptors.get(descriptor);
+ Set<POIFSReaderListener> listeners =
+ chosenDocumentDescriptors.get(descriptor);
if (listeners == null)
{
// nobody was listening for this document before
- listeners = new HashSet();
+ listeners = new HashSet<POIFSReaderListener>();
chosenDocumentDescriptors.put(descriptor, listeners);
}
listeners.add(listener);
@@ -141,31 +141,30 @@ class POIFSReaderRegistry
* @return an Iterator POIFSReaderListeners; may be empty
*/
- Iterator getListeners(final POIFSDocumentPath path, final String name)
+ Iterator<POIFSReaderListener> getListeners(final POIFSDocumentPath path, final String name)
{
- Set rval = new HashSet(omnivorousListeners);
- Set selectiveListeners =
- ( Set ) chosenDocumentDescriptors.get(new DocumentDescriptor(path,
- name));
+ Set<POIFSReaderListener> rval = new HashSet<POIFSReaderListener>(omnivorousListeners);
+ Set<POIFSReaderListener> selectiveListenersInner =
+ chosenDocumentDescriptors.get(new DocumentDescriptor(path, name));
- if (selectiveListeners != null)
+ if (selectiveListenersInner != null)
{
- rval.addAll(selectiveListeners);
+ rval.addAll(selectiveListenersInner);
}
return rval.iterator();
}
private void removeSelectiveListener(final POIFSReaderListener listener)
{
- Set selectedDescriptors = ( Set ) selectiveListeners.remove(listener);
+ Set<DocumentDescriptor> selectedDescriptors = selectiveListeners.remove(listener);
if (selectedDescriptors != null)
{
- Iterator iter = selectedDescriptors.iterator();
+ Iterator<DocumentDescriptor> iter = selectedDescriptors.iterator();
while (iter.hasNext())
{
- dropDocument(listener, ( DocumentDescriptor ) iter.next());
+ dropDocument(listener, iter.next());
}
}
}
@@ -173,7 +172,7 @@ class POIFSReaderRegistry
private void dropDocument(final POIFSReaderListener listener,
final DocumentDescriptor descriptor)
{
- Set listeners = ( Set ) chosenDocumentDescriptors.get(descriptor);
+ Set<POIFSReaderListener> listeners = chosenDocumentDescriptors.get(descriptor);
listeners.remove(listener);
if (listeners.size() == 0)
diff --git a/src/java/org/apache/poi/sl/draw/geom/ExpressionParser.java b/src/java/org/apache/poi/sl/draw/geom/ExpressionParser.java
index f1f0193a89..682869e967 100644
--- a/src/java/org/apache/poi/sl/draw/geom/ExpressionParser.java
+++ b/src/java/org/apache/poi/sl/draw/geom/ExpressionParser.java
@@ -29,7 +29,9 @@ import java.util.regex.Pattern;
* @author Yegor Kozlov
*/
public class ExpressionParser {
- static final HashMap<String, Class> impls = new HashMap<String, Class>();
+ static final HashMap<String, Class<? extends Expression>> impls =
+ new HashMap<String, Class<? extends Expression>>();
+
static {
impls.put("\\*/ +([\\-\\w]+) +([\\-\\w]+) +([\\-\\w]+)", MultiplyDivideExpression.class);
impls.put("\\+- +([\\-\\w]+) +([\\-\\w]+) +([\\-\\w]+)( 0)?", AddSubtractExpression.class);
@@ -56,9 +58,9 @@ public class ExpressionParser {
Pattern ptrn = Pattern.compile(regexp);
Matcher m = ptrn.matcher(str);
if(m.matches()) {
- Class c = impls.get(regexp);
+ Class<? extends Expression> c = impls.get(regexp);
try {
- return (Expression)c.getDeclaredConstructor(Matcher.class).newInstance(m);
+ return c.getDeclaredConstructor(Matcher.class).newInstance(m);
} catch (Exception e){
throw new RuntimeException(e);
}
diff --git a/src/java/org/apache/poi/ss/formula/Formula.java b/src/java/org/apache/poi/ss/formula/Formula.java
index 52b92ec4b1..48c7f391be 100644
--- a/src/java/org/apache/poi/ss/formula/Formula.java
+++ b/src/java/org/apache/poi/ss/formula/Formula.java
@@ -44,19 +44,19 @@ public class Formula {
private Formula(byte[] byteEncoding, int encodedTokenLen) {
_byteEncoding = byteEncoding;
_encodedTokenLen = encodedTokenLen;
- if (false) { // set to true to eagerly check Ptg decoding
- LittleEndianByteArrayInputStream in = new LittleEndianByteArrayInputStream(byteEncoding);
- Ptg.readTokens(encodedTokenLen, in);
- int nUnusedBytes = _byteEncoding.length - in.getReadIndex();
- if (nUnusedBytes > 0) {
- // TODO - this seems to occur when IntersectionPtg is present
- // This example file "IntersectionPtg.xls"
- // used by test: TestIntersectionPtg.testReading()
- // has 10 bytes unused at the end of the formula
- // 10 extra bytes are just 0x01 and 0x00
- System.out.println(nUnusedBytes + " unused bytes at end of formula");
- }
- }
+// if (false) { // set to true to eagerly check Ptg decoding
+// LittleEndianByteArrayInputStream in = new LittleEndianByteArrayInputStream(byteEncoding);
+// Ptg.readTokens(encodedTokenLen, in);
+// int nUnusedBytes = _byteEncoding.length - in.getReadIndex();
+// if (nUnusedBytes > 0) {
+// // TODO - this seems to occur when IntersectionPtg is present
+// // This example file "IntersectionPtg.xls"
+// // used by test: TestIntersectionPtg.testReading()
+// // has 10 bytes unused at the end of the formula
+// // 10 extra bytes are just 0x01 and 0x00
+// System.out.println(nUnusedBytes + " unused bytes at end of formula");
+// }
+// }
}
/**
* Convenience method for {@link #read(int, LittleEndianInput, int)}
diff --git a/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java b/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java
index af4cb81b31..c61594f465 100644
--- a/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java
+++ b/src/java/org/apache/poi/ss/formula/eval/OperandResolver.java
@@ -130,28 +130,28 @@ public final class OperandResolver {
private static ValueEval chooseSingleElementFromAreaInternal(AreaEval ae,
int srcCellRow, int srcCellCol) throws EvaluationException {
- if(false) {
- // this is too simplistic
- if(ae.containsRow(srcCellRow) && ae.containsColumn(srcCellCol)) {
- throw new EvaluationException(ErrorEval.CIRCULAR_REF_ERROR);
- }
- /*
- Circular references are not dealt with directly here, but it is worth noting some issues.
-
- ANY one of the return statements in this method could return a cell that is identical
- to the one immediately being evaluated. The evaluating cell is identified by srcCellRow,
- srcCellRow AND sheet. The sheet is not available in any nearby calling method, so that's
- one reason why circular references are not easy to detect here. (The sheet of the returned
- cell can be obtained from ae if it is an Area3DEval.)
-
- Another reason there's little value in attempting to detect circular references here is
- that only direct circular references could be detected. If the cycle involved two or more
- cells this method could not detect it.
-
- Logic to detect evaluation cycles of all kinds has been coded in EvaluationCycleDetector
- (and FormulaEvaluator).
- */
- }
+// if(false) {
+// // this is too simplistic
+// if(ae.containsRow(srcCellRow) && ae.containsColumn(srcCellCol)) {
+// throw new EvaluationException(ErrorEval.CIRCULAR_REF_ERROR);
+// }
+// /*
+// Circular references are not dealt with directly here, but it is worth noting some issues.
+//
+// ANY one of the return statements in this method could return a cell that is identical
+// to the one immediately being evaluated. The evaluating cell is identified by srcCellRow,
+// srcCellRow AND sheet. The sheet is not available in any nearby calling method, so that's
+// one reason why circular references are not easy to detect here. (The sheet of the returned
+// cell can be obtained from ae if it is an Area3DEval.)
+//
+// Another reason there's little value in attempting to detect circular references here is
+// that only direct circular references could be detected. If the cycle involved two or more
+// cells this method could not detect it.
+//
+// Logic to detect evaluation cycles of all kinds has been coded in EvaluationCycleDetector
+// (and FormulaEvaluator).
+// */
+// }
if (ae.isColumn()) {
if(ae.isRow()) {