From: Josh Micich Date: Wed, 3 Dec 2008 22:34:26 +0000 (+0000) Subject: more generics compiler warnings fixes for poi.ss.formula X-Git-Tag: REL_3_5_BETA5~69 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=8153e57152a76324e2fe50a2b136b0f43ad11230;p=poi.git more generics compiler warnings fixes for poi.ss.formula git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@723104 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/ss/formula/CellCacheEntry.java b/src/java/org/apache/poi/ss/formula/CellCacheEntry.java index 1eb7298a50..610708a3b7 100644 --- a/src/java/org/apache/poi/ss/formula/CellCacheEntry.java +++ b/src/java/org/apache/poi/ss/formula/CellCacheEntry.java @@ -58,7 +58,7 @@ abstract class CellCacheEntry implements ICacheEntry { if (a == null) { return false; } - Class cls = a.getClass(); + Class cls = a.getClass(); if (cls != b.getClass()) { // value type is changing return false; diff --git a/src/java/org/apache/poi/ss/formula/FormulaCellCache.java b/src/java/org/apache/poi/ss/formula/FormulaCellCache.java index 81cd4d4689..63a1da166d 100644 --- a/src/java/org/apache/poi/ss/formula/FormulaCellCache.java +++ b/src/java/org/apache/poi/ss/formula/FormulaCellCache.java @@ -65,9 +65,9 @@ final class FormulaCellCache { } public void applyOperation(IEntryOperation operation) { - Iterator i = _formulaEntriesByCell.values().iterator(); + Iterator i = _formulaEntriesByCell.values().iterator(); while (i.hasNext()) { - operation.processEntry((FormulaCellCacheEntry) i.next()); + operation.processEntry(i.next()); } } } diff --git a/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntry.java b/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntry.java index 06e300811e..a02b772116 100644 --- a/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntry.java +++ b/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntry.java @@ -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() { diff --git a/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntrySet.java b/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntrySet.java index 780d2661e2..d8e573150e 100644 --- a/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntrySet.java +++ b/src/java/org/apache/poi/ss/formula/FormulaCellCacheEntrySet.java @@ -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; } - } diff --git a/src/java/org/apache/poi/ss/formula/FormulaParser.java b/src/java/org/apache/poi/ss/formula/FormulaParser.java index e3e8749101..4551c35853 100644 --- a/src/java/org/apache/poi/ss/formula/FormulaParser.java +++ b/src/java/org/apache/poi/ss/formula/FormulaParser.java @@ -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); } } diff --git a/src/java/org/apache/poi/ss/formula/FormulaRenderer.java b/src/java/org/apache/poi/ss/formula/FormulaRenderer.java index d7c9cd58e6..df078809cf 100644 --- a/src/java/org/apache/poi/ss/formula/FormulaRenderer.java +++ b/src/java/org/apache/poi/ss/formula/FormulaRenderer.java @@ -115,7 +115,7 @@ public class FormulaRenderer { return result; } - private static String[] getOperands(Stack stack, int nOperands) { + private static String[] getOperands(Stack 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 @@ public class FormulaRenderer { + ") operands but got (" + (nOperands - j - 1) + ")"; throw new IllegalStateException(msg); } - operands[j] = (String) stack.pop(); + operands[j] = stack.pop(); } return operands; } diff --git a/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java b/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java index 6ad87a71ab..12c7fcda0b 100755 --- a/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java +++ b/src/java/org/apache/poi/ss/formula/OperationEvaluatorFactory.java @@ -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 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() + ")"); } } diff --git a/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java b/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java index a2a3b97149..fac5715b1d 100644 --- a/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java +++ b/src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java @@ -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() + ")"); }