You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by jo...@apache.org on 2008/12/03 20:22:45 UTC

svn commit: r723021 - in /poi/trunk/src/java/org/apache/poi: hssf/record/formula/eval/ ss/formula/

Author: josh
Date: Wed Dec  3 11:22:45 2008
New Revision: 723021

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

Modified:
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/ConcatEval.java
    poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/FuncVarEval.java
    poi/trunk/src/java/org/apache/poi/ss/formula/CellEvaluationFrame.java
    poi/trunk/src/java/org/apache/poi/ss/formula/CollaboratingWorkbooksEnvironment.java
    poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationTracker.java
    poi/trunk/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntry.java
    poi/trunk/src/java/org/apache/poi/ss/formula/FormulaRenderer.java
    poi/trunk/src/java/org/apache/poi/ss/formula/FormulaUsedBlankCellSet.java
    poi/trunk/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java
    poi/trunk/src/java/org/apache/poi/ss/formula/PlainCellCache.java

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/ConcatEval.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/ConcatEval.java?rev=723021&r1=723020&r2=723021&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/ConcatEval.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/ConcatEval.java Wed Dec  3 11:22:45 2008
@@ -18,7 +18,6 @@
 package org.apache.poi.hssf.record.formula.eval;
 
 import org.apache.poi.hssf.record.formula.ConcatPtg;
-import org.apache.poi.hssf.record.formula.Ptg;
 
 /**
  * @author Amol S. Deshmukh < amolweb at ya hoo dot com >
@@ -28,8 +27,8 @@
 
     private ConcatPtg delegate;
 
-    public ConcatEval(Ptg ptg) {
-        this.delegate = (ConcatPtg) ptg;
+    public ConcatEval(ConcatPtg ptg) {
+        delegate = ptg;
     }
 
     public Eval evaluate(Eval[] args, int srcRow, short srcCol) {
@@ -46,7 +45,7 @@
 			        sb.append(sve.getStringValue());
 			    } else if (ve == BlankEval.INSTANCE) {
 			        // do nothing
-			    } else { // must be an error eval
+			    } else {
 			        throw new RuntimeException("Unexpected value type (" 
 			        		+ ve.getClass().getName() + ")");
 			    }

Modified: poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/FuncVarEval.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/FuncVarEval.java?rev=723021&r1=723020&r2=723021&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/FuncVarEval.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/record/formula/eval/FuncVarEval.java Wed Dec  3 11:22:45 2008
@@ -1,49 +1,43 @@
-/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements.  See the NOTICE file distributed with
-* this work for additional information regarding copyright ownership.
-* The ASF licenses this file to You under the Apache License, Version 2.0
-* (the "License"); you may not use this file except in compliance with
-* the License.  You may obtain a copy of the License at
-*
-*     http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
-/*
- * Created on May 8, 2005
- *
- */
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+
 package org.apache.poi.hssf.record.formula.eval;
 
 import org.apache.poi.hssf.record.formula.AbstractFunctionPtg;
-import org.apache.poi.hssf.record.formula.Ptg;
 import org.apache.poi.hssf.record.formula.functions.Function;
 
 /**
  * @author Amol S. Deshmukh < amolweb at ya hoo dot com >
  *  
  */
