]> source.dussan.org Git - poi.git/commitdiff
more generics compiler warnings fixes for poi.ss.formula
authorJosh Micich <josh@apache.org>
Wed, 3 Dec 2008 22:34:26 +0000 (22:34 +0000)
committerJosh Micich <josh@apache.org>
Wed, 3 Dec 2008 22:34:26 +0000 (22:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@723104 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/ss/formula/CellCacheEntry.java
src/java/org/apache/poi/ss/formula/FormulaCellCache.java
src/java/org/apache/poi/ss/formula/FormulaCellCacheEntry.java
src/java/org/apache/poi/ss/formula/FormulaCellCacheEntrySet.java
src/java/org/apache/poi/ss/formula/FormulaParser.java
src/java/org/apache/poi/ss/formula/FormulaRenderer.java
src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java
src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java

index 1eb7298a50d082151ba8ec72a33ba13809ddb14f..610708a3b7c616239cc46519ac7635fa86c4559f 100644 (file)
@@ -58,7 +58,7 @@ abstract class CellCacheEntry implements ICacheEntry {
                if (a == null) {
                        return false;
                }
-               Class cls = a.getClass();
+               Class<? extends ValueEval> cls = a.getClass();
                if (cls != b.getClass()) {
                        // value type is changing
                        return false;
index 81cd4d46897a92e0860a849268cfced04327d9a2..63a1da166d1b70c86a36e94b2552e6ad5ac15a90 100644 (file)
@@ -65,9 +65,9 @@ final class FormulaCellCache {
        }
 
        public void applyOperation(IEntryOperation operation) {
-               Iterator i = _formulaEntriesByCell.values().iterator();
+               Iterator<FormulaCellCacheEntry> i = _formulaEntriesByCell.values().iterator();
                while (i.hasNext()) {
-                       operation.processEntry((FormulaCellCacheEntry) i.next());
+                       operation.processEntry(i.next());
                }
        }
 }
index 06e300811ebddd60b047b163100153921498931b..a02b772116924268160385591939751adbab5b92 100644 (file)
@@ -26,12 +26,11 @@ import org.apache.poi.ss.formula.FormulaUsedBlankCellSet.BookSheetKey;
 
 
 /**
- * Stores the cached result of a formula evaluation, along with the set of sensititive input cells
+ * Stores the cached result of a formula evaluation, along with the set of sensitive input cells
  * 
  * @author Josh Micich
  */
 final class FormulaCellCacheEntry extends CellCacheEntry {
-       public static final FormulaCellCacheEntry[] EMPTY_ARRAY = { };
        
        /**
         * Cells 'used' in the current evaluation of the formula corresponding to this cache entry
@@ -43,7 +42,7 @@ final class FormulaCellCacheEntry extends CellCacheEntry {
        private FormulaUsedBlankCellSet _usedBlankCellGroup;
 
        public FormulaCellCacheEntry() {
-               
+               // leave fields un-set
        }
        
        public boolean isInputSensitive() {
index 780d2661e251b50219e738e92beb85be8e5bccc5..d8e573150ecc39080f36a877e6e82aeca7ac56df 100644 (file)
@@ -27,18 +27,19 @@ package org.apache.poi.ss.formula;
  * @author Josh Micich
  */
 final class FormulaCellCacheEntrySet {
+       private static final FormulaCellCacheEntry[] EMPTY_ARRAY = { };
 
        private int _size;
        private FormulaCellCacheEntry[] _arr;
 
        public FormulaCellCacheEntrySet() {
-               _arr = FormulaCellCacheEntry.EMPTY_ARRAY;
+               _arr = EMPTY_ARRAY;
        }
 
        public FormulaCellCacheEntry[] toArray() {
                int nItems = _size;
                if (nItems < 1) {
-                       return FormulaCellCacheEntry.EMPTY_ARRAY;
+                       return EMPTY_ARRAY;
                }
                FormulaCellCacheEntry[] result = new FormulaCellCacheEntry[nItems];
                int j=0;
@@ -152,5 +153,4 @@ final class FormulaCellCacheEntrySet {
                }
                return false;
        }
-
 }
index e3e8749101ca51222efadba2933de3b8747b97e0..4551c35853021551c5a6688177740ecb81bbf21f 100644 (file)
@@ -126,9 +126,9 @@ public final class FormulaParser {
     }
 
 
-    private final String formulaString;
-    private final int formulaLength;
-    private int pointer;
+    private final String _formulaString;
+    private final int _formulaLength;
+    private int _pointer;
 
     private ParseNode _rootNode;
 
@@ -140,7 +140,7 @@ public final class FormulaParser {
      */
     private char look;
 
-    private FormulaParsingWorkbook book;
+    private FormulaParsingWorkbook _book;
 
 
 
@@ -148,7 +148,7 @@ public final class FormulaParser {
      * Create the formula parser, with the string that is to be
      *  parsed against the supplied workbook.
      * A later call the parse() method to return ptg list in
-     *  rpn order, then call the getRPNPtg() to retrive the
+     *  rpn order, then call the getRPNPtg() to retrieve the
      *  parse results.
      * This class is recommended only for single threaded use.
      *
@@ -157,10 +157,10 @@ public final class FormulaParser {
      *  usermodel.HSSFFormulaEvaluator
      */
     private FormulaParser(String formula, FormulaParsingWorkbook book){
-        formulaString = formula;
-        pointer=0;
-        this.book = book;
-        formulaLength = formulaString.length();
+        _formulaString = formula;
+        _pointer=0;
+        _book = book;
+        _formulaLength = _formulaString.length();
     }
 
     public static Ptg[] parse(String formula, FormulaParsingWorkbook book) {
@@ -176,17 +176,17 @@ public final class FormulaParser {
     /** Read New Character From Input Stream */
     private void GetChar() {
         // Check to see if we've walked off the end of the string.
-        if (pointer > formulaLength) {
+        if (_pointer > _formulaLength) {
             throw new RuntimeException("too far");
         }
-        if (pointer < formulaLength) {
-            look=formulaString.charAt(pointer);
+        if (_pointer < _formulaLength) {
+            look=_formulaString.charAt(_pointer);
         } else {
             // Just return if so and reset 'look' to something to keep
             // SkipWhitespace from spinning
             look = (char)0;
         }
-        pointer++;
+        _pointer++;
         //System.out.println("Got char: "+ look);
     }
 
@@ -194,12 +194,12 @@ public final class FormulaParser {
     private RuntimeException expected(String s) {
         String msg;
 
-        if (look == '=' && formulaString.substring(0, pointer-1).trim().length() < 1) {
-            msg = "The specified formula '" + formulaString
+        if (look == '=' && _formulaString.substring(0, _pointer-1).trim().length() < 1) {
+            msg = "The specified formula '" + _formulaString
                 + "' starts with an equals sign which is not allowed.";
         } else {
-            msg = "Parse error near char " + (pointer-1) + " '" + look + "'"
-                + " in specified formula '" + formulaString + "'. Expected "
+            msg = "Parse error near char " + (_pointer-1) + " '" + look + "'"
+                + " in specified formula '" + _formulaString + "'. Expected "
                 + s;
         }
         return new FormulaParseException(msg);
@@ -413,7 +413,7 @@ public final class FormulaParser {
             new FormulaParseException("Name '" + name
                 + "' does not look like a cell reference or named range");
         }
-        EvaluationName evalName = book.getName(name);
+        EvaluationName evalName = _book.getName(name);
         if (evalName == null) {
             throw new FormulaParseException("Specified named range '"
                     + name + "' does not exist in the current workbook.");
@@ -458,9 +458,9 @@ public final class FormulaParser {
             int pos = name.lastIndexOf(']'); // safe because sheet names never have ']'
             String wbName = name.substring(1, pos);
             String sheetName = name.substring(pos+1);
-            return book.getExternalSheetIndex(wbName, sheetName);
+            return _book.getExternalSheetIndex(wbName, sheetName);
         }
-        return book.getExternalSheetIndex(name);
+        return _book.getExternalSheetIndex(name);
     }
 
     /**
@@ -516,10 +516,10 @@ public final class FormulaParser {
             // user defined function
             // in the token tree, the name is more or less the first argument
 
-            EvaluationName hName = book.getName(name);
+            EvaluationName hName = _book.getName(name);
             if (hName == null) {
 
-                nameToken = book.getNameXPtg(name);
+                nameToken = _book.getNameXPtg(name);
                 if (nameToken == null) {
                     throw new FormulaParseException("Name '" + name
                             + "' is completely unknown in the current workbook");
@@ -1092,13 +1092,13 @@ end;
      * 
      */
     private void parse() {
-        pointer=0;
+        _pointer=0;
         GetChar();
         _rootNode = unionExpression();
 
-        if(pointer <= formulaLength) {
-            String msg = "Unused input [" + formulaString.substring(pointer-1)
-                + "] after attempting to parse the formula [" + formulaString + "]";
+        if(_pointer <= _formulaLength) {
+            String msg = "Unused input [" + _formulaString.substring(_pointer-1)
+                + "] after attempting to parse the formula [" + _formulaString + "]";
             throw new FormulaParseException(msg);
         }
     }
index d7c9cd58e6b6caf247ca2c7ff02130d2325ed4ca..df078809cf30af2e2c826c757242a8491ff4c311 100644 (file)
@@ -115,7 +115,7 @@ public class FormulaRenderer {
         return result;\r
     }\r
 \r
-    private static String[] getOperands(Stack stack, int nOperands) {\r
+    private static String[] getOperands(Stack<String> stack, int nOperands) {\r
         String[] operands = new String[nOperands];\r
 \r
         for (int j = nOperands-1; j >= 0; j--) { // reverse iteration because args were pushed in-order\r
@@ -124,7 +124,7 @@ public class FormulaRenderer {
                     + ") operands but got (" + (nOperands - j - 1) + ")";\r
                 throw new IllegalStateException(msg);\r
             }\r
-            operands[j] = (String) stack.pop();\r
+            operands[j] = stack.pop();\r
         }\r
         return operands;\r
     }\r
index 6ad87a71ab6bdbd0b451cc6b9ed68e2d70acb321..12c7fcda0b6f2a19587a2b023f071988024f6a67 100755 (executable)
@@ -24,7 +24,6 @@ import org.apache.poi.hssf.record.formula.AddPtg;
 import org.apache.poi.hssf.record.formula.ConcatPtg;
 import org.apache.poi.hssf.record.formula.DividePtg;
 import org.apache.poi.hssf.record.formula.EqualPtg;
-import org.apache.poi.hssf.record.formula.ExpPtg;
 import org.apache.poi.hssf.record.formula.FuncPtg;
 import org.apache.poi.hssf.record.formula.FuncVarPtg;
 import org.apache.poi.hssf.record.formula.GreaterEqualPtg;
@@ -107,7 +106,7 @@ final class OperationEvaluatorFactory {
                }
                OperationEval result;
 
-               Class ptgClass = ptg.getClass();
+               Class<? extends OperationPtg> ptgClass = ptg.getClass();
 
                result = _instancesByPtgClass.get(ptgClass);
                if (result != null) {
@@ -123,11 +122,6 @@ final class OperationEvaluatorFactory {
                if (ptgClass == ConcatPtg.class) {
                        return new ConcatEval((ConcatPtg)ptg);
                }
-               if(ptgClass == ExpPtg.class) {
-                       // ExpPtg is used for array formulas and shared formulas.
-                       // it is currently unsupported, and may not even get implemented here
-                       throw new RuntimeException("ExpPtg currently not supported");
-               }
                throw new RuntimeException("Unexpected operation ptg class (" + ptgClass.getName() + ")");
        }
 }
index a2a3b97149685c31ebc934539e41eb491a1c4f11..fac5715b1dd1771024c1dd740993c227ade1d3ee 100644 (file)
@@ -30,6 +30,7 @@ import org.apache.poi.hssf.record.formula.ControlPtg;
 import org.apache.poi.hssf.record.formula.DeletedArea3DPtg;
 import org.apache.poi.hssf.record.formula.DeletedRef3DPtg;
 import org.apache.poi.hssf.record.formula.ErrPtg;
+import org.apache.poi.hssf.record.formula.ExpPtg;
 import org.apache.poi.hssf.record.formula.FuncVarPtg;
 import org.apache.poi.hssf.record.formula.IntPtg;
 import org.apache.poi.hssf.record.formula.MemErrPtg;
@@ -456,6 +457,11 @@ public final class WorkbookEvaluator {
                        // In any case, formulas are re-parsed before execution, so UnknownPtg should not get here
                        throw new RuntimeException("UnknownPtg not allowed");
                }
+               if (ptg instanceof ExpPtg) {
+                       // ExpPtg is used for array formulas and shared formulas.
+                       // it is currently unsupported, and may not even get implemented here
+                       throw new RuntimeException("ExpPtg currently not supported");
+               }
 
                throw new RuntimeException("Unexpected ptg class (" + ptg.getClass().getName() + ")");
        }