]> source.dussan.org Git - poi.git/commitdiff
initial work on removing obsolete Eval interface
authorJosh Micich <josh@apache.org>
Mon, 17 Aug 2009 18:55:05 +0000 (18:55 +0000)
committerJosh Micich <josh@apache.org>
Mon, 17 Aug 2009 18:55:05 +0000 (18:55 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@805091 13f79535-47bb-0310-9956-ffa450edef68

26 files changed:
src/java/org/apache/poi/hssf/record/formula/atp/AnalysisToolPak.java
src/java/org/apache/poi/hssf/record/formula/atp/ParityFunction.java
src/java/org/apache/poi/hssf/record/formula/atp/YearFrac.java
src/java/org/apache/poi/hssf/record/formula/eval/ConcatEval.java
src/java/org/apache/poi/hssf/record/formula/eval/FunctionEval.java
src/java/org/apache/poi/hssf/record/formula/eval/OperationEval.java
src/java/org/apache/poi/hssf/record/formula/eval/PercentEval.java
src/java/org/apache/poi/hssf/record/formula/eval/RangeEval.java
src/java/org/apache/poi/hssf/record/formula/eval/RelationalOperationEval.java
src/java/org/apache/poi/hssf/record/formula/eval/TwoOperandNumericOperation.java
src/java/org/apache/poi/hssf/record/formula/eval/UnaryMinusEval.java
src/java/org/apache/poi/hssf/record/formula/eval/UnaryPlusEval.java
src/java/org/apache/poi/hssf/record/formula/eval/UserDefinedFunction.java
src/java/org/apache/poi/hssf/record/formula/functions/FreeRefFunction.java
src/java/org/apache/poi/hssf/record/formula/functions/Indirect.java
src/java/org/apache/poi/ss/formula/WorkbookEvaluator.java
src/testcases/org/apache/poi/hssf/record/formula/eval/TestDivideEval.java
src/testcases/org/apache/poi/hssf/record/formula/eval/TestEqualEval.java
src/testcases/org/apache/poi/hssf/record/formula/eval/TestMinusZeroResult.java
src/testcases/org/apache/poi/hssf/record/formula/eval/TestPercentEval.java
src/testcases/org/apache/poi/hssf/record/formula/eval/TestRangeEval.java
src/testcases/org/apache/poi/hssf/record/formula/eval/TestUnaryPlusEval.java
src/testcases/org/apache/poi/hssf/record/formula/functions/NumericFunctionInvoker.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestCountFuncs.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestIndex.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestRowCol.java

index 104b7a86d22fef9f2655909f1a9018621f294e50..96a43170e762ba6f9829fad17a6c56f98edc820b 100644 (file)
@@ -35,12 +35,12 @@ public final class AnalysisToolPak {
                        _functionName = functionName;
                }
 
-               public ValueEval evaluate(Eval[] args, EvaluationWorkbook workbook, int srcCellSheet,
+               public ValueEval evaluate(ValueEval[] args, EvaluationWorkbook workbook, int srcCellSheet,
                                int srcCellRow, int srcCellCol) {
                        throw new NotImplementedException(_functionName);
                }
        };
-       
+
        private static Map<String, FreeRefFunction> _functionsByName = createFunctionsMap();
 
        private AnalysisToolPak() {
@@ -50,7 +50,7 @@ public final class AnalysisToolPak {
        public static FreeRefFunction findFunction(String name) {
                return _functionsByName.get(name);
        }
-       
+
        private static Map<String, FreeRefFunction> createFunctionsMap() {
                Map<String, FreeRefFunction> m = new HashMap<String, FreeRefFunction>(100);
 
@@ -147,7 +147,7 @@ public final class AnalysisToolPak {
                r(m, "YIELD", null);
                r(m, "YIELDDISC", null);
                r(m, "YIELDMAT", null);
-               
+
                return m;
        }
 
index b907d89eabebcb2e3b2f416f44d9f99acb51265b..04ba61e120e878bb90c0424fa4169032272498ef 100644 (file)
@@ -27,7 +27,7 @@ import org.apache.poi.hssf.record.formula.functions.FreeRefFunction;
 import org.apache.poi.ss.formula.EvaluationWorkbook;
 /**
  * Implementation of Excel 'Analysis ToolPak' function ISEVEN() ISODD()<br/>
- * 
+ *
  * @author Josh Micich
  */
 final class ParityFunction implements FreeRefFunction {
@@ -35,17 +35,17 @@ final class ParityFunction implements FreeRefFunction {
        public static final FreeRefFunction IS_EVEN = new ParityFunction(0);
        public static final FreeRefFunction IS_ODD = new ParityFunction(1);
        private final int _desiredParity;
-       
+
        private ParityFunction(int desiredParity) {
                _desiredParity = desiredParity;
        }
 
-       public ValueEval evaluate(Eval[] args, EvaluationWorkbook workbook, int srcCellSheet, int srcCellRow,
+       public ValueEval evaluate(ValueEval[] args, EvaluationWorkbook workbook, int srcCellSheet, int srcCellRow,
                        int srcCellCol) {
                if (args.length != 1) {
-                       return ErrorEval.VALUE_INVALID;  
+                       return ErrorEval.VALUE_INVALID;
                }
-               
+
                int val;
                try {
                        val = evaluateArgParity(args[0], srcCellRow, srcCellCol);
@@ -58,7 +58,7 @@ final class ParityFunction implements FreeRefFunction {
 
        private static int evaluateArgParity(Eval arg, int srcCellRow, int srcCellCol) throws EvaluationException {
                ValueEval ve = OperandResolver.getSingleValue(arg, srcCellRow, (short)srcCellCol);
-               
+
                double d = OperandResolver.coerceValueToDouble(ve);
                if (d < 0) {
                        d = -d;
index 7c87fe25216dd91076724fa2351a846cc1c9ca26..ea2dc380157fa4213f66df1bad5d97d732e0f3c3 100644 (file)
@@ -33,14 +33,14 @@ import org.apache.poi.ss.usermodel.DateUtil;
 import org.apache.poi.ss.formula.EvaluationWorkbook;
 /**
  * Implementation of Excel 'Analysis ToolPak' function YEARFRAC()<br/>
- * 
+ *
  * Returns the fraction of the year spanned by two dates.<p/>
- * 
+ *
  * <b>Syntax</b><br/>
  * <b>YEARFRAC</b>(<b>startDate</b>, <b>endDate</b>, basis)<p/>
- * 
+ *
  * The <b>basis</b> optionally specifies the behaviour of YEARFRAC as follows:
- * 
+ *
  * <table border="0" cellpadding="1" cellspacing="0" summary="basis parameter description">
  *   <tr><th>Value</th><th>Days per Month</th><th>Days per Year</th></tr>
  *   <tr align='center'><td>0 (default)</td><td>30</td><td>360</td></tr>
@@ -49,17 +49,17 @@ import org.apache.poi.ss.formula.EvaluationWorkbook;
  *   <tr align='center'><td>3</td><td>actual</td><td>365</td></tr>
  *   <tr align='center'><td>4</td><td>30</td><td>360</td></tr>
  * </table>
- * 
+ *
  */
 final class YearFrac implements FreeRefFunction {
 
        public static final FreeRefFunction instance = new YearFrac();
-       
+
        private YearFrac() {
                // enforce singleton
        }
 
-       public ValueEval evaluate(Eval[] args, EvaluationWorkbook workbook, int srcCellSheet, int srcCellRow,
+       public ValueEval evaluate(ValueEval[] args, EvaluationWorkbook workbook, int srcCellSheet, int srcCellRow,
                        int srcCellCol) {
 
                double result;
@@ -71,7 +71,7 @@ final class YearFrac implements FreeRefFunction {
                                case 2:
                                        break;
                                default:
-                                       return ErrorEval.VALUE_INVALID;  
+                                       return ErrorEval.VALUE_INVALID;
                        }
                        double startDateVal = evaluateDateArg(args[0], srcCellRow, srcCellCol);
                        double endDateVal = evaluateDateArg(args[1], srcCellRow, srcCellCol);
@@ -79,7 +79,7 @@ final class YearFrac implements FreeRefFunction {
                } catch (EvaluationException e) {
                        return e.getErrorEval();
                }
-               
+
                return new NumberEval(result);
        }
 
@@ -123,7 +123,7 @@ final class YearFrac implements FreeRefFunction {
                        // easy to see this cannot be a valid date
                        throw new EvaluationException(ErrorEval.VALUE_INVALID);
                }
-               
+
                if (f0 >= 1900 && f0 < 9999) {
                        // when 4 digit value appears first, the format is YYYY/MM/DD, regardless of OS settings
                        return makeDate(f0, f1, f2);
index b79abe7af659f9cfcff26e0f61f74e7fccf86ad8..0ffba7c358b16bc166b5a342d283221464c60d5c 100644 (file)
@@ -28,7 +28,7 @@ public final class ConcatEval implements OperationEval {
                // enforce singleton
        }
 
-       public Eval evaluate(Eval[] args, int srcRow, short srcCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcRow, short srcCol) {
                if(args.length != 2) {
                        return ErrorEval.VALUE_INVALID;
                }
index 93f1a7624a587cb6116f3268d90427725a9c9d75..5928fe40fee685ebb3e9bb8b87b99998473630f2 100644 (file)
@@ -243,12 +243,12 @@ public final class FunctionEval implements OperationEval {
                _delegate = funcPtg;
        }
 
-       public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+       public ValueEval evaluate(ValueEval[] operands, int srcRow, short srcCol) {
                Function f = getFunction();
                if (f == null) {
                        throw new NotImplementedException("FuncIx=" + getFunctionIndex());
                }
-               return f.evaluate(operands, srcRow, srcCol);
+               return (ValueEval) f.evaluate(operands, srcRow, srcCol);
        }
 
        public int getNumberOfOperands() {
index 22f7d364ae9a1ad0dd3161345ce9146895852358..d66c314d7d7325368b0b086cd08c9943bfede107 100644 (file)
@@ -19,21 +19,21 @@ package org.apache.poi.hssf.record.formula.eval;
 
 /**
  * Common interface for implementations of Excel formula operations.
- * 
+ *
  * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
- *  
+ *
  */
 public interface OperationEval {
 
        /**
-        * @param args the evaluated operation arguments. Elements of this array typically implement 
-        * {@link ValueEval}.  Empty values are represented with {@link BlankEval} or {@link 
+        * @param args the evaluated operation arguments. Elements of this array typically implement
+        * {@link ValueEval}.  Empty values are represented with {@link BlankEval} or {@link
         * MissingArgEval}, never <code>null</code>.
         * @param srcRowIndex row index of the cell containing the formula under evaluation
         * @param srcColumnIndex column index of the cell containing the formula under evaluation
         * @return The evaluated result, possibly an {@link ErrorEval}, never <code>null</code>.
         */
-       Eval evaluate(Eval[] args, int srcRowIndex, short srcColumnIndex);
+       ValueEval evaluate(ValueEval[] args, int srcRowIndex, short srcColumnIndex);
 
        int getNumberOfOperands();
 }
index 145874e6e6e1f852c5c6c9cac93f8f570952fb81..60c0642924d159420ad314fdcb3d56a46836c635 100755 (executable)
@@ -30,7 +30,7 @@ public final class PercentEval implements OperationEval {
                // enforce singleton
        }
 
-       public Eval evaluate(Eval[] args, int srcRow, short srcCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcRow, short srcCol) {
                if (args.length != 1) {
                        return ErrorEval.VALUE_INVALID;
                }
index 07b143a6d6328e069410fbd2f7bd57ac6e12611d..cf3ed58477cd3336ed89763624a64f4fc8585f13 100644 (file)
@@ -19,18 +19,18 @@ package org.apache.poi.hssf.record.formula.eval;
 
 
 /**
- * 
- * @author Josh Micich 
+ *
+ * @author Josh Micich
  */
 public final class RangeEval implements OperationEval {
 
        public static final OperationEval instance = new RangeEval();
-       
+
        private RangeEval() {
                // enforces singleton
        }
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                if(args.length != 2) {
                        return ErrorEval.VALUE_INVALID;
                }
@@ -45,18 +45,18 @@ public final class RangeEval implements OperationEval {
        }
 
        /**
-        * @return simple rectangular {@link AreaEval} which fully encloses both areas 
+        * @return simple rectangular {@link AreaEval} which fully encloses both areas
         * <tt>aeA</tt> and <tt>aeB</tt>
         */
        private static AreaEval resolveRange(AreaEval aeA, AreaEval aeB) {
                int aeAfr = aeA.getFirstRow();
                int aeAfc = aeA.getFirstColumn();
-               
+
                int top = Math.min(aeAfr, aeB.getFirstRow());
                int bottom = Math.max(aeA.getLastRow(), aeB.getLastRow());
                int left = Math.min(aeAfc, aeB.getFirstColumn());
                int right = Math.max(aeA.getLastColumn(), aeB.getLastColumn());
-               
+
                return aeA.offset(top-aeAfr, bottom-aeAfr, left-aeAfc, right-aeAfc);
        }
 
index f54b7cd2bc8de235df21b3fd9ada18cbe290489d..d2ce53296d45281bcc84ff61f1df108d080e04c7 100644 (file)
@@ -54,7 +54,7 @@ public abstract class RelationalOperationEval implements OperationEval {
         * Blank < Positive numbers
         * </pre>
         */
-       public final Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+       public final ValueEval evaluate(ValueEval[] operands, int srcRow, short srcCol) {
                if (operands.length != 2) {
                        return ErrorEval.VALUE_INVALID;
                }
index 672c5a7d76349e54e0c5eaa56c73367edaad64a3..f8ff34ab00f088672e7924d93f1fd4ae39b682e3 100644 (file)
@@ -27,7 +27,7 @@ abstract class TwoOperandNumericOperation implements OperationEval {
                return OperandResolver.coerceValueToDouble(ve);
        }
 
-       public final Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public final ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                double result;
                try {
                        double d0 = singleOperandEvaluate(args[0], srcCellRow, srcCellCol);
index 98f31c529232500bf55d693113c8daee8f1791e4..c9130953dc2f75e5d600d428c32b20329bcd5f6b 100644 (file)
@@ -30,7 +30,7 @@ public final class UnaryMinusEval implements OperationEval {
                // enforce singleton
        }
 
-       public Eval evaluate(Eval[] args, int srcRow, short srcCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcRow, short srcCol) {
                if (args.length != 1) {
                        return ErrorEval.VALUE_INVALID;
                }
index 508fb0d060e94b6f09898117a287a4aaafacf22d..1cac938734afea31bea3ba9705f41b32ef78f00d 100644 (file)
@@ -20,17 +20,17 @@ package org.apache.poi.hssf.record.formula.eval;
 
 /**
  * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
- *  
+ *
  */
 public final class UnaryPlusEval implements OperationEval {
 
        public static final OperationEval instance = new UnaryPlusEval();
-       
+
        private UnaryPlusEval() {
                // enforce singleton
        }
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                if(args.length != 1) {
                        return ErrorEval.VALUE_INVALID;
                }
index 4e32d988919467ecefe4078b595198d74c6a2239..65252d08d459b08895f92f1663108654da4af842 100755 (executable)
@@ -36,7 +36,7 @@ final class UserDefinedFunction implements FreeRefFunction {
                // enforce singleton
        }
 
-       public ValueEval evaluate(Eval[] args, EvaluationWorkbook workbook,
+       public ValueEval evaluate(ValueEval[] args, EvaluationWorkbook workbook,
                        int srcCellSheet, int srcCellRow,int srcCellCol) {
 
                int nIncomingArgs = args.length;
@@ -55,7 +55,7 @@ final class UserDefinedFunction implements FreeRefFunction {
                                        + nameArg.getClass().getName() + ")");
                }
                int nOutGoingArgs = nIncomingArgs -1;
-               Eval[] outGoingArgs = new Eval[nOutGoingArgs];
+               ValueEval[] outGoingArgs = new ValueEval[nOutGoingArgs];
                System.arraycopy(args, 1, outGoingArgs, 0, nOutGoingArgs);
                return targetFunc.evaluate(outGoingArgs, workbook, srcCellSheet, srcCellRow, srcCellCol);
        }
index edec7df5ceeb239132a564d7acdde8de728e1c3d..c80647206842958b8f7860e6eeacc132099391eb 100755 (executable)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hssf.record.formula.functions;
 
-import org.apache.poi.hssf.record.formula.eval.Eval;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
 import org.apache.poi.ss.formula.EvaluationWorkbook;
 
@@ -52,5 +51,5 @@ public interface FreeRefFunction {
         * a specified Excel error (Exceptions are never thrown to represent Excel errors).
         *
         */
-       ValueEval evaluate(Eval[] args, EvaluationWorkbook workbook, int srcCellSheet, int srcCellRow, int srcCellCol);
+       ValueEval evaluate(ValueEval[] args, EvaluationWorkbook workbook, int srcCellSheet, int srcCellRow, int srcCellCol);
 }
index 11a4c46cc7f4561b0f1ff22a854a1eefbe3591fd..d7b031d565e6f2205f4fc48ab0683fd553eb6f23 100644 (file)
@@ -17,7 +17,6 @@
 
 package org.apache.poi.hssf.record.formula.functions;
 
-import org.apache.poi.hssf.record.formula.eval.Eval;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
 import org.apache.poi.ss.formula.EvaluationWorkbook;
 import org.apache.poi.ss.formula.eval.NotImplementedException;
@@ -46,7 +45,7 @@ public final class Indirect implements FreeRefFunction {
                // enforce singleton
        }
 
-       public ValueEval evaluate(Eval[] args, EvaluationWorkbook workbook, int srcCellSheet, int srcCellRow, int srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, EvaluationWorkbook workbook, int srcCellSheet, int srcCellRow, int srcCellCol) {
                // TODO - implement INDIRECT()
                throw new NotImplementedException("INDIRECT");
        }
index 5ca223e72df3ff01e263cf14807d4a0f980b527c..b0c7e2d464c07b60dafad8599da398f92352aa8a 100644 (file)
@@ -51,7 +51,6 @@ import org.apache.poi.hssf.record.formula.eval.AreaEval;
 import org.apache.poi.hssf.record.formula.eval.BlankEval;
 import org.apache.poi.hssf.record.formula.eval.BoolEval;
 import org.apache.poi.hssf.record.formula.eval.ErrorEval;
-import org.apache.poi.hssf.record.formula.eval.Eval;
 import org.apache.poi.hssf.record.formula.eval.FunctionEval;
 import org.apache.poi.hssf.record.formula.eval.MissingArgEval;
 import org.apache.poi.hssf.record.formula.eval.NameEval;
@@ -237,20 +236,20 @@ public final class WorkbookEvaluator {
                        CellReference cr = new CellReference(rowIndex, columnIndex);
                        logDebug("Evaluated " + sheetName + "!" + cr.formatAsString() + " to " + result.toString());
                }
-               // Usually (result === cce.getValue())  
+               // Usually (result === cce.getValue())
                // But sometimes: (result==ErrorEval.CIRCULAR_REF_ERROR, cce.getValue()==null)
-               // When circular references are detected, the cache entry is only updated for 
-               // the top evaluation frame 
+               // When circular references are detected, the cache entry is only updated for
+               // the top evaluation frame
                return result;
        }
 
        /**
-        * Adds the current cell reference to the exception for easier debugging. 
+        * Adds the current cell reference to the exception for easier debugging.
         * Would be nice to get the formula text as well, but that seems to require
-        * too much digging around and casting to get the FormulaRenderingWorkbook. 
+        * too much digging around and casting to get the FormulaRenderingWorkbook.
         */
        private NotImplementedException addExceptionInfo(NotImplementedException inner, int sheetIndex, int rowIndex, int columnIndex) {
-               
+
                try {
                        String sheetName = _workbook.getSheetName(sheetIndex);
                        CellReference cr = new CellReference(sheetName, rowIndex, columnIndex, false, false);
@@ -385,7 +384,7 @@ public final class WorkbookEvaluator {
                return evaluationResult;
        }
 
-       private static ValueEval invokeOperation(OperationEval operation, Eval[] ops,
+       private static ValueEval invokeOperation(OperationEval operation, ValueEval[] ops,
                        EvaluationWorkbook workbook, int sheetIndex, int srcRowNum, int srcColNum) {
 
                if(operation instanceof FunctionEval) {
index 71bf03e5013ca64d746f8d79df7dfd91e786a992..0b093e7decc521c85a7b8d792f28748aa0456f76 100644 (file)
@@ -24,18 +24,18 @@ import org.apache.poi.hssf.record.formula.functions.NumericFunctionInvoker;
 
 /**
  * Test for divide operator evaluator.
- * 
+ *
  * @author Josh Micich
  */
 public final class TestDivideEval extends TestCase {
-       
+
        private static void confirm(ValueEval arg0, ValueEval arg1, double expectedResult) {
-               Eval[] args = { 
-                       arg0, arg1,      
+               ValueEval[] args = {
+                       arg0, arg1,
                };
-               
+
                double result = NumericFunctionInvoker.invoke(DivideEval.instance, args, 0, 0);
-               
+
                assertEquals(expectedResult, result, 0);
        }
 
@@ -53,10 +53,10 @@ public final class TestDivideEval extends TestCase {
                confirm(ae0, ae1, 5);
        }
        public void testDivZero() {
-               Eval[] args = { 
-                       new NumberEval(5), NumberEval.ZERO,      
+               ValueEval[] args = {
+                       new NumberEval(5), NumberEval.ZERO,
                };
-               Eval result = DivideEval.instance.evaluate(args, 0, (short) 0);
+               ValueEval result = DivideEval.instance.evaluate(args, 0, (short) 0);
                assertEquals(ErrorEval.DIV_ZERO, result);
        }
 }
index 3e71107b7697525fa1105f9dc7086136273ce7e0..c64a2a7fd7f27f2661d9d650117ff05b00816fe6 100644 (file)
@@ -36,11 +36,11 @@ public final class TestEqualEval extends TestCase {
        public void test1x1AreaOperand() {
 
                ValueEval[] values = { BoolEval.FALSE, };
-               Eval[] args = {
+               ValueEval[] args = {
                        EvalFactory.createAreaEval("B1:B1", values),
                        BoolEval.FALSE,
                };
-               Eval result = EqualEval.instance.evaluate(args, 10, (short)20);
+               ValueEval result = EqualEval.instance.evaluate(args, 10, (short)20);
                if (result instanceof ErrorEval) {
                        if (result == ErrorEval.VALUE_INVALID) {
                                throw new AssertionFailedError("Identified bug in evaluation of 1x1 area");
@@ -54,11 +54,11 @@ public final class TestEqualEval extends TestCase {
         */
        public void testBlankEqualToEmptyString() {
 
-               Eval[] args = {
+               ValueEval[] args = {
                        new StringEval(""),
                        BlankEval.INSTANCE,
                };
-               Eval result = EqualEval.instance.evaluate(args, 10, (short)20);
+               ValueEval result = EqualEval.instance.evaluate(args, 10, (short)20);
                assertEquals(BoolEval.class, result.getClass());
                BoolEval be = (BoolEval) result;
                if (!be.getBooleanValue()) {
@@ -82,11 +82,11 @@ public final class TestEqualEval extends TestCase {
        }
 
        private static boolean evalStringCmp(String a, String b, OperationEval cmpOp) {
-               Eval[] args = {
+               ValueEval[] args = {
                        new StringEval(a),
                        new StringEval(b),
                };
-               Eval result = cmpOp.evaluate(args, 10, (short)20);
+               ValueEval result = cmpOp.evaluate(args, 10, (short)20);
                assertEquals(BoolEval.class, result.getClass());
                BoolEval be = (BoolEval) result;
                return be.getBooleanValue();
@@ -103,12 +103,12 @@ public final class TestEqualEval extends TestCase {
         */
        public void testZeroEquality_bug47198() {
                NumberEval zero = new NumberEval(0.0);
-               NumberEval mZero = (NumberEval) UnaryMinusEval.instance.evaluate(new Eval[] { zero, }, 0,
+               NumberEval mZero = (NumberEval) UnaryMinusEval.instance.evaluate(new ValueEval[] { zero, }, 0,
                                (short) 0);
                if (Double.doubleToLongBits(mZero.getNumberValue()) == 0x8000000000000000L) {
                        throw new AssertionFailedError("Identified bug 47198: unary minus should convert -0.0 to 0.0");
                }
-               Eval[] args = { zero, mZero, };
+               ValueEval[] args = { zero, mZero, };
                BoolEval result = (BoolEval) EqualEval.instance.evaluate(args, 0, (short) 0);
                if (!result.getBooleanValue()) {
                        throw new AssertionFailedError("Identified bug 47198: -0.0 != 0.0");
@@ -123,7 +123,7 @@ public final class TestEqualEval extends TestCase {
                NumberEval b = new NumberEval(1.0055);
                assertEquals("1.0055", b.getStringValue());
 
-               Eval[] args = { a, b, };
+               ValueEval[] args = { a, b, };
                BoolEval result = (BoolEval) EqualEval.instance.evaluate(args, 0, (short) 0);
                if (!result.getBooleanValue()) {
                        throw new AssertionFailedError("Identified bug 47598: 1+1.0028-0.9973 != 1.0055");
index b68b1f74dcc3e4e7e5518314107c04aa63574e6d..73383effae99e9627497364c464ea136cc510b8e 100644 (file)
@@ -77,7 +77,7 @@ public final class TestMinusZeroResult extends TestCase {
         * Uses {@link ConcatEval} to force number-to-text conversion
         */
        private static void confirmTextRendering(String expRendering, double d) {
-               Eval[] args = { StringEval.EMPTY_INSTANCE, new NumberEval(d), };
+               ValueEval[] args = { StringEval.EMPTY_INSTANCE, new NumberEval(d), };
                StringEval se = (StringEval) ConcatEval.instance.evaluate(args, -1, (short)-1);
                String result = se.getStringValue();
                assertEquals(expRendering, result);
@@ -91,13 +91,13 @@ public final class TestMinusZeroResult extends TestCase {
                BoolEval result = (BoolEval) evaluate(instance, dArgs);
                assertEquals(expectedResult, result.getBooleanValue());
        }
-       private static Eval evaluate(OperationEval instance, double... dArgs) {
-               Eval[] evalArgs;
-               evalArgs = new Eval[dArgs.length];
+       private static ValueEval evaluate(OperationEval instance, double... dArgs) {
+               ValueEval[] evalArgs;
+               evalArgs = new ValueEval[dArgs.length];
                for (int i = 0; i < evalArgs.length; i++) {
                        evalArgs[i] = new NumberEval(dArgs[i]);
                }
-               Eval r = instance.evaluate(evalArgs, -1, (short)-1);
+               ValueEval r = instance.evaluate(evalArgs, -1, (short)-1);
                return r;
        }
 
index 750f71ba018b5220a584e884c0c963863f3f2cf2..46b193def981ab6fff082c06e0de46b74775e661 100755 (executable)
@@ -31,19 +31,19 @@ import org.apache.poi.ss.usermodel.CellValue;
 
 /**
  * Test for percent operator evaluator.
- * 
+ *
  * @author Josh Micich
  */
 public final class TestPercentEval extends TestCase {
-       
+
        private static void confirm(ValueEval arg, double expectedResult) {
-               Eval[] args = { 
-                       arg,    
+               ValueEval[] args = {
+                       arg,
                };
-               
+
                OperationEval opEval = PercentEval.instance;
                double result = NumericFunctionInvoker.invoke(opEval, args, 0, 0);
-               
+
                assertEquals(expectedResult, result, 0);
        }
 
@@ -66,7 +66,7 @@ public final class TestPercentEval extends TestCase {
                HSSFCell cell = row.createCell(0);
                cell.setCellFormula("B1%");
                row.createCell(1).setCellValue(50.0);
-               
+
                HSSFFormulaEvaluator fe = new HSSFFormulaEvaluator(wb);
                CellValue cv;
                try {
@@ -81,5 +81,4 @@ public final class TestPercentEval extends TestCase {
                assertEquals(HSSFCell.CELL_TYPE_NUMERIC, cv.getCellType());
                assertEquals(0.5, cv.getNumberValue(), 0.0);
        }
-
 }
index d30a7b1d388934028881b6dd94dd478f61c3d09c..afda62b332c4182182e084a13ee844f6c90201db 100644 (file)
@@ -59,12 +59,12 @@ public final class TestRangeEval extends TestCase {
 
        private static void confirm(String refA, String refB, String expectedAreaRef) {
 
-               Eval[] args = {
+               ValueEval[] args = {
                        createRefEval(refA),
                        createRefEval(refB),
                };
                AreaReference ar = new AreaReference(expectedAreaRef);
-               Eval result = RangeEval.instance.evaluate(args, 0, (short)0);
+               ValueEval result = RangeEval.instance.evaluate(args, 0, (short)0);
                assertTrue(result instanceof AreaEval);
                AreaEval ae = (AreaEval) result;
                assertEquals(ar.getFirstCell().getRow(), ae.getFirstRow());
@@ -73,7 +73,7 @@ public final class TestRangeEval extends TestCase {
                assertEquals(ar.getLastCell().getCol(), ae.getLastColumn());
        }
 
-       private static Eval createRefEval(String refStr) {
+       private static ValueEval createRefEval(String refStr) {
                CellReference cr = new CellReference(refStr);
                return new MockRefEval(cr.getRow(), cr.getCol());
 
index 726633c40604f0235398c502cb3ea80591766ab5..6a73dd637e5f8febe969abaafc1bb86f06d8f940 100755 (executable)
@@ -47,7 +47,7 @@ public final class TestUnaryPlusEval extends TestCase {
                                new NumberEval(37),
                                new NumberEval(38),
                };
-               Eval[] args = {
+               ValueEval[] args = {
                        EvalFactory.createAreaEval(areaPtg, values),
                };
 
index 51340af49a78044c46e1e205098a06ee9d0cea2b..39b4b08f88858902708e5cffdf62d4a7e1a9ead2 100755 (executable)
@@ -14,7 +14,6 @@
    See the License for the specific language governing permissions and
    limitations under the License.
 ==================================================================== */
-        
 
 package org.apache.poi.hssf.record.formula.functions;
 
@@ -24,11 +23,12 @@ import org.apache.poi.hssf.record.formula.eval.ErrorEval;
 import org.apache.poi.hssf.record.formula.eval.Eval;
 import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
 import org.apache.poi.hssf.record.formula.eval.OperationEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
 import org.apache.poi.ss.formula.eval.NotImplementedException;
 
 /**
  * Test helper class for invoking functions with numeric results.
- * 
+ *
  * @author Josh Micich
  */
 public final class NumericFunctionInvoker {
@@ -36,13 +36,13 @@ public final class NumericFunctionInvoker {
        private NumericFunctionInvoker() {
                // no instances of this class
        }
-       
+
        private static final class NumericEvalEx extends Exception {
                public NumericEvalEx(String msg) {
                        super(msg);
                }
        }
-       
+
        /**
         * Invokes the specified function with the arguments.
         * <p/>
@@ -53,14 +53,14 @@ public final class NumericFunctionInvoker {
         * This method cannot be used for confirming error return codes.  Any non-numeric evaluation
         * result causes the current junit test to fail.
         */
-       public static double invoke(Function f, Eval[] args) {
+       public static double invoke(Function f, ValueEval[] args) {
                try {
                        return invokeInternal(f, args, -1, -1);
                } catch (NumericEvalEx e) {
-                       throw new AssertionFailedError("Evaluation of function (" + f.getClass().getName() 
+                       throw new AssertionFailedError("Evaluation of function (" + f.getClass().getName()
                                        + ") failed: " + e.getMessage());
                }
-               
+
        }
        /**
         * Invokes the specified operator with the arguments.
@@ -68,19 +68,19 @@ public final class NumericFunctionInvoker {
         * This method cannot be used for confirming error return codes.  Any non-numeric evaluation
         * result causes the current junit test to fail.
         */
-       public static double invoke(OperationEval f, Eval[] args, int srcCellRow, int srcCellCol) {
+       public static double invoke(OperationEval f, ValueEval[] args, int srcCellRow, int srcCellCol) {
                try {
                        return invokeInternal(f, args, srcCellRow, srcCellCol);
                } catch (NumericEvalEx e) {
-                       throw new AssertionFailedError("Evaluation of function (" + f.getClass().getName() 
+                       throw new AssertionFailedError("Evaluation of function (" + f.getClass().getName()
                                        + ") failed: " + e.getMessage());
                }
-               
+
        }
        /**
         * Formats nicer error messages for the junit output
         */
-       private static double invokeInternal(Object target, Eval[] args, int srcCellRow, int srcCellCol)
+       private static double invokeInternal(Object target, ValueEval[] args, int srcCellRow, int srcCellCol)
                                throws NumericEvalEx {
                Eval evalResult;
                // TODO - make OperationEval extend Function
@@ -95,7 +95,7 @@ public final class NumericFunctionInvoker {
                } catch (NotImplementedException e) {
                        throw new NumericEvalEx("Not implemented:" + e.getMessage());
                }
-               
+
                if(evalResult == null) {
                        throw new NumericEvalEx("Result object was null");
                }
@@ -105,10 +105,10 @@ public final class NumericFunctionInvoker {
                }
                if(!(evalResult instanceof NumericValueEval)) {
                        throw new NumericEvalEx("Result object type (" + evalResult.getClass().getName()
-                                       + ") is invalid.  Expected implementor of (" 
+                                       + ") is invalid.  Expected implementor of ("
                                        + NumericValueEval.class.getName() + ")");
                }
-               
+
                NumericValueEval result = (NumericValueEval) evalResult;
                return result.getNumberValue();
        }
@@ -124,5 +124,4 @@ public final class NumericFunctionInvoker {
                }
                return a.getErrorCode() == b.getErrorCode();
        }
-
 }
index f11749030b1630bd615ad5ae7fab1a16e6f4e988..e07f2c2454a3e56dd69015d8f6ac0c241958c2b3 100755 (executable)
@@ -25,7 +25,6 @@ import org.apache.poi.hssf.record.formula.eval.AreaEval;
 import org.apache.poi.hssf.record.formula.eval.BlankEval;
 import org.apache.poi.hssf.record.formula.eval.BoolEval;
 import org.apache.poi.hssf.record.formula.eval.ErrorEval;
-import org.apache.poi.hssf.record.formula.eval.Eval;
 import org.apache.poi.hssf.record.formula.eval.NumberEval;
 import org.apache.poi.hssf.record.formula.eval.OperandResolver;
 import org.apache.poi.hssf.record.formula.eval.StringEval;
@@ -44,31 +43,31 @@ import org.apache.poi.ss.usermodel.CellValue;
  * @author Josh Micich
  */
 public final class TestCountFuncs extends TestCase {
-       
+
        private static final String NULL = null;
 
        public void testCountA() {
 
-               Eval[] args;
+               ValueEval[] args;
 
-               args = new Eval[] {
+               args = new ValueEval[] {
                        new NumberEval(0),
                };
                confirmCountA(1, args);
 
-               args = new Eval[] {
+               args = new ValueEval[] {
                        new NumberEval(0),
                        new NumberEval(0),
                        new StringEval(""),
                };
                confirmCountA(3, args);
 
-               args = new Eval[] {
+               args = new ValueEval[] {
                        EvalFactory.createAreaEval("D2:F5", new ValueEval[12]),
                };
                confirmCountA(12, args);
 
-               args = new Eval[] {
+               args = new ValueEval[] {
                        EvalFactory.createAreaEval("D1:F5", new ValueEval[15]),
                        EvalFactory.createRefEval("A1"),
                        EvalFactory.createAreaEval("A1:G6", new ValueEval[42]),
@@ -163,7 +162,6 @@ public final class TestCountFuncs extends TestCase {
 
                range = EvalFactory.createAreaEval("A1:A5", values);
                confirmCountIf(4, range, new StringEval("<>111"));
-       
        }
 
        /**
@@ -182,57 +180,57 @@ public final class TestCountFuncs extends TestCase {
                AreaEval arg0 = EvalFactory.createAreaEval("C1:C6", values);
 
                ValueEval criteriaArg = EvalFactory.createRefEval("A1", new NumberEval(25));
-               Eval[] args=  { arg0, criteriaArg, };
+               ValueEval[] args=  { arg0, criteriaArg, };
 
                double actual = NumericFunctionInvoker.invoke(new Countif(), args);
                assertEquals(4, actual, 0D);
        }
 
-       private static void confirmCountA(int expected, Eval[] args) {
+       private static void confirmCountA(int expected, ValueEval[] args) {
                double result = NumericFunctionInvoker.invoke(new Counta(), args);
                assertEquals(expected, result, 0);
        }
-       private static void confirmCountIf(int expected, AreaEval range, Eval criteria) {
+       private static void confirmCountIf(int expected, AreaEval range, ValueEval criteria) {
 
-               Eval[] args = { range, criteria, };
+               ValueEval[] args = { range, criteria, };
                double result = NumericFunctionInvoker.invoke(new Countif(), args);
                assertEquals(expected, result, 0);
        }
 
-       private static I_MatchPredicate createCriteriaPredicate(Eval ev) {
+       private static I_MatchPredicate createCriteriaPredicate(ValueEval ev) {
                return Countif.createCriteriaPredicate(ev, 0, 0);
        }
-       
+
        /**
         * the criteria arg is mostly handled by {@link OperandResolver#getSingleValue(Eval, int, short)}
         */
        public void testCountifAreaCriteria() {
                int srcColIx = 2; // anything but column A
-               
+
                ValueEval v0 = new NumberEval(2.0);
                ValueEval v1 = new StringEval("abc");
                ValueEval v2 = ErrorEval.DIV_ZERO;
-               
+
                AreaEval ev = EvalFactory.createAreaEval("A10:A12", new ValueEval[] { v0, v1, v2, });
-               
+
                I_MatchPredicate mp;
                mp = Countif.createCriteriaPredicate(ev, 9, srcColIx);
                confirmPredicate(true, mp, srcColIx);
                confirmPredicate(false, mp, "abc");
                confirmPredicate(false, mp, ErrorEval.DIV_ZERO);
-               
+
                mp = Countif.createCriteriaPredicate(ev, 10, srcColIx);
                confirmPredicate(false, mp, srcColIx);
                confirmPredicate(true, mp, "abc");
                confirmPredicate(false, mp, ErrorEval.DIV_ZERO);
-               
+
                mp = Countif.createCriteriaPredicate(ev, 11, srcColIx);
                confirmPredicate(false, mp, srcColIx);
                confirmPredicate(false, mp, "abc");
                confirmPredicate(true, mp, ErrorEval.DIV_ZERO);
                confirmPredicate(false, mp, ErrorEval.VALUE_INVALID);
 
-               // tricky: indexing outside of A10:A12 
+               // tricky: indexing outside of A10:A12
                // even this #VALUE! error gets used by COUNTIF as valid criteria
                mp = Countif.createCriteriaPredicate(ev, 12, srcColIx);
                confirmPredicate(false, mp, srcColIx);
@@ -240,7 +238,7 @@ public final class TestCountFuncs extends TestCase {
                confirmPredicate(false, mp, ErrorEval.DIV_ZERO);
                confirmPredicate(true, mp, ErrorEval.VALUE_INVALID);
        }
-       
+
        public void testCountifEmptyStringCriteria() {
                I_MatchPredicate mp;
 
@@ -296,7 +294,7 @@ public final class TestCountFuncs extends TestCase {
                confirmPredicate(true, mp, "500");
                confirmPredicate(true, mp, "4t4");
        }
-       
+
        /**
         * the criteria arg value can be an error code (the error does not
         * propagate to the COUNTIF result).
@@ -315,7 +313,7 @@ public final class TestCountFuncs extends TestCase {
                confirmPredicate(false, mp, "#REF!");
                confirmPredicate(true, mp, ErrorEval.DIV_ZERO);
                confirmPredicate(false, mp, ErrorEval.REF_INVALID);
-               
+
                // not quite an error literal, should be treated as plain text
                mp = createCriteriaPredicate(new StringEval("<=#REF!a"));
                confirmPredicate(false, mp, 4);
@@ -382,7 +380,7 @@ public final class TestCountFuncs extends TestCase {
                assertEquals(expectedResult, matchPredicate.matches(new NumberEval(value)));
        }
        private static void confirmPredicate(boolean expectedResult, I_MatchPredicate matchPredicate, String value) {
-               Eval ev = value == null ? (Eval)BlankEval.INSTANCE : new StringEval(value);
+               ValueEval ev = value == null ? BlankEval.INSTANCE : new StringEval(value);
                assertEquals(expectedResult, matchPredicate.matches(ev));
        }
        private static void confirmPredicate(boolean expectedResult, I_MatchPredicate matchPredicate, ErrorEval value) {
index 764e30cd997601cfebc804f74513fd43dc4de650..1352870c157c4eecb4a81810151ba36c03353b22 100755 (executable)
@@ -21,7 +21,6 @@ import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
 import org.apache.poi.hssf.record.formula.eval.AreaEval;
-import org.apache.poi.hssf.record.formula.eval.Eval;
 import org.apache.poi.hssf.record.formula.eval.MissingArgEval;
 import org.apache.poi.hssf.record.formula.eval.NumberEval;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
@@ -77,11 +76,11 @@ public final class TestIndex extends TestCase {
                }
                AreaEval arg0 = EvalFactory.createAreaEval(areaRefString, values);
 
-               Eval[] args;
+               ValueEval[] args;
                if (colNum > 0) {
-                       args = new Eval[] { arg0, new NumberEval(rowNum), new NumberEval(colNum), };
+                       args = new ValueEval[] { arg0, new NumberEval(rowNum), new NumberEval(colNum), };
                } else {
-                       args = new Eval[] { arg0, new NumberEval(rowNum), };
+                       args = new ValueEval[] { arg0, new NumberEval(rowNum), };
                }
 
                double actual = NumericFunctionInvoker.invoke(FUNC_INST, args);
@@ -99,10 +98,10 @@ public final class TestIndex extends TestCase {
                                new NumberEval(28.0),
                };
                AreaEval arg0 = EvalFactory.createAreaEval("A10:C10", values);
-               Eval[] args = new Eval[] { arg0, MissingArgEval.instance, new NumberEval(2), };
-               Eval actualResult;
+               ValueEval[] args = new ValueEval[] { arg0, MissingArgEval.instance, new NumberEval(2), };
+               ValueEval actualResult;
                try {
-                       actualResult = FUNC_INST.evaluate(args, 1, (short)1);
+                       actualResult = (ValueEval) FUNC_INST.evaluate(args, 1, (short)1);
                } catch (RuntimeException e) {
                        if (e.getMessage().equals("Unexpected arg eval type (org.apache.poi.hssf.record.formula.eval.MissingArgEval")) {
                                throw new AssertionFailedError("Identified bug 47048b - INDEX() should support missing-arg");
index f51436fe95b8ec411b085056f58955bfce035583..1bec618aa3c18e90a747ab6ab8b333cb6144a7e9 100755 (executable)
@@ -19,12 +19,11 @@ package org.apache.poi.hssf.record.formula.functions;
 
 import junit.framework.TestCase;
 
-import org.apache.poi.hssf.record.formula.eval.Eval;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
 /**
  * Tests for ROW(), ROWS(), COLUMN(), COLUMNS()
- * 
+ *
  * @author Josh Micich
  */
 public final class TestRowCol extends TestCase {
@@ -32,65 +31,65 @@ public final class TestRowCol extends TestCase {
        public void testCol() {
                Function target = new Column();
                {
-                       Eval[] args = { EvalFactory.createRefEval("C5"), };
+                       ValueEval[] args = { EvalFactory.createRefEval("C5"), };
                        double actual = NumericFunctionInvoker.invoke(target, args);
                        assertEquals(3, actual, 0D);
                }
                {
-                       Eval[] args = { EvalFactory.createAreaEval("E2:H12", new ValueEval[44]), };
+                       ValueEval[] args = { EvalFactory.createAreaEval("E2:H12", new ValueEval[44]), };
                        double actual = NumericFunctionInvoker.invoke(target, args);
                        assertEquals(5, actual, 0D);
                }
        }
-       
+
        public void testRow() {
                Function target = new Row();
                {
-                       Eval[] args = { EvalFactory.createRefEval("C5"), };
+                       ValueEval[] args = { EvalFactory.createRefEval("C5"), };
                        double actual = NumericFunctionInvoker.invoke(target, args);
                        assertEquals(5, actual, 0D);
                }
                {
-                       Eval[] args = { EvalFactory.createAreaEval("E2:H12", new ValueEval[44]), };
+                       ValueEval[] args = { EvalFactory.createAreaEval("E2:H12", new ValueEval[44]), };
                        double actual = NumericFunctionInvoker.invoke(target, args);
                        assertEquals(2, actual, 0D);
                }
        }
-       
+
        public void testColumns() {
-               
+
                confirmColumnsFunc("A1:F1", 6, 1);
                confirmColumnsFunc("A1:C2", 3, 2);
                confirmColumnsFunc("A1:B3", 2, 3);
                confirmColumnsFunc("A1:A6", 1, 6);
-               
-               Eval[] args = { EvalFactory.createRefEval("C5"), };
+
+               ValueEval[] args = { EvalFactory.createRefEval("C5"), };
                double actual = NumericFunctionInvoker.invoke(new Columns(), args);
                assertEquals(1, actual, 0D);
        }
-       
+
        public void testRows() {
-               
+
                confirmRowsFunc("A1:F1", 6, 1);
                confirmRowsFunc("A1:C2", 3, 2);
                confirmRowsFunc("A1:B3", 2, 3);
                confirmRowsFunc("A1:A6", 1, 6);
-               
-               Eval[] args = { EvalFactory.createRefEval("C5"), };
+
+               ValueEval[] args = { EvalFactory.createRefEval("C5"), };
                double actual = NumericFunctionInvoker.invoke(new Rows(), args);
                assertEquals(1, actual, 0D);
        }
-       
+
        private static void confirmRowsFunc(String areaRefStr, int nCols, int nRows) {
-               Eval[] args = { EvalFactory.createAreaEval(areaRefStr, new ValueEval[nCols * nRows]), };
+               ValueEval[] args = { EvalFactory.createAreaEval(areaRefStr, new ValueEval[nCols * nRows]), };
 
                double actual = NumericFunctionInvoker.invoke(new Rows(), args);
                assertEquals(nRows, actual, 0D);
        }
-       
+
 
        private static void confirmColumnsFunc(String areaRefStr, int nCols, int nRows) {
-               Eval[] args = { EvalFactory.createAreaEval(areaRefStr, new ValueEval[nCols * nRows]), };
+               ValueEval[] args = { EvalFactory.createAreaEval(areaRefStr, new ValueEval[nCols * nRows]), };
 
                double actual = NumericFunctionInvoker.invoke(new Columns(), args);
                assertEquals(nCols, actual, 0D);