poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j...@apache.org
Subject svn commit: r723104 - /poi/trunk/src/java/org/apache/poi/ss/formula/
Date Wed, 03 Dec 2008 22:34:27 GMT
Author: josh
Date: Wed Dec  3 14:34:26 2008
New Revision: 723104

URL: http://svn.apache.org/viewvc?rev=723104&view=rev
Log:
more generics compiler warnings fixes for poi.ss.formula

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

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/CellCacheEntry.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/CellCacheEntry.java?rev=723104&r1=723103&r2=723104&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/CellCacheEntry.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/CellCacheEntry.java Wed Dec  3 14:34:26 2008
@@ -58,7 +58,7 @@
 		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;

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/FormulaCellCache.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/FormulaCellCache.java?rev=723104&r1=723103&r2=723104&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/FormulaCellCache.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/FormulaCellCache.java Wed Dec  3 14:34:26
2008
@@ -65,9 +65,9 @@
 	}
 
 	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());
 		}
 	}
 }

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntry.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntry.java?rev=723104&r1=723103&r2=723104&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntry.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntry.java Wed Dec  3 14:34:26
2008
@@ -26,12 +26,11 @@
 
 
 /**
- * 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 @@
 	private FormulaUsedBlankCellSet _usedBlankCellGroup;
 
 	public FormulaCellCacheEntry() {
-		
+		// leave fields un-set
 	}
 	
 	public boolean isInputSensitive() {

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntrySet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntrySet.java?rev=723104&r1=723103&r2=723104&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntrySet.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntrySet.java Wed Dec  3
14:34:26 2008
@@ -27,18 +27,19 @@
  * @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 @@
 		}
 		return false;
 	}
-
 }

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java?rev=723104&r1=723103&r2=723104&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/FormulaParser.java Wed Dec  3 14:34:26 2008
@@ -126,9 +126,9 @@
     }
 
 
-    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 @@
      */
     private char look;
 
-    private FormulaParsingWorkbook book;
+    private FormulaParsingWorkbook _book;
 
 
 
@@ -148,7 +148,7 @@
      * 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 @@
      *  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 @@
     /** 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 @@
     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 @@
             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 @@
             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 @@
             // 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 @@
      * 
      */
     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);
         }
     }

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/FormulaRenderer.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/FormulaRenderer.java?rev=723104&r1=723103&r2=723104&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/FormulaRenderer.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/FormulaRenderer.java Wed Dec  3 14:34:26
2008
@@ -115,7 +115,7 @@
         return result;
     }
 
-    private static String[] getOperands(Stack stack, int nOperands) {
+    private static String[] getOperands(Stack<String> stack, int nOperands) {
         String[] operands = new String[nOperands];
 
         for (int j = nOperands-1; j >= 0; j--) { // reverse iteration because args were
pushed in-order
@@ -124,7 +124,7 @@
                     + ") operands but got (" + (nOperands - j - 1) + ")";
                 throw new IllegalStateException(msg);
             }
-            operands[j] = (String) stack.pop();
+            operands[j] = stack.pop();
         }
         return operands;
     }

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java?rev=723104&r1=723103&r2=723104&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java Wed Dec  3
14:34:26 2008
@@ -24,7 +24,6 @@
 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 @@
 		}
 		OperationEval result;
 
-		Class ptgClass = ptg.getClass();
+		Class<? extends OperationPtg> ptgClass = ptg.getClass();
 
 		result = _instancesByPtgClass.get(ptgClass);
 		if (result != null) {
@@ -123,11 +122,6 @@
 		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() + ")");
 	}
 }

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java?rev=723104&r1=723103&r2=723104&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java Wed Dec  3 14:34:26
2008
@@ -30,6 +30,7 @@
 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 @@
 			// 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() + ")");
 	}



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message