-public class FuncVarEval extends FunctionEval {
+public final class FuncVarEval extends FunctionEval {
 
     private AbstractFunctionPtg delegate;
 
-    public FuncVarEval(Ptg funcPtg) {
-        delegate = (AbstractFunctionPtg) funcPtg;
+    public FuncVarEval(AbstractFunctionPtg funcPtg) {
+        delegate = funcPtg;
     }
 
     public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
-        Eval retval = null;
         Function f = getFunction();
-        if (f != null)
-            retval = f.evaluate(operands, srcRow, srcCol);
-        else
-            retval = ErrorEval.FUNCTION_NOT_IMPLEMENTED;
-        return retval;
+        if (f == null) {
+			return ErrorEval.FUNCTION_NOT_IMPLEMENTED;
+		}
+		return f.evaluate(operands, srcRow, srcCol);
     }
 
     public int getNumberOfOperands() {

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/CellEvaluationFrame.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/CellEvaluationFrame.java?rev=723021&r1=723020&r2=723021&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/CellEvaluationFrame.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/CellEvaluationFrame.java Wed Dec  3 11:22:45 2008
@@ -28,12 +28,12 @@
 final class CellEvaluationFrame {
 
 	private final FormulaCellCacheEntry _cce;
-	private final Set _sensitiveInputCells;
+	private final Set<CellCacheEntry> _sensitiveInputCells;
 	private FormulaUsedBlankCellSet _usedBlankCellGroup;
 
 	public CellEvaluationFrame(FormulaCellCacheEntry cce) {
 		_cce = cce;
-		_sensitiveInputCells = new HashSet();
+		_sensitiveInputCells = new HashSet<CellCacheEntry>();
 	}
 	public CellCacheEntry getCCE() {
 		return _cce;

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/CollaboratingWorkbooksEnvironment.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/CollaboratingWorkbooksEnvironment.java?rev=723021&r1=723020&r2=723021&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/CollaboratingWorkbooksEnvironment.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/CollaboratingWorkbooksEnvironment.java Wed Dec  3 11:22:45 2008
@@ -37,12 +37,12 @@
 	
 	public static final CollaboratingWorkbooksEnvironment EMPTY = new CollaboratingWorkbooksEnvironment();
 	
-	private final Map _evaluatorsByName;
+	private final Map<String, WorkbookEvaluator> _evaluatorsByName;
 	private final WorkbookEvaluator[] _evaluators;
 
 	private boolean _unhooked;
 	private CollaboratingWorkbooksEnvironment() {
-		_evaluatorsByName = Collections.EMPTY_MAP;
+		_evaluatorsByName = Collections.emptyMap();
 		_evaluators = new WorkbookEvaluator[0];
 	}
 	public static void setup(String[] workbookNames, WorkbookEvaluator[] evaluators) {
@@ -58,8 +58,8 @@
 	}
 
 	private CollaboratingWorkbooksEnvironment(String[] workbookNames, WorkbookEvaluator[] evaluators, int nItems) {
-		Map m = new HashMap(nItems * 3 / 2);
-		IdentityHashMap uniqueEvals = new IdentityHashMap(nItems * 3 / 2);
+		Map<String, WorkbookEvaluator> m = new HashMap<String, WorkbookEvaluator>(nItems * 3 / 2);
+		IdentityHashMap<WorkbookEvaluator, String> uniqueEvals = new IdentityHashMap<WorkbookEvaluator, String>(nItems * 3 / 2);
 		for(int i=0; i<nItems; i++) {
 			String wbName = workbookNames[i];
 			WorkbookEvaluator wbEval = evaluators[i];
@@ -102,7 +102,7 @@
 		
 	}
 	private void unhookOldEnvironments(WorkbookEvaluator[] evaluators) {
-		Set oldEnvs = new HashSet();
+		Set<CollaboratingWorkbooksEnvironment> oldEnvs = new HashSet<CollaboratingWorkbooksEnvironment>();
 		for(int i=0; i<evaluators.length; i++) {
 			oldEnvs.add(evaluators[i].getEnvironment());
 		}
@@ -130,7 +130,7 @@
 		if (_unhooked) {
 			throw new IllegalStateException("This environment has been unhooked");
 		}
-		WorkbookEvaluator result = (WorkbookEvaluator) _evaluatorsByName.get(workbookName);
+		WorkbookEvaluator result = _evaluatorsByName.get(workbookName);
 		if (result == null) {
 			StringBuffer sb = new StringBuffer(256);
 			sb.append("Could not resolve external workbook name '").append(workbookName).append("'.");
@@ -138,7 +138,7 @@
 				sb.append(" Workbook environment has not been set up.");
 			} else {
 				sb.append(" The following workbook names are valid: (");
-				Iterator i = _evaluatorsByName.keySet().iterator();
+				Iterator<String> i = _evaluatorsByName.keySet().iterator();
 				int count=0;
 				while(i.hasNext()) {
 					if (count++>0) {

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationTracker.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationTracker.java?rev=723021&r1=723020&r2=723021&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationTracker.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/EvaluationTracker.java Wed Dec  3 11:22:45 2008
@@ -37,14 +37,14 @@
  */
 final class EvaluationTracker {
 	// TODO - consider deleting this class and letting CellEvaluationFrame take care of itself
-	private final List _evaluationFrames;
-	private final Set _currentlyEvaluatingCells;
+	private final List<CellEvaluationFrame> _evaluationFrames;
+	private final Set<FormulaCellCacheEntry> _currentlyEvaluatingCells;
 	private final EvaluationCache _cache;
 
 	public EvaluationTracker(EvaluationCache cache) {
 		_cache = cache;
-		_evaluationFrames = new ArrayList();
-		_currentlyEvaluatingCells = new HashSet();
+		_evaluationFrames = new ArrayList<CellEvaluationFrame>();
+		_currentlyEvaluatingCells = new HashSet<FormulaCellCacheEntry>();
 	}
 
 	/**
@@ -79,7 +79,7 @@
 		if (nFrames < 1) {
 			throw new IllegalStateException("Call to endEvaluate without matching call to startEvaluate");
 		}
-		CellEvaluationFrame frame = (CellEvaluationFrame) _evaluationFrames.get(nFrames-1);
+		CellEvaluationFrame frame = _evaluationFrames.get(nFrames-1);
 
 		frame.updateFormulaResult(result);
 	}
@@ -102,7 +102,7 @@
 		}
 
 		nFrames--;
-		CellEvaluationFrame frame = (CellEvaluationFrame) _evaluationFrames.get(nFrames);
+		CellEvaluationFrame frame = _evaluationFrames.get(nFrames);
 		if (cce != frame.getCCE()) {
 			throw new IllegalStateException("Wrong cell specified. ");
 		}
@@ -117,7 +117,7 @@
 		if (prevFrameIndex < 0) {
 			// Top level frame, there is no 'cell' above this frame that is using the current cell
 		} else {
-			CellEvaluationFrame consumingFrame = (CellEvaluationFrame) _evaluationFrames.get(prevFrameIndex);
+			CellEvaluationFrame consumingFrame = _evaluationFrames.get(prevFrameIndex);
 			consumingFrame.addSensitiveInputCell(cce);
 		}
 	}
@@ -129,7 +129,7 @@
 		if (prevFrameIndex < 0) {
 			// Top level frame, there is no 'cell' above this frame that is using the current cell
 		} else {
-			CellEvaluationFrame consumingFrame = (CellEvaluationFrame) _evaluationFrames.get(prevFrameIndex);
+			CellEvaluationFrame consumingFrame = _evaluationFrames.get(prevFrameIndex);
 			if (value == BlankEval.INSTANCE) {
 				consumingFrame.addUsedBlankCell(bookIndex, sheetIndex, rowIndex, columnIndex);
 			} else {

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=723021&r1=723020&r2=723021&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 11:22:45 2008
@@ -87,11 +87,11 @@
 		if (nPrevUsed < 1) {
 			return;
 		}
-		Set usedSet;
+		Set<CellCacheEntry> usedSet;
 		if (nUsed < 1) {
-			usedSet = Collections.EMPTY_SET;
+			usedSet = Collections.emptySet();
 		} else {
-			usedSet = new HashSet(nUsed * 3 / 2);
+			usedSet = new HashSet<CellCacheEntry>(nUsed * 3 / 2);
 			for (int i = 0; i < nUsed; i++) {
 				usedSet.add(usedCells[i]);
 			}

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=723021&r1=723020&r2=723021&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 11:22:45 2008
@@ -47,7 +47,7 @@
         if (ptgs == null || ptgs.length == 0) {
             throw new IllegalArgumentException("ptgs must not be null");
         }
-        Stack stack = new Stack();
+        Stack<String> stack = new Stack<String>();
 
         for (int i=0 ; i < ptgs.length; i++) {
             Ptg ptg = ptgs[i];
@@ -59,7 +59,7 @@
                 continue;
             }
             if (ptg instanceof ParenthesisPtg) {
-                String contents = (String)stack.pop();
+                String contents = stack.pop();
                 stack.push ("(" + contents + ")");
                 continue;
             }
@@ -106,7 +106,7 @@
             // stack.push(). So this is either an internal error or impossible.
             throw new IllegalStateException("Stack underflow");
         }
-        String result = (String) stack.pop();
+        String result = stack.pop();
         if(!stack.isEmpty()) {
             // Might be caused by some tokens like AttrPtg and Mem*Ptg, which really shouldn't
             // put anything on the stack

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/FormulaUsedBlankCellSet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/FormulaUsedBlankCellSet.java?rev=723021&r1=723020&r2=723021&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/FormulaUsedBlankCellSet.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/FormulaUsedBlankCellSet.java Wed Dec  3 11:22:45 2008
@@ -49,14 +49,14 @@
 	}
 
 	private static final class BlankCellSheetGroup {
-		private final List _rectangleGroups;
+		private final List<BlankCellRectangleGroup> _rectangleGroups;
 		private int _currentRowIndex;
 		private int _firstColumnIndex;
 		private int _lastColumnIndex;
 		private BlankCellRectangleGroup _currentRectangleGroup;
 
 		public BlankCellSheetGroup() {
-			_rectangleGroups = new ArrayList();
+			_rectangleGroups = new ArrayList<BlankCellRectangleGroup>();
 			_currentRowIndex = -1;
 		}
 
@@ -87,7 +87,7 @@
 
 		public boolean containsCell(int rowIndex, int columnIndex) {
 			for (int i=_rectangleGroups.size()-1; i>=0; i--) {
-				BlankCellRectangleGroup bcrg = (BlankCellRectangleGroup) _rectangleGroups.get(i);
+				BlankCellRectangleGroup bcrg = _rectangleGroups.get(i);
 				if (bcrg.containsCell(rowIndex, columnIndex)) {
 					return true;
 				}
@@ -157,10 +157,10 @@
 		}
 	}
 
-	private final Map _sheetGroupsByBookSheet;
+	private final Map<BookSheetKey, BlankCellSheetGroup> _sheetGroupsByBookSheet;
 
 	public FormulaUsedBlankCellSet() {
-		_sheetGroupsByBookSheet = new HashMap();
+		_sheetGroupsByBookSheet = new HashMap<BookSheetKey, BlankCellSheetGroup>();
 	}
 
 	public void addCell(int bookIndex, int sheetIndex, int rowIndex, int columnIndex) {
@@ -171,7 +171,7 @@
 	private BlankCellSheetGroup getSheetGroup(int bookIndex, int sheetIndex) {
 		BookSheetKey key = new BookSheetKey(bookIndex, sheetIndex);
 
-		BlankCellSheetGroup result = (BlankCellSheetGroup) _sheetGroupsByBookSheet.get(key);
+		BlankCellSheetGroup result = _sheetGroupsByBookSheet.get(key);
 		if (result == null) {
 			result = new BlankCellSheetGroup();
 			_sheetGroupsByBookSheet.put(key, result);
@@ -180,7 +180,7 @@
 	}
 
 	public boolean containsCell(BookSheetKey key, int rowIndex, int columnIndex) {
-		BlankCellSheetGroup bcsg = (BlankCellSheetGroup) _sheetGroupsByBookSheet.get(key);
+		BlankCellSheetGroup bcsg = _sheetGroupsByBookSheet.get(key);
 		if (bcsg == null) {
 			return false;
 		}

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=723021&r1=723020&r2=723021&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 11:22:45 2008
@@ -17,9 +17,6 @@
 
 package org.apache.poi.ss.formula;
 
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Modifier;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -66,80 +63,38 @@
 /**
  * This class creates <tt>OperationEval</tt> instances to help evaluate <tt>OperationPtg</tt>
  * formula tokens.
- * 
+ *
  * @author Josh Micich
  */
 final class OperationEvaluatorFactory {
-	private static final Class[] OPERATION_CONSTRUCTOR_CLASS_ARRAY = new Class[] { Ptg.class };
-	// TODO - use singleton instances directly instead of reflection
-	private static final Map _constructorsByPtgClass = initialiseConstructorsMap();
-	private static final Map _instancesByPtgClass = initialiseInstancesMap();
-	
+
+	private static final Map<Class<? extends Ptg>, OperationEval> _instancesByPtgClass = initialiseInstancesMap();
+
 	private OperationEvaluatorFactory() {
 		// no instances of this class
 	}
-	
-	private static Map initialiseConstructorsMap() {
-		Map m = new HashMap(32);
-		add(m, ConcatPtg.class, ConcatEval.class);
-		add(m, FuncPtg.class, FuncVarEval.class);
-		add(m, FuncVarPtg.class, FuncVarEval.class);
-		return m;
-	}
-	private static Map initialiseInstancesMap() {
-		Map m = new HashMap(32);
-		add(m, EqualPtg.class, EqualEval.instance);
-		add(m, GreaterEqualPtg.class, GreaterEqualEval.instance);
-		add(m, GreaterThanPtg.class, GreaterThanEval.instance);
-		add(m, LessEqualPtg.class, LessEqualEval.instance);
-		add(m, LessThanPtg.class, LessThanEval.instance);
-		add(m, NotEqualPtg.class, NotEqualEval.instance);
-
-		add(m, AddPtg.class, AddEval.instance);
-		add(m, DividePtg.class, DivideEval.instance);
-		add(m, MultiplyPtg.class, MultiplyEval.instance);
-		add(m, PercentPtg.class, PercentEval.instance);
-		add(m, PowerPtg.class, PowerEval.instance);
-		add(m, SubtractPtg.class, SubtractEval.instance);
-		add(m, UnaryMinusPtg.class, UnaryMinusEval.instance);
-		add(m, UnaryPlusPtg.class, UnaryPlusEval.instance);
-		add(m, RangePtg.class, RangeEval.instance);
-		return m;
-	}
 
-	private static void add(Map m, Class ptgClass, OperationEval evalInstance) {
-		if(!Ptg.class.isAssignableFrom(ptgClass)) {
-			throw new IllegalArgumentException("Expected Ptg subclass");
-		}
-		m.put(ptgClass, evalInstance);
-	}
-
-	private static void add(Map m, Class ptgClass, Class evalClass) {
-		// perform some validation now, to keep later exception handlers simple
-		if(!Ptg.class.isAssignableFrom(ptgClass)) {
-			throw new IllegalArgumentException("Expected Ptg subclass");
-		}
-		
-		if(!OperationEval.class.isAssignableFrom(evalClass)) {
-			throw new IllegalArgumentException("Expected OperationEval subclass");
-		}
-		if (!Modifier.isPublic(evalClass.getModifiers())) {
-			throw new RuntimeException("Eval class must be public");
-		}
-		if (Modifier.isAbstract(evalClass.getModifiers())) {
-			throw new RuntimeException("Eval class must not be abstract");
-		}
-		
-		Constructor constructor;
-		try {
-			constructor = evalClass.getDeclaredConstructor(OPERATION_CONSTRUCTOR_CLASS_ARRAY);
-		} catch (NoSuchMethodException e) {
-			throw new RuntimeException("Missing constructor");
-		}
-		if (!Modifier.isPublic(constructor.getModifiers())) {
-			throw new RuntimeException("Eval constructor must be public");
-		}
-		m.put(ptgClass, constructor);
+	private static Map<Class<? extends Ptg>, OperationEval> initialiseInstancesMap() {
+		Map<Class<? extends Ptg>, OperationEval> m = new HashMap<Class<? extends Ptg>, OperationEval>(32);
+		m.put(EqualPtg.class, EqualEval.instance);
+
+		m.put(EqualPtg.class, EqualEval.instance);
+		m.put(GreaterEqualPtg.class, GreaterEqualEval.instance);
+		m.put(GreaterThanPtg.class, GreaterThanEval.instance);
+		m.put(LessEqualPtg.class, LessEqualEval.instance);
+		m.put(LessThanPtg.class, LessThanEval.instance);
+		m.put(NotEqualPtg.class, NotEqualEval.instance);
+
+		m.put(AddPtg.class, AddEval.instance);
+		m.put(DividePtg.class, DivideEval.instance);
+		m.put(MultiplyPtg.class, MultiplyEval.instance);
+		m.put(PercentPtg.class, PercentEval.instance);
+		m.put(PowerPtg.class, PowerEval.instance);
+		m.put(SubtractPtg.class, SubtractEval.instance);
+		m.put(UnaryMinusPtg.class, UnaryMinusEval.instance);
+		m.put(UnaryPlusPtg.class, UnaryPlusEval.instance);
+		m.put(RangePtg.class, RangeEval.instance);
+		return m;
 	}
 
 	/**
@@ -150,38 +105,29 @@
 		if(ptg == null) {
 			throw new IllegalArgumentException("ptg must not be null");
 		}
-		Object result;
-		
+		OperationEval result;
+
 		Class ptgClass = ptg.getClass();
-		
+
 		result = _instancesByPtgClass.get(ptgClass);
 		if (result != null) {
-			return (OperationEval) result;
+			return  result;
 		}
 		
-		
-		Constructor constructor = (Constructor) _constructorsByPtgClass.get(ptgClass);
-		if(constructor == null) {
-			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() + ")");
+		if (ptgClass == FuncPtg.class) {
+			return new FuncVarEval((FuncPtg)ptg);
 		}
-		
-		Object[] initargs = { ptg };
-		try {
-			result = constructor.newInstance(initargs);
-		} catch (IllegalArgumentException e) {
-			throw new RuntimeException(e);
-		} catch (InstantiationException e) {
-			throw new RuntimeException(e);
-		} catch (IllegalAccessException e) {
-			throw new RuntimeException(e);
-		} catch (InvocationTargetException e) {
-			throw new RuntimeException(e);
+		if (ptgClass == FuncVarPtg.class) {
+			return new FuncVarEval((FuncVarPtg)ptg);
+		}
+		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");
 		}
-		return (OperationEval) result;
+		throw new RuntimeException("Unexpected operation ptg class (" + ptgClass.getName() + ")");
 	}
 }

Modified: poi/trunk/src/java/org/apache/poi/ss/formula/PlainCellCache.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/ss/formula/PlainCellCache.java?rev=723021&r1=723020&r2=723021&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/ss/formula/PlainCellCache.java (original)
+++ poi/trunk/src/java/org/apache/poi/ss/formula/PlainCellCache.java Wed Dec  3 11:22:45 2008
@@ -64,10 +64,10 @@
 		}
 	}
 
-	private Map _plainValueEntriesByLoc;
+	private Map<Loc, PlainValueCellCacheEntry> _plainValueEntriesByLoc;
 
 	public PlainCellCache() {
-		_plainValueEntriesByLoc = new HashMap();
+		_plainValueEntriesByLoc = new HashMap<Loc, PlainValueCellCacheEntry>();
 	}
 	public void put(Loc key, PlainValueCellCacheEntry cce) {
 		_plainValueEntriesByLoc.put(key, cce);
@@ -76,7 +76,7 @@
 		_plainValueEntriesByLoc.clear();
 	}
 	public PlainValueCellCacheEntry get(Loc key) {
-		return (PlainValueCellCacheEntry) _plainValueEntriesByLoc.get(key);
+		return _plainValueEntriesByLoc.get(key);
 	}
 	public void remove(Loc key) {
 		_plainValueEntriesByLoc.remove(key);



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