]> source.dussan.org Git - poi.git/commitdiff
Replaced obsolete Eval with ValueEval in signature of Function.evaluate()
authorJosh Micich <josh@apache.org>
Mon, 17 Aug 2009 20:04:45 +0000 (20:04 +0000)
committerJosh Micich <josh@apache.org>
Mon, 17 Aug 2009 20:04:45 +0000 (20:04 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@805119 13f79535-47bb-0310-9956-ffa450edef68

63 files changed:
src/java/org/apache/poi/hssf/record/formula/atp/AnalysisToolPak.java
src/java/org/apache/poi/hssf/record/formula/eval/FunctionEval.java
src/java/org/apache/poi/hssf/record/formula/functions/BooleanFunction.java
src/java/org/apache/poi/hssf/record/formula/functions/CalendarFieldFunction.java
src/java/org/apache/poi/hssf/record/formula/functions/Choose.java
src/java/org/apache/poi/hssf/record/formula/functions/Column.java
src/java/org/apache/poi/hssf/record/formula/functions/Columns.java
src/java/org/apache/poi/hssf/record/formula/functions/Count.java
src/java/org/apache/poi/hssf/record/formula/functions/Counta.java
src/java/org/apache/poi/hssf/record/formula/functions/Countif.java
src/java/org/apache/poi/hssf/record/formula/functions/Errortype.java
src/java/org/apache/poi/hssf/record/formula/functions/False.java
src/java/org/apache/poi/hssf/record/formula/functions/Function.java
src/java/org/apache/poi/hssf/record/formula/functions/Hlookup.java
src/java/org/apache/poi/hssf/record/formula/functions/Hyperlink.java
src/java/org/apache/poi/hssf/record/formula/functions/If.java
src/java/org/apache/poi/hssf/record/formula/functions/Index.java
src/java/org/apache/poi/hssf/record/formula/functions/IsError.java
src/java/org/apache/poi/hssf/record/formula/functions/IsNa.java
src/java/org/apache/poi/hssf/record/formula/functions/Isblank.java
src/java/org/apache/poi/hssf/record/formula/functions/Islogical.java [deleted file]
src/java/org/apache/poi/hssf/record/formula/functions/Isnontext.java [deleted file]
src/java/org/apache/poi/hssf/record/formula/functions/Isnumber.java [deleted file]
src/java/org/apache/poi/hssf/record/formula/functions/Isref.java
src/java/org/apache/poi/hssf/record/formula/functions/Istext.java [deleted file]
src/java/org/apache/poi/hssf/record/formula/functions/LogicalFunction.java
src/java/org/apache/poi/hssf/record/formula/functions/Lookup.java
src/java/org/apache/poi/hssf/record/formula/functions/Match.java
src/java/org/apache/poi/hssf/record/formula/functions/Mode.java
src/java/org/apache/poi/hssf/record/formula/functions/MultiOperandNumericFunction.java
src/java/org/apache/poi/hssf/record/formula/functions/Na.java
src/java/org/apache/poi/hssf/record/formula/functions/Not.java
src/java/org/apache/poi/hssf/record/formula/functions/NotImplementedFunction.java
src/java/org/apache/poi/hssf/record/formula/functions/Now.java
src/java/org/apache/poi/hssf/record/formula/functions/NumericFunction.java
src/java/org/apache/poi/hssf/record/formula/functions/Offset.java
src/java/org/apache/poi/hssf/record/formula/functions/Pi.java
src/java/org/apache/poi/hssf/record/formula/functions/Rand.java
src/java/org/apache/poi/hssf/record/formula/functions/Row.java
src/java/org/apache/poi/hssf/record/formula/functions/Rows.java
src/java/org/apache/poi/hssf/record/formula/functions/Sumif.java
src/java/org/apache/poi/hssf/record/formula/functions/Sumproduct.java
src/java/org/apache/poi/hssf/record/formula/functions/T.java
src/java/org/apache/poi/hssf/record/formula/functions/TextFunction.java
src/java/org/apache/poi/hssf/record/formula/functions/Time.java
src/java/org/apache/poi/hssf/record/formula/functions/Today.java
src/java/org/apache/poi/hssf/record/formula/functions/True.java
src/java/org/apache/poi/hssf/record/formula/functions/Value.java
src/java/org/apache/poi/hssf/record/formula/functions/Vlookup.java
src/java/org/apache/poi/hssf/record/formula/functions/XYNumericFunction.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestAverage.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestIndex.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestLen.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestMatch.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestMid.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestNper.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestPmt.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestRoundFuncs.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestSumproduct.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestTFunc.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestTrim.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestValue.java
src/testcases/org/apache/poi/hssf/record/formula/functions/TestXYNumericFunction.java

index 96a43170e762ba6f9829fad17a6c56f98edc820b..af5604152184228908354d84766b87bf7c39b258 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.poi.hssf.record.formula.atp;
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.poi.hssf.record.formula.eval.Eval;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
 import org.apache.poi.hssf.record.formula.functions.FreeRefFunction;
 import org.apache.poi.ss.formula.EvaluationWorkbook;
index 5928fe40fee685ebb3e9bb8b87b99998473630f2..5d04de0fc30f865478bfa89755f2c940dc4b36fd 100644 (file)
@@ -20,7 +20,63 @@ package org.apache.poi.hssf.record.formula.eval;
 import org.apache.poi.hssf.record.formula.AbstractFunctionPtg;
 import org.apache.poi.hssf.record.formula.function.FunctionMetadata;
 import org.apache.poi.hssf.record.formula.function.FunctionMetadataRegistry;
-import org.apache.poi.hssf.record.formula.functions.*;
+import org.apache.poi.hssf.record.formula.functions.AggregateFunction;
+import org.apache.poi.hssf.record.formula.functions.And;
+import org.apache.poi.hssf.record.formula.functions.CalendarFieldFunction;
+import org.apache.poi.hssf.record.formula.functions.Choose;
+import org.apache.poi.hssf.record.formula.functions.Column;
+import org.apache.poi.hssf.record.formula.functions.Columns;
+import org.apache.poi.hssf.record.formula.functions.Count;
+import org.apache.poi.hssf.record.formula.functions.Counta;
+import org.apache.poi.hssf.record.formula.functions.Countif;
+import org.apache.poi.hssf.record.formula.functions.DateFunc;
+import org.apache.poi.hssf.record.formula.functions.Errortype;
+import org.apache.poi.hssf.record.formula.functions.Even;
+import org.apache.poi.hssf.record.formula.functions.False;
+import org.apache.poi.hssf.record.formula.functions.FinanceFunction;
+import org.apache.poi.hssf.record.formula.functions.Find;
+import org.apache.poi.hssf.record.formula.functions.FreeRefFunction;
+import org.apache.poi.hssf.record.formula.functions.Function;
+import org.apache.poi.hssf.record.formula.functions.Hlookup;
+import org.apache.poi.hssf.record.formula.functions.Hyperlink;
+import org.apache.poi.hssf.record.formula.functions.If;
+import org.apache.poi.hssf.record.formula.functions.Index;
+import org.apache.poi.hssf.record.formula.functions.Indirect;
+import org.apache.poi.hssf.record.formula.functions.IsError;
+import org.apache.poi.hssf.record.formula.functions.IsNa;
+import org.apache.poi.hssf.record.formula.functions.Isblank;
+import org.apache.poi.hssf.record.formula.functions.Isref;
+import org.apache.poi.hssf.record.formula.functions.LogicalFunction;
+import org.apache.poi.hssf.record.formula.functions.Lookup;
+import org.apache.poi.hssf.record.formula.functions.Match;
+import org.apache.poi.hssf.record.formula.functions.MinaMaxa;
+import org.apache.poi.hssf.record.formula.functions.Mode;
+import org.apache.poi.hssf.record.formula.functions.Na;
+import org.apache.poi.hssf.record.formula.functions.Not;
+import org.apache.poi.hssf.record.formula.functions.NotImplementedFunction;
+import org.apache.poi.hssf.record.formula.functions.Now;
+import org.apache.poi.hssf.record.formula.functions.NumericFunction;
+import org.apache.poi.hssf.record.formula.functions.Odd;
+import org.apache.poi.hssf.record.formula.functions.Offset;
+import org.apache.poi.hssf.record.formula.functions.Or;
+import org.apache.poi.hssf.record.formula.functions.Pi;
+import org.apache.poi.hssf.record.formula.functions.Rand;
+import org.apache.poi.hssf.record.formula.functions.Replace;
+import org.apache.poi.hssf.record.formula.functions.Row;
+import org.apache.poi.hssf.record.formula.functions.Rows;
+import org.apache.poi.hssf.record.formula.functions.Substitute;
+import org.apache.poi.hssf.record.formula.functions.Sumif;
+import org.apache.poi.hssf.record.formula.functions.Sumproduct;
+import org.apache.poi.hssf.record.formula.functions.Sumx2my2;
+import org.apache.poi.hssf.record.formula.functions.Sumx2py2;
+import org.apache.poi.hssf.record.formula.functions.Sumxmy2;
+import org.apache.poi.hssf.record.formula.functions.T;
+import org.apache.poi.hssf.record.formula.functions.TextFunction;
+import org.apache.poi.hssf.record.formula.functions.Time;
+import org.apache.poi.hssf.record.formula.functions.Today;
+import org.apache.poi.hssf.record.formula.functions.True;
+import org.apache.poi.hssf.record.formula.functions.Value;
+import org.apache.poi.hssf.record.formula.functions.Vlookup;
 import org.apache.poi.ss.formula.eval.NotImplementedException;
 
 /**
@@ -151,8 +207,8 @@ public final class FunctionEval implements OperationEval {
 
                retval[124] = new Find();
 
-               retval[127] = new Istext();
-               retval[128] = new Isnumber();
+               retval[127] = LogicalFunction.IsText;
+               retval[128] = LogicalFunction.IsNumber;
                retval[129] = new Isblank();
                retval[130] = new T();
 
@@ -163,9 +219,9 @@ public final class FunctionEval implements OperationEval {
                retval[183] = AggregateFunction.PRODUCT;
                retval[184] = NumericFunction.FACT;
 
-               retval[190] = new Isnontext();
+               retval[190] = LogicalFunction.IsNonText;
 
-               retval[198] = new Islogical();
+               retval[198] = LogicalFunction.IsLogical;
 
                retval[212] = NumericFunction.ROUNDUP;
                retval[213] = NumericFunction.ROUNDDOWN;
@@ -248,7 +304,7 @@ public final class FunctionEval implements OperationEval {
                if (f == null) {
                        throw new NotImplementedException("FuncIx=" + getFunctionIndex());
                }
-               return (ValueEval) f.evaluate(operands, srcRow, srcCol);
+               return f.evaluate(operands, srcRow, srcCol);
        }
 
        public int getNumberOfOperands() {
index 4995599ea5e9bd6b8fe39201d58b2b4b83db1633..76be216f2f4f8aba7639d00e1d52bf4e698083c0 100644 (file)
@@ -39,7 +39,7 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
  */
 public abstract class BooleanFunction implements Function {
 
-       public final Eval evaluate(Eval[] args, int srcRow, short srcCol) {
+       public final ValueEval evaluate(ValueEval[] args, int srcRow, short srcCol) {
                if (args.length < 1) {
                        return ErrorEval.VALUE_INVALID;
                }
index ce6c2b4285c3a1a0b9d46d2e154d153f6361cdd7..90e8c1667516c99f7d684bc9000c431263184ae4 100644 (file)
@@ -22,7 +22,6 @@ import java.util.Date;
 import java.util.GregorianCalendar;
 
 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.EvaluationException;
 import org.apache.poi.hssf.record.formula.eval.NumberEval;
 import org.apache.poi.hssf.record.formula.eval.OperandResolver;
@@ -49,7 +48,7 @@ public final class CalendarFieldFunction implements Function {
                _needsOneBaseAdjustment = needsOneBaseAdjustment;
        }
 
-       public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] operands, int srcCellRow, short srcCellCol) {
                if (operands.length != 1) {
                        return ErrorEval.VALUE_INVALID;
                }
index dbe0aa7a9b0290b7439e7bbaf0ee4e0c7570da06..e7a827f4bdc89f29778f682a89b5d15f15e8c8e7 100644 (file)
@@ -18,7 +18,6 @@
 package org.apache.poi.hssf.record.formula.functions;
 
 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.EvaluationException;
 import org.apache.poi.hssf.record.formula.eval.OperandResolver;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
@@ -29,7 +28,7 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
  */
 public final class Choose implements Function {
 
-       public Eval evaluate(Eval[] args, int srcRowIndex, short srcColumnIndex) {
+       public ValueEval evaluate(ValueEval[] args, int srcRowIndex, short srcColumnIndex) {
                if (args.length < 2) {
                        return ErrorEval.VALUE_INVALID;
                }
index 5b04836123dcfe1ca96f9f87fbb71dab016c8c2d..e329abe3de7b24543cbfa3796bad4f366984dc32 100644 (file)
@@ -19,13 +19,12 @@ package org.apache.poi.hssf.record.formula.functions;
 
 import org.apache.poi.hssf.record.formula.eval.AreaEval;
 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.RefEval;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
 public final class Column implements Function {
-    public Eval evaluate(Eval[] evals, int srcCellRow, short srcCellCol) {
+    public ValueEval evaluate(ValueEval[] evals, int srcCellRow, short srcCellCol) {
         ValueEval retval = null;
         int cnum = -1;
 
index 2a57bedb2d7c60a948f1a385e60b310404526743..2871c63410a0ccb8c645d1eac045afb29a916f7d 100644 (file)
@@ -22,6 +22,7 @@ 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.RefEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
 /**
  * Implementation for Excel COLUMNS function.
@@ -30,7 +31,7 @@ import org.apache.poi.hssf.record.formula.eval.RefEval;
  */
 public final class Columns implements Function {
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                switch(args.length) {
                        case 1:
                                // expected
index 4b8b217f4da2977e51c5c45264b4f103ec97eeff..827fc0449fc803f886a25a8ea3299af45b917b38 100644 (file)
@@ -21,6 +21,7 @@ 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.MissingArgEval;
 import org.apache.poi.hssf.record.formula.eval.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
 import org.apache.poi.hssf.record.formula.functions.CountUtils.I_MatchPredicate;
 
 /**
@@ -36,7 +37,7 @@ import org.apache.poi.hssf.record.formula.functions.CountUtils.I_MatchPredicate;
  */
 public final class Count implements Function {
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                int nArgs = args.length;
                if (nArgs < 1) {
                        // too few arguments
index 7ce7eadcb52c3c0fbe2229e1a75634743ededdfe..609301db6d9a33ae3fe89e322bb042d2a7826004 100644 (file)
@@ -21,6 +21,7 @@ import org.apache.poi.hssf.record.formula.eval.BlankEval;
 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.ValueEval;
 import org.apache.poi.hssf.record.formula.functions.CountUtils.I_MatchPredicate;
 
 /**
@@ -34,7 +35,7 @@ import org.apache.poi.hssf.record.formula.functions.CountUtils.I_MatchPredicate;
  */
 public final class Counta implements Function {
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                int nArgs = args.length;
                if (nArgs < 1) {
                        // too few arguments
index 5b9debc28d3d1c606af39832c2e868ee6096996b..e1de081d8b8ff6ec83f61adfa3518d09c48d0f78 100644 (file)
@@ -29,6 +29,7 @@ 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.RefEval;
 import org.apache.poi.hssf.record.formula.eval.StringEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
 import org.apache.poi.hssf.record.formula.functions.CountUtils.I_MatchPredicate;
 import org.apache.poi.ss.usermodel.ErrorConstants;
 
@@ -400,7 +401,7 @@ public final class Countif implements Function {
                }
        }
 
-       public Eval evaluate(Eval[] args, int srcRowIndex, short srcColumnIndex) {
+       public ValueEval evaluate(ValueEval[] args, int srcRowIndex, short srcColumnIndex) {
                switch(args.length) {
                        case 2:
                                // expected
index 0240f817e71d356f0c42a7d357ed4fc8c92639fa..a2a2572587f5e79b6ca64a76720797eb40b89768 100644 (file)
 package org.apache.poi.hssf.record.formula.functions;
 
 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.EvaluationException;
 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.ValueEval;
 import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
 
 /**
@@ -52,7 +52,7 @@ import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
  */
 public final class Errortype implements Function {
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
 
                try {
                        OperandResolver.getSingleValue(args[0], srcCellRow, srcCellCol);
index b94686bb9e9bcd9bd6719b1854ee0dd839df4d0b..c5ddc266ac74fd8ce6704972278b0f12827c2d72 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.poi.hssf.record.formula.functions;
 
 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.ValueEval;
 
 /**
@@ -28,7 +27,7 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
  */
 public final class False implements Function {
 
-    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+    public ValueEval evaluate(ValueEval[] operands, int srcRow, short srcCol) {
         ValueEval retval;
         switch (operands.length) {
         default:
index 90e6afe05fa107cc8db366f88c90cdd00b0d50da..1aff51cf4fc96f80e391481785d6aef035d33133 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.poi.hssf.record.formula.functions;
 
 import org.apache.poi.hssf.record.formula.eval.BlankEval;
 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.MissingArgEval;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
@@ -31,16 +30,14 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
 public interface Function {
 
        /**
-        * @param args the evaluated function arguments. Elements of this array typically implement
-        * {@link ValueEval}.  Empty values are represented with {@link BlankEval} or {@link
-        * MissingArgEval}, never <code>null</code>.
+        * @param args the evaluated function arguments.  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>.
         * <b>Note</b> - Excel uses the error code <i>#NUM!</i> instead of IEEE <i>NaN</i>, so when
         * numeric functions evaluate to {@link Double#NaN} be sure to translate the result to {@link
         * ErrorEval#NUM_ERROR}.
-        *
         */
-       Eval evaluate(Eval[] args, int srcRowIndex, short srcColumnIndex);
+       ValueEval evaluate(ValueEval[] args, int srcRowIndex, short srcColumnIndex);
 }
index 8230fb01f9a4010cf0cf2d7f0a3fdcbb770a4536..35a0b3ae340ee7d42678a30c6ee4332421ab8248 100644 (file)
@@ -42,7 +42,7 @@ import org.apache.poi.hssf.record.formula.functions.LookupUtils.ValueVector;
  */
 public final class Hlookup implements Function {
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                Eval arg3 = null;
                switch(args.length) {
                        case 4:
index ecfdebf26f80808d382ef2163903fbf706398b79..19659081ecd040dff1713564dfefe9e684021640 100644 (file)
 package org.apache.poi.hssf.record.formula.functions;
 
 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.EvaluationException;
 import org.apache.poi.hssf.record.formula.eval.OperandResolver;
 import org.apache.poi.hssf.record.formula.eval.StringEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
 /**
  * Implementation of Excel HYPERLINK function.<p/>
@@ -41,7 +41,7 @@ import org.apache.poi.hssf.record.formula.eval.StringEval;
  */
 public final class Hyperlink implements Function {
 
-       public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+       public ValueEval evaluate(ValueEval[] operands, int srcRow, short srcCol) {
                int lastArgIx = operands.length - 1;
                if (lastArgIx < 0 || lastArgIx > 1) {
                        return ErrorEval.VALUE_INVALID;
index 450a96834b048aa4aa87b2a2b55f046612241466..f8d3c03ee3f59071537de1abcf9e3cc1459b7f4b 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.poi.hssf.record.formula.functions;
 
 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.EvaluationException;
 import org.apache.poi.hssf.record.formula.eval.OperandResolver;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
@@ -30,8 +29,8 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
  */
 public final class If implements Function {
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
-               Eval falseResult;
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
+               ValueEval falseResult;
                switch (args.length) {
                        case 3:
                                falseResult = args[2];
@@ -54,7 +53,7 @@ public final class If implements Function {
                return falseResult;
        }
 
-       private static boolean evaluateFirstArg(Eval arg, int srcCellRow, short srcCellCol)
+       private static boolean evaluateFirstArg(ValueEval arg, int srcCellRow, short srcCellCol)
                        throws EvaluationException {
                ValueEval ve = OperandResolver.getSingleValue(arg, srcCellRow, srcCellCol);
                Boolean b = OperandResolver.coerceValueToBoolean(ve, false);
index b4eca2b9b5dd4ec2b1857f409219301f9dc378a0..acdd6adde85b5a7a46e0d551d6f7348c2bc07338 100644 (file)
@@ -47,7 +47,7 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
  */
 public final class Index implements Function {
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                int nArgs = args.length;
                if(nArgs < 2) {
                        // too few arguments
index 818a463d955159869798b324f4d52b779f191b75..55919a3a8413210b9287b3e22cd39b6662dd660b 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.poi.hssf.record.formula.functions;
 import org.apache.poi.hssf.record.formula.eval.AreaEval;
 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.RefEval;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
@@ -30,7 +29,7 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
  */
 public final class IsError implements Function {
 
-    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {
+    public ValueEval evaluate(ValueEval[] operands, int srcCellRow, short srcCellCol) {
         ValueEval retval = null;
         boolean b = false;
 
index 0c9cf4f2007ed6184a8ae99357323ffc038fe079..d8f9ac9ecb405f84eee21aabfd3150b0d960ad81 100644 (file)
@@ -22,6 +22,7 @@ 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.EvaluationException;
 import org.apache.poi.hssf.record.formula.eval.OperandResolver;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
 import org.apache.poi.ss.usermodel.ErrorConstants;
 
 /**
@@ -38,7 +39,7 @@ import org.apache.poi.ss.usermodel.ErrorConstants;
  */
 public final class IsNa implements Function {
 
-       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 655d296c396ee813a07f00ec7f90b656f23c256f..51e8ee441f467c7b5f0deb5364e3f6e9fd4c38d8 100644 (file)
@@ -31,7 +31,7 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
  */
 public final class Isblank implements Function {
 
-       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;
                }
diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Islogical.java b/src/java/org/apache/poi/hssf/record/formula/functions/Islogical.java
deleted file mode 100644 (file)
index 666c89e..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ====================================================================
-   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.functions;
-
-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.RefEval;
-
-/**
- * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
- *
- */
-public final class Islogical extends LogicalFunction {
-
-    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {
-        Eval retval = BoolEval.FALSE;
-
-        switch (operands.length) {
-        default:
-            retval = ErrorEval.VALUE_INVALID;
-            break;
-        case 1:
-            Eval eval = operands[0];
-            if (eval instanceof BoolEval) {
-                retval = BoolEval.TRUE;
-            }
-            else if (eval instanceof RefEval) {
-                Eval xlatedEval = xlateRefEval((RefEval) eval);
-                if (xlatedEval instanceof BoolEval) {
-                    retval = BoolEval.TRUE;
-                }
-            }
-        }
-
-        return retval;
-    }
-}
diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Isnontext.java b/src/java/org/apache/poi/hssf/record/formula/functions/Isnontext.java
deleted file mode 100644 (file)
index e62dc69..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ====================================================================
-   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.functions;
-
-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.RefEval;
-import org.apache.poi.hssf.record.formula.eval.StringEval;
-
-/**
- * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
- *
- */
-public final class Isnontext extends LogicalFunction {
-    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {
-        Eval retval = BoolEval.TRUE;
-
-        switch (operands.length) {
-        default:
-            retval = ErrorEval.VALUE_INVALID;
-            break;
-        case 1:
-            Eval eval = operands[0];
-            if (eval instanceof StringEval) {
-                retval = BoolEval.FALSE;
-            }
-            else if (eval instanceof RefEval) {
-                Eval xlatedEval = xlateRefEval((RefEval) eval);
-                if (xlatedEval instanceof StringEval) {
-                    retval = BoolEval.FALSE;
-                }
-            }
-        }
-
-        return retval;
-    }
-}
diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Isnumber.java b/src/java/org/apache/poi/hssf/record/formula/functions/Isnumber.java
deleted file mode 100644 (file)
index f00fd05..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ====================================================================
-   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.functions;
-
-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.RefEval;
-
-/**
- * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
- *
- */
-public final class Isnumber extends LogicalFunction {
-    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {
-        Eval retval = BoolEval.FALSE;
-
-        switch (operands.length) {
-        default:
-            retval = ErrorEval.VALUE_INVALID;
-            break;
-        case 1:
-            Eval eval = operands[0];
-            if (eval instanceof NumberEval) {
-                retval = BoolEval.TRUE;
-            }
-            else if (eval instanceof RefEval) {
-                Eval xlatedEval = xlateRefEval((RefEval) eval);
-                if (xlatedEval instanceof NumberEval) {
-                    retval = BoolEval.TRUE;
-                }
-            }
-        }
-
-        return retval;
-    }
-}
index 565d5e49896d5abdbeaed584281c3936de6fbbf0..f5d8ac7e384e6cdffc20a30d76e80fb2a6fa0e93 100644 (file)
@@ -22,26 +22,22 @@ 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.RefEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
 /**
  * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
- *
  */
 public final class Isref implements Function {
-    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {
-        Eval retval = BoolEval.FALSE;
+       public ValueEval evaluate(ValueEval[] operands, int srcCellRow, short srcCellCol) {
+               if (operands.length != 1) {
+                       return ErrorEval.VALUE_INVALID;
+               }
 
-        switch (operands.length) {
-        default:
-            retval = ErrorEval.VALUE_INVALID;
-            break;
-        case 1:
-            Eval eval = operands[0];
-            if (eval instanceof RefEval || eval instanceof AreaEval) {
-                retval = BoolEval.TRUE;
-            }
-        }
+               Eval eval = operands[0];
+               if (eval instanceof RefEval || eval instanceof AreaEval) {
+                       return BoolEval.TRUE;
+               }
 
-        return retval;
-    }
+               return BoolEval.FALSE;
+       }
 }
diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Istext.java b/src/java/org/apache/poi/hssf/record/formula/functions/Istext.java
deleted file mode 100644 (file)
index f669d7f..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/* ====================================================================
-   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.functions;
-
-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.RefEval;
-import org.apache.poi.hssf.record.formula.eval.StringEval;
-
-/**
- * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
- *
- */
-public final class Istext extends LogicalFunction {
-    public Eval evaluate(Eval[] operands, int srcCellRow, short srcCellCol) {
-        Eval retval = BoolEval.FALSE;
-
-        switch (operands.length) {
-        default:
-            retval = ErrorEval.VALUE_INVALID;
-            break;
-        case 1:
-            Eval eval = operands[0];
-            if (eval instanceof StringEval) {
-                retval = BoolEval.TRUE;
-            }
-            else if (eval instanceof RefEval) {
-                Eval xlatedEval = xlateRefEval((RefEval) eval);
-                if (xlatedEval instanceof StringEval) {
-                    retval = BoolEval.TRUE;
-                }
-            }
-        }
-
-        return retval;
-    }
-}
index ae5a0ebf6b1d4635116fc4c5df88eefde6f9a17b..fadad2ca7c76234d1109095715715c76fc973ac4 100644 (file)
 
 package org.apache.poi.hssf.record.formula.functions;
 
+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.EvaluationException;
+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.RefEval;
+import org.apache.poi.hssf.record.formula.eval.StringEval;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
 /**
  * @author Amol S. Deshmukh &lt; amolweb at ya hoo dot com &gt;
- *
  */
 public abstract class LogicalFunction implements Function {
 
-    /**
-     * recursively evaluate any RefEvals
-     * TODO - use {@link OperandResolver}
-     */
-    protected ValueEval xlateRefEval(RefEval reval) {
-        ValueEval retval = reval.getInnerValueEval();
+       /**
+        * recursively evaluate any RefEvals TODO - use {@link OperandResolver}
+        */
+       private static ValueEval xlateRefEval(RefEval reval) {
+               ValueEval retval = reval.getInnerValueEval();
 
-        if (retval instanceof RefEval) {
-            RefEval re = (RefEval) retval;
-            retval = xlateRefEval(re);
-        }
+               if (retval instanceof RefEval) {
+                       RefEval re = (RefEval) retval;
+                       retval = xlateRefEval(re);
+               }
 
-        return retval;
-    }
+               return retval;
+       }
+
+       public final ValueEval evaluate(ValueEval[] operands, int srcCellRow, short srcCellCol) {
+               if (operands.length != 1) {
+                       return ErrorEval.VALUE_INVALID;
+               }
+               ValueEval ve;
+               try {
+                       ve = OperandResolver.getSingleValue(operands[0], srcCellRow, srcCellCol);
+               } catch (EvaluationException e) {
+                       if (false) {
+                               // Note - it is more usual to propagate error codes straight to the result like this:
+                               return e.getErrorEval();
+                               // but logical functions behave a little differently
+                       }
+                       // this will usually cause a 'FALSE' result except for ISNONTEXT()
+                       ve = e.getErrorEval();
+               }
+               if (ve instanceof RefEval) {
+                       ve = xlateRefEval((RefEval) ve);
+               }
+               return BoolEval.valueOf(evaluate(ve));
+
+       }
+       protected abstract boolean evaluate(ValueEval arg);
+
+       public static final Function IsLogical = new LogicalFunction() {
+               protected boolean evaluate(ValueEval arg) {
+                       return arg instanceof BoolEval;
+               }
+       };
+       public static final Function IsNonText = new LogicalFunction() {
+               protected boolean evaluate(ValueEval arg) {
+                       return !(arg instanceof StringEval);
+               }
+       };
+       public static final Function IsNumber = new LogicalFunction() {
+               protected boolean evaluate(ValueEval arg) {
+                       return arg instanceof NumberEval;
+               }
+       };
+       public static final Function IsText = new LogicalFunction() {
+               protected boolean evaluate(ValueEval arg) {
+                       return arg instanceof StringEval;
+               }
+       };
 }
index 0cbae7fb8824f2cfb7c87bad5ae0a2f3caf8e710..7bb3326d4ed32a78a64fa449efe3bf32cbb17651 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.poi.hssf.record.formula.functions;
 
 import org.apache.poi.hssf.record.formula.eval.AreaEval;
 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.EvaluationException;
 import org.apache.poi.hssf.record.formula.eval.OperandResolver;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
@@ -41,7 +40,7 @@ import org.apache.poi.hssf.record.formula.functions.LookupUtils.ValueVector;
  */
 public final class Lookup implements Function {
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                switch(args.length) {
                        case 3:
                                break;
index 7a8cc6cc24a6c6ae34a4b1432403c2d123d40456..9f6193744098242e911bad4462b51b8a347f4e3f 100644 (file)
@@ -67,7 +67,7 @@ import org.apache.poi.hssf.record.formula.functions.LookupUtils.ValueVector;
 public final class Match implements Function {
 
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
 
                double match_type = 1; // default
 
index 767e980c1c0604d7ded553a3bcf99e32293a9b3e..4c6295615dab4318b7b372b6f100237007aeed4a 100644 (file)
@@ -74,7 +74,7 @@ public final class Mode implements Function {
 
        }
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                double result;
                try {
                        List<Double> temp = new ArrayList<Double>();
index 30b72ee74f36ec8cad65cc2548bb7013bca9505b..67bfaa038b626dd1363c40810fa6a29c00e98eac 100644 (file)
@@ -83,7 +83,7 @@ public abstract class MultiOperandNumericFunction implements Function {
 
        private static final int DEFAULT_MAX_NUM_OPERANDS = 30;
 
-       public final Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public final ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
 
                double d;
                try {
index 720b0c661f175395898e79499c4d4376ad4f66c3..d24a5994a909aef915d6f22addd880c21956dda8 100644 (file)
@@ -18,7 +18,7 @@
 package org.apache.poi.hssf.record.formula.functions;
 
 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.ValueEval;
 
 /**
  * Implementation of Excel function NA()
@@ -27,7 +27,7 @@ import org.apache.poi.hssf.record.formula.eval.Eval;
  */
 public final class Na implements Function {
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                return ErrorEval.NA;
        }
 
index 46d1e7142a2a625187a5325ea8fba5f6024526d0..4e89ac30960a054b68df4fcfbe65ebc579e2dfc0 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.poi.hssf.record.formula.functions;
 
 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.EvaluationException;
 import org.apache.poi.hssf.record.formula.eval.OperandResolver;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
@@ -33,7 +32,7 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
  */
 public final class Not implements Function {
 
-       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 9c685d0f51f0a7dfb1b70ee7f39b04157ee02e1d..e243e87289c5918f6c70d78f8e865a4cd211031a 100644 (file)
@@ -17,7 +17,7 @@
 
 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.eval.NotImplementedException;
 
 /**
@@ -38,7 +38,7 @@ public final class NotImplementedFunction implements Function {
                _functionName = name;
        }
 
-       public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+       public ValueEval evaluate(ValueEval[] operands, int srcRow, short srcCol) {
                throw new NotImplementedException(_functionName);
        }
        public String getFunctionName() {
index 528d7f98abb5fcd242c01931d8bbc5ff7ec20b42..cb9687654b6a34bba6bfdd71cadf9ff3fb523a28 100644 (file)
@@ -20,8 +20,8 @@ package org.apache.poi.hssf.record.formula.functions;
 import java.util.Date;
 
 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.ValueEval;
 import org.apache.poi.hssf.usermodel.HSSFDateUtil;
 
 /**
@@ -31,7 +31,7 @@ import org.apache.poi.hssf.usermodel.HSSFDateUtil;
  */
 public final class Now implements Function {
 
-       public Eval evaluate(Eval[] evals, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] evals, int srcCellRow, short srcCellCol) {
                if (evals.length > 0) {
                        return ErrorEval.VALUE_INVALID;
                }
index 136cf36630ab636dcd35fc2851a5388f90499da0..310be7bb15ecabe1f279b60fbc1ae0924019a84f 100644 (file)
@@ -46,7 +46,7 @@ public abstract class NumericFunction implements Function {
                }
        }
 
-       public final Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public final ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                double result;
                try {
                        result = eval(args, srcCellRow, srcCellCol);
index 0fda540e3a3705849c63d3b6a1adc970bbe4230d..c83e1b8f572dd0f5b5adcfd754d08788b2725708 100644 (file)
@@ -164,7 +164,7 @@ public final class Offset implements Function {
                }
        }
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                if(args.length < 3 || args.length > 5) {
                        return ErrorEval.VALUE_INVALID;
                }
index d69015b14847db728d1c228d1bd289815c530185..3282c7d78664585ddcafcc41d54e624b69638baa 100644 (file)
@@ -18,7 +18,6 @@
 package org.apache.poi.hssf.record.formula.functions;
 
 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.ValueEval;
 
@@ -30,7 +29,7 @@ public final class Pi implements Function {
 
     private static final NumberEval PI_EVAL = new NumberEval(Math.PI);
 
-    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+    public ValueEval evaluate(ValueEval[] operands, int srcRow, short srcCol) {
         ValueEval retval;
         switch (operands.length) {
         default:
index c9940fffedb23db135a308d7b3ef7f6489b7e57f..5f5173e85610e34709660be1fc260e122ee22a4a 100644 (file)
@@ -18,7 +18,6 @@
 package org.apache.poi.hssf.record.formula.functions;
 
 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.ValueEval;
 
@@ -28,7 +27,7 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
  */
 public final class Rand implements Function {
 
-    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+    public ValueEval evaluate(ValueEval[] operands, int srcRow, short srcCol) {
         ValueEval retval;
         switch (operands.length) {
         default:
index ac164012620c96d0afeecd3ba03145a3abe3ab0b..59c1203b75eb32a49e113e96102ac6992170170c 100644 (file)
@@ -19,14 +19,13 @@ package org.apache.poi.hssf.record.formula.functions;
 
 import org.apache.poi.hssf.record.formula.eval.AreaEval;
 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.RefEval;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
 public final class Row implements Function {
 
-    public Eval evaluate(Eval[] evals, int srcCellRow, short srcCellCol) {
+    public ValueEval evaluate(ValueEval[] evals, int srcCellRow, short srcCellCol) {
         ValueEval retval = null;
         int rnum = -1;
 
index 9f331f47d73dd8a4861c66653b5b384a0b7491cc..7272a07c5daef67cf9ed2975e26a285884e77908 100644 (file)
@@ -22,6 +22,7 @@ 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.RefEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
 /**
  * Implementation for Excel ROWS function.
@@ -30,7 +31,7 @@ import org.apache.poi.hssf.record.formula.eval.RefEval;
  */
 public final class Rows implements Function {
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                switch(args.length) {
                        case 1:
                                // expected
index 8eb2565d8921c59adc3ceaaba57774af4774e505..97ba463d92af0803bc1766a6c03ea2e1c7af73b8 100644 (file)
@@ -41,7 +41,7 @@ import org.apache.poi.hssf.record.formula.functions.CountUtils.I_MatchPredicate;
  */
 public final class Sumif implements Function {
 
-       public Eval evaluate(Eval[] args, int srcRowIndex, short srcColumnIndex) {
+       public ValueEval evaluate(ValueEval[] args, int srcRowIndex, short srcColumnIndex) {
                if (args.length < 2) {
                        return ErrorEval.VALUE_INVALID;
                }
index 572c67f9265f094594b9d17028b2573d503b16e3..bc743e7197a9843b7eb232330ce2106f807d2d6f 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.poi.hssf.record.formula.functions;
 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.ErrorEval;
-import org.apache.poi.hssf.record.formula.eval.Eval;
 import org.apache.poi.hssf.record.formula.eval.EvaluationException;
 import org.apache.poi.hssf.record.formula.eval.NumberEval;
 import org.apache.poi.hssf.record.formula.eval.NumericValueEval;
@@ -54,14 +53,14 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
 public final class Sumproduct implements Function {
 
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
 
                int maxN = args.length;
 
                if(maxN < 1) {
                        return ErrorEval.VALUE_INVALID;
                }
-               Eval firstArg = args[0];
+               ValueEval firstArg = args[0];
                try {
                        if(firstArg instanceof NumericValueEval) {
                                return evaluateSingleProduct(args);
@@ -83,7 +82,7 @@ public final class Sumproduct implements Function {
                                + firstArg.getClass().getName() + ")");
        }
 
-       private static Eval evaluateSingleProduct(Eval[] evalArgs) throws EvaluationException {
+       private static ValueEval evaluateSingleProduct(ValueEval[] evalArgs) throws EvaluationException {
                int maxN = evalArgs.length;
 
                double term = 1D;
@@ -94,9 +93,9 @@ public final class Sumproduct implements Function {
                return new NumberEval(term);
        }
 
-       private static double getScalarValue(Eval arg) throws EvaluationException {
+       private static double getScalarValue(ValueEval arg) throws EvaluationException {
 
-               Eval eval;
+               ValueEval eval;
                if (arg instanceof RefEval) {
                        RefEval re = (RefEval) arg;
                        eval = re.getInnerValueEval();
@@ -116,15 +115,10 @@ public final class Sumproduct implements Function {
                        eval = ae.getRelativeValue(0, 0);
                }
 
-               if (!(eval instanceof ValueEval)) {
-                       throw new RuntimeException("Unexpected value eval class ("
-                                       + eval.getClass().getName() + ")");
-               }
-
-               return getProductTerm((ValueEval) eval, true);
+               return getProductTerm(eval, true);
        }
 
-       private static Eval evaluateAreaSumProduct(Eval[] evalArgs) throws EvaluationException {
+       private static ValueEval evaluateAreaSumProduct(ValueEval[] evalArgs) throws EvaluationException {
                int maxN = evalArgs.length;
                AreaEval[] args = new AreaEval[maxN];
                try {
index 9d764c33bc0903731be344db858b39f0dbac069f..6f13d4c5ee4ae574f29e19345fa053d41c36f243 100644 (file)
 package org.apache.poi.hssf.record.formula.functions;
 
 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.RefEval;
 import org.apache.poi.hssf.record.formula.eval.StringEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
 public final class T implements Function {
 
-    public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+    public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
         switch (args.length) {
             default:
                 return ErrorEval.VALUE_INVALID;
             case 1:
                  break;
         }
-        Eval arg = args[0];
+        ValueEval arg = args[0];
         if (arg instanceof RefEval) {
             RefEval re = (RefEval) arg;
             arg = re.getInnerValueEval();
index 5fd758962df3e251d6c409655d9ed97ec2ab9ca8..ff55e1921f5ef1544e4f0248a38c48c5201278f9 100644 (file)
@@ -43,7 +43,7 @@ public abstract class TextFunction implements Function {
                return OperandResolver.coerceValueToInt(ve);
        }
 
-       public final Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public final ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                try {
                        return evaluateFunc(args, srcCellRow, srcCellCol);
                } catch (EvaluationException e) {
index 1ddb8516ffba0b1632f704dbc54f650faee64a67..6d1ef146ca4f37bbab5fb08ae112a0d8a379d3d4 100644 (file)
@@ -38,7 +38,7 @@ public final class Time implements Function {
        private static final int SECONDS_PER_DAY = HOURS_PER_DAY * SECONDS_PER_HOUR;
 
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                if (args.length != 3) {
                        return ErrorEval.VALUE_INVALID;
                }
index b71fce46111055586ebeb96aa3a04de9a5277250..434653c12cc824b90c1fbe40153652f7d7842289 100644 (file)
@@ -21,8 +21,8 @@ import java.util.Calendar;
 import java.util.GregorianCalendar;
 
 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.ValueEval;
 import org.apache.poi.hssf.usermodel.HSSFDateUtil;
 
 /**
@@ -32,7 +32,7 @@ import org.apache.poi.hssf.usermodel.HSSFDateUtil;
  */
 public final class Today implements Function {
 
-       public Eval evaluate(Eval[] evals, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] evals, int srcCellRow, short srcCellCol) {
                if (evals.length > 0) {
                        return ErrorEval.VALUE_INVALID;
                }
index 429cc5f0d5f650ae0a4ce7b808b58a584c5bbd5b..9a80c8d479b62608245853eb5b75e06b1a05e251 100644 (file)
@@ -19,7 +19,6 @@ package org.apache.poi.hssf.record.formula.functions;
 
 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.ValueEval;
 
 /**
@@ -28,7 +27,7 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
  */
 public final class True implements Function {
 
-    public Eval evaluate(Eval[] operands, int srcRow, short srcCol) {
+    public ValueEval evaluate(ValueEval[] operands, int srcRow, short srcCol) {
         ValueEval retval;
         switch (operands.length) {
         default:
index 0dbfdb52de412041fdd49428c878145794f86256..cfa6dff4c9bccc8268021093de1c3108da7729d7 100644 (file)
@@ -18,7 +18,6 @@
 package org.apache.poi.hssf.record.formula.functions;
 
 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.EvaluationException;
 import org.apache.poi.hssf.record.formula.eval.NumberEval;
 import org.apache.poi.hssf.record.formula.eval.OperandResolver;
@@ -42,7 +41,7 @@ public final class Value implements Function {
        private static final int MIN_DISTANCE_BETWEEN_THOUSANDS_SEPARATOR = 4;
        private static final Double ZERO = new Double(0.0);
 
-       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 27d16ee86702fb720a8f193f51350fd92ed44df1..9887f69c3309e528c4fab47cbd3fe6e57fe60a40 100644 (file)
@@ -42,7 +42,7 @@ import org.apache.poi.hssf.record.formula.functions.LookupUtils.ValueVector;
  */
 public final class Vlookup implements Function {
 
-       public Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                Eval arg3 = null;
                switch(args.length) {
                        case 4:
index 5c80068fff726d3680b49d7a2097a1d018d99ba7..c43cca0adf00d03ff29739335ff8f8bb4f5bd1eb 100644 (file)
@@ -97,7 +97,7 @@ public abstract class XYNumericFunction implements Function {
         */
        protected abstract Accumulator createAccumulator();
 
-       public final Eval evaluate(Eval[] args, int srcCellRow, short srcCellCol) {
+       public final ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) {
                if (args.length != 2) {
                        return ErrorEval.VALUE_INVALID;
                }
index 727f6b76454d8d84bd29987b83846ed8890ed0fb..e14c1db9515693071bdc2c47c968e226d1db553e 100755 (executable)
@@ -22,7 +22,6 @@ import junit.framework.TestCase;
 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.ValueEval;
 /**
@@ -32,18 +31,18 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
  */
 public final class TestAverage extends TestCase {
 
-       private static Eval invokeAverage(Eval[] args) {
+       private static ValueEval invokeAverage(ValueEval[] args) {
                return AggregateFunction.AVERAGE.evaluate(args, -1, (short)-1);
        }
 
-       private void confirmAverage(Eval[] args, double expected) {
-               Eval result = invokeAverage(args);
+       private void confirmAverage(ValueEval[] args, double expected) {
+               ValueEval result = invokeAverage(args);
                assertEquals(NumberEval.class, result.getClass());
                assertEquals(expected, ((NumberEval)result).getNumberValue(), 0);
        }
 
-       private void confirmAverage(Eval[] args, ErrorEval expectedError) {
-               Eval result = invokeAverage(args);
+       private void confirmAverage(ValueEval[] args, ErrorEval expectedError) {
+               ValueEval result = invokeAverage(args);
                assertEquals(ErrorEval.class, result.getClass());
                assertEquals(expectedError.getErrorCode(), ((ErrorEval)result).getErrorCode());
        }
index 1352870c157c4eecb4a81810151ba36c03353b22..557833bed9a7a5ba261179e7f52a6e37cf856ad7 100755 (executable)
@@ -101,7 +101,7 @@ public final class TestIndex extends TestCase {
                ValueEval[] args = new ValueEval[] { arg0, MissingArgEval.instance, new NumberEval(2), };
                ValueEval actualResult;
                try {
-                       actualResult = (ValueEval) FUNC_INST.evaluate(args, 1, (short)1);
+                       actualResult = 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 459d2fb555b029c066b8be08cf69f536ae0f20c7..610897a6abfb14ee40fcddb1d422c84224919437 100755 (executable)
@@ -22,45 +22,44 @@ import junit.framework.TestCase;
 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.StringEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
 /**
  * Tests for Excel function LEN()
- * 
+ *
  * @author Josh Micich
  */
 public final class TestLen extends TestCase {
 
-       
-       private static Eval invokeLen(Eval text) {
-               Eval[] args = new Eval[] { text, };
+       private static ValueEval invokeLen(ValueEval text) {
+               ValueEval[] args = new ValueEval[] { text, };
                return TextFunction.LEN.evaluate(args, -1, (short)-1);
        }
 
-       private void confirmLen(Eval text, int expected) {
-               Eval result = invokeLen(text);
+       private void confirmLen(ValueEval text, int expected) {
+               ValueEval result = invokeLen(text);
                assertEquals(NumberEval.class, result.getClass());
                assertEquals(expected, ((NumberEval)result).getNumberValue(), 0);
        }
 
-       private void confirmLen(Eval text, ErrorEval expectedError) {
-               Eval result = invokeLen(text);
+       private void confirmLen(ValueEval text, ErrorEval expectedError) {
+               ValueEval result = invokeLen(text);
                assertEquals(ErrorEval.class, result.getClass());
                assertEquals(expectedError.getErrorCode(), ((ErrorEval)result).getErrorCode());
        }
-       
+
        public void testBasic() {
-               
+
                confirmLen(new StringEval("galactic"), 8);
        }
-       
+
        /**
         * Valid cases where text arg is not exactly a string
         */
        public void testUnusualArgs() {
-               
-               // text (first) arg type is number, other args are strings with fractional digits 
+
+               // text (first) arg type is number, other args are strings with fractional digits
                confirmLen(new NumberEval(123456), 6);
                confirmLen(BoolEval.FALSE, 5);
                confirmLen(BoolEval.TRUE, 4);
index 48104c22e5e739f6dd6fd83b63af468cf8774142..a92dd1fbc11681e2b65b4afd0080e9c9f5c9adbf 100755 (executable)
@@ -22,7 +22,6 @@ import junit.framework.TestCase;
 import org.apache.poi.hssf.record.formula.eval.AreaEval;
 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.NumericValueEval;
 import org.apache.poi.hssf.record.formula.eval.StringEval;
@@ -41,11 +40,11 @@ public final class TestMatch extends TestCase {
        private static final NumberEval MATCH_SMALLEST_GTE = new NumberEval(-1);
 
 
-       private static Eval invokeMatch(Eval lookup_value, Eval lookup_array, Eval match_type) {
-               Eval[] args = { lookup_value, lookup_array, match_type, };
+       private static ValueEval invokeMatch(ValueEval lookup_value, ValueEval lookup_array, ValueEval match_type) {
+               ValueEval[] args = { lookup_value, lookup_array, match_type, };
                return new Match().evaluate(args, -1, (short)-1);
        }
-       private static void confirmInt(int expected, Eval actualEval) {
+       private static void confirmInt(int expected, ValueEval actualEval) {
                if(!(actualEval instanceof NumericValueEval)) {
                        fail("Expected numeric result");
                }
index 81e78e737c4f4a4914b31fb929386149b638e82b..dc4d50208d947b243498e29d4854640576f87de8 100755 (executable)
@@ -23,7 +23,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.RefEval;
 import org.apache.poi.hssf.record.formula.eval.StringEval;
@@ -36,19 +35,19 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
 public final class TestMid extends TestCase {
 
 
-       private static Eval invokeMid(Eval text, Eval startPos, Eval numChars) {
-               Eval[] args = new Eval[] { text, startPos, numChars, };
+       private static ValueEval invokeMid(ValueEval text, ValueEval startPos, ValueEval numChars) {
+               ValueEval[] args = new ValueEval[] { text, startPos, numChars, };
                return TextFunction.MID.evaluate(args, -1, (short)-1);
        }
 
-       private void confirmMid(Eval text, Eval startPos, Eval numChars, String expected) {
-               Eval result = invokeMid(text, startPos, numChars);
+       private void confirmMid(ValueEval text, ValueEval startPos, ValueEval numChars, String expected) {
+               ValueEval result = invokeMid(text, startPos, numChars);
                assertEquals(StringEval.class, result.getClass());
                assertEquals(expected, ((StringEval)result).getStringValue());
        }
 
-       private void confirmMid(Eval text, Eval startPos, Eval numChars, ErrorEval expectedError) {
-               Eval result = invokeMid(text, startPos, numChars);
+       private void confirmMid(ValueEval text, ValueEval startPos, ValueEval numChars, ErrorEval expectedError) {
+               ValueEval result = invokeMid(text, startPos, numChars);
                assertEquals(ErrorEval.class, result.getClass());
                assertEquals(expectedError.getErrorCode(), ((ErrorEval)result).getErrorCode());
        }
index a919c35af488c10a8c38b72d5c66d2e8d5a8aa38..99fb4dea410d653d4636d511e2161f44231311d7 100644 (file)
@@ -19,8 +19,8 @@ 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.NumberEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
 import org.apache.poi.hssf.usermodel.HSSFCell;
 import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
 import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
@@ -29,18 +29,18 @@ import org.apache.poi.hssf.usermodel.HSSFWorkbook;
 
 /**
  * Tests for {@link FinanceFunction#NPER}
- * 
+ *
  * @author Josh Micich
  */
 public final class TestNper extends TestCase {
        public void testSimpleEvaluate() {
 
-               Eval[] args = {
+               ValueEval[] args = {
                        new NumberEval(0.05),
                        new NumberEval(250),
                        new NumberEval(-1000),
                };
-               Eval result = FinanceFunction.NPER.evaluate(args, 0, (short)0);
+               ValueEval result = FinanceFunction.NPER.evaluate(args, 0, (short)0);
 
                assertEquals(NumberEval.class, result.getClass());
                assertEquals(4.57353557, ((NumberEval)result).getNumberValue(), 0.00000001);
index 9a4cded9af68cfbac3b6ae2a793864724487e52e..cac4bde13ff6e245ee39a8ff3ef64777a0344cd3 100644 (file)
@@ -21,12 +21,11 @@ import junit.framework.AssertionFailedError;
 import junit.framework.TestCase;
 
 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.ValueEval;
 import org.apache.poi.hssf.record.formula.eval.NumberEval;
 import org.apache.poi.hssf.usermodel.HSSFErrorConstants;
 
 /**
- * 
  * @author Josh Micich
  */
 public final class TestPmt extends TestCase {
@@ -35,14 +34,14 @@ public final class TestPmt extends TestCase {
                // only asserting accuracy to 4 fractional digits
                assertEquals(expected, ne.getNumberValue(), 0.00005);
        }
-       private static Eval invoke(Eval[] args) {
+       private static ValueEval invoke(ValueEval[] args) {
                return FinanceFunction.PMT.evaluate(args, -1, (short)-1);
        }
        /**
         * Invocation when not expecting an error result
         */
-       private static NumberEval invokeNormal(Eval[] args) {
-               Eval ev = invoke(args);
+       private static NumberEval invokeNormal(ValueEval[] args) {
+               ValueEval ev = invoke(args);
                if(ev instanceof ErrorEval) {
                        throw new AssertionFailedError("Normal evaluation failed with error code: "
                                        + ev.toString());
@@ -51,7 +50,7 @@ public final class TestPmt extends TestCase {
        }
 
        private static void confirm(double expected, double rate, double nper, double pv, double fv, boolean isBeginning) {
-               Eval[] args = { 
+               ValueEval[] args = {
                                new NumberEval(rate),
                                new NumberEval(nper),
                                new NumberEval(pv),
@@ -68,20 +67,20 @@ public final class TestPmt extends TestCase {
        }
 
        public void test3args() {
-               
-               Eval[] args = { 
+
+               ValueEval[] args = {
                                new NumberEval(0.005),
                                new NumberEval(24),
                                new NumberEval(1000),
                };
-               Eval ev = invoke(args);
+               ValueEval ev = invoke(args);
                if(ev instanceof ErrorEval) {
                        ErrorEval err = (ErrorEval) ev;
                        if(err.getErrorCode() == HSSFErrorConstants.ERROR_VALUE) {
                                throw new AssertionFailedError("Identified bug 44691");
                        }
                }
-               
+
                confirm(-44.3206, invokeNormal(args));
        }
 }
index 9dbbb438e0f2a01c71ce3afa4290338b08ab5c88..d3fa564391a11dd9cf6c102e84e4603ba8ccebcc 100755 (executable)
@@ -20,31 +20,31 @@ package org.apache.poi.hssf.record.formula.functions;
 import junit.framework.TestCase;
 
 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.ValueEval;
 import org.apache.poi.hssf.record.formula.eval.NumberEval;
 import org.apache.poi.hssf.record.formula.eval.StringEval;
 
 /**
  * Test cases for ROUND(), ROUNDUP(), ROUNDDOWN()
- * 
+ *
  * @author Josh Micich
  */
 public final class TestRoundFuncs extends TestCase {
        private static final NumericFunction F = null;
        public void testRounddownWithStringArg() {
-               
-               Eval strArg = new StringEval("abc");
-               Eval[] args = { strArg, new NumberEval(2), };
-               Eval result = F.ROUNDDOWN.evaluate(args, -1, (short)-1);
+
+               ValueEval strArg = new StringEval("abc");
+               ValueEval[] args = { strArg, new NumberEval(2), };
+               ValueEval result = F.ROUNDDOWN.evaluate(args, -1, (short)-1);
                assertEquals(ErrorEval.VALUE_INVALID, result);
        }
-       
+
        public void testRoundupWithStringArg() {
-               
-               Eval strArg = new StringEval("abc");
-               Eval[] args = { strArg, new NumberEval(2), };
-               Eval result = F.ROUNDUP.evaluate(args, -1, (short)-1);
+
+               ValueEval strArg = new StringEval("abc");
+               ValueEval[] args = { strArg, new NumberEval(2), };
+               ValueEval result = F.ROUNDUP.evaluate(args, -1, (short)-1);
                assertEquals(ErrorEval.VALUE_INVALID, result);
        }
-       
+
 }
index 47ee0afbb62938fdfa303c0af759fa5019237c6f..63d1088e8c74837245829a8179028b24c51693d4 100755 (executable)
@@ -21,7 +21,6 @@ import junit.framework.TestCase;
 
 import org.apache.poi.hssf.record.formula.eval.AreaEval;
 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.NumericValueEval;
 import org.apache.poi.hssf.record.formula.eval.RefEval;
@@ -29,16 +28,16 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
 /**
  * Test cases for SUMPRODUCT()
- * 
+ *
  * @author Josh Micich
  */
 public final class TestSumproduct extends TestCase {
-       
-       private static Eval invokeSumproduct(Eval[] args) {
+
+       private static ValueEval invokeSumproduct(ValueEval[] args) {
                // srcCellRow and srcCellColumn are ignored by SUMPRODUCT
                return new Sumproduct().evaluate(args, -1, (short)-1);
        }
-       private static void confirmDouble(double expected, Eval actualEval) {
+       private static void confirmDouble(double expected, ValueEval actualEval) {
                if(!(actualEval instanceof NumericValueEval)) {
                        fail("Expected numeric result");
                }
@@ -49,11 +48,11 @@ public final class TestSumproduct extends TestCase {
        public void testScalarSimple() {
 
                RefEval refEval = EvalFactory.createRefEval("A1", new NumberEval(3));
-               Eval[] args = {
-                       refEval, 
+               ValueEval[] args = {
+                       refEval,
                        new NumberEval(2),
                };
-               Eval result = invokeSumproduct(args);
+               ValueEval result = invokeSumproduct(args);
                confirmDouble(6D, result);
        }
 
@@ -70,9 +69,9 @@ public final class TestSumproduct extends TestCase {
                };
                AreaEval aeA = EvalFactory.createAreaEval("A1:A3", aValues);
                AreaEval aeB = EvalFactory.createAreaEval("B1:B3", bValues);
-               
-               Eval[] args = { aeA, aeB, };
-               Eval result = invokeSumproduct(args);
+
+               ValueEval[] args = { aeA, aeB, };
+               ValueEval result = invokeSumproduct(args);
                confirmDouble(65D, result);
        }
 
@@ -83,27 +82,27 @@ public final class TestSumproduct extends TestCase {
 
                AreaEval ae = EvalFactory.createAreaEval("A1:A1", new ValueEval[] { new NumberEval(7), });
 
-               Eval[] args = {
-                               ae, 
+               ValueEval[] args = {
+                               ae,
                                new NumberEval(2),
                        };
-               Eval result = invokeSumproduct(args);
+               ValueEval result = invokeSumproduct(args);
                confirmDouble(14D, result);
        }
 
        public void testMismatchAreaDimensions() {
-               
+
                AreaEval aeA = EvalFactory.createAreaEval("A1:A3", new ValueEval[3]);
                AreaEval aeB = EvalFactory.createAreaEval("B1:D1", new ValueEval[3]);
 
-               Eval[] args;
-               args = new Eval[] { aeA, aeB, };
+               ValueEval[] args;
+               args = new ValueEval[] { aeA, aeB, };
                assertEquals(ErrorEval.VALUE_INVALID, invokeSumproduct(args));
 
-               args = new Eval[] { aeA, new NumberEval(5), };
+               args = new ValueEval[] { aeA, new NumberEval(5), };
                assertEquals(ErrorEval.VALUE_INVALID, invokeSumproduct(args));
        }
-       
+
        public void testAreaWithErrorCell() {
                ValueEval[] aValues = {
                        ErrorEval.REF_INVALID,
@@ -112,7 +111,7 @@ public final class TestSumproduct extends TestCase {
                AreaEval aeA = EvalFactory.createAreaEval("A1:A2", aValues);
                AreaEval aeB = EvalFactory.createAreaEval("B1:B2", new ValueEval[2]);
 
-               Eval[] args = { aeA, aeB, };
+               ValueEval[] args = { aeA, aeB, };
                assertEquals(ErrorEval.REF_INVALID, invokeSumproduct(args));
        }
 }
index ac7152d0e20c6bb670551cefe324a3318b6510e1..53482c86c874d7a2625128f69946de3a1308b790 100755 (executable)
@@ -22,14 +22,13 @@ import junit.framework.TestCase;
 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.StringEval;
 import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
 /**
  * Test cases for Excel function T()
- * 
+ *
  * @author Josh Micich
  */
 public final class TestTFunc extends TestCase {
@@ -37,9 +36,9 @@ public final class TestTFunc extends TestCase {
        /**
         * @return the result of calling function T() with the specified argument
         */
-       private static Eval invokeT(Eval arg) {
-               Eval[] args = { arg, };
-               Eval result = new T().evaluate(args, -1, (short)-1);
+       private static ValueEval invokeT(ValueEval arg) {
+               ValueEval[] args = { arg, };
+               ValueEval result = new T().evaluate(args, -1, (short)-1);
                assertNotNull("result may never be null", result);
                return result;
        }
@@ -47,20 +46,20 @@ public final class TestTFunc extends TestCase {
         * Simulates call: T(A1)
         * where cell A1 has the specified innerValue
         */
-       private Eval invokeTWithReference(ValueEval innerValue) {
-               Eval arg = EvalFactory.createRefEval("$B$2", innerValue);
+       private ValueEval invokeTWithReference(ValueEval innerValue) {
+               ValueEval arg = EvalFactory.createRefEval("$B$2", innerValue);
                return invokeT(arg);
        }
-       
+
        private static void confirmText(String text) {
-               Eval arg = new StringEval(text);
-               Eval eval = invokeT(arg);
+               ValueEval arg = new StringEval(text);
+               ValueEval eval = invokeT(arg);
                StringEval se = (StringEval) eval;
                assertEquals(text, se.getStringValue());
        }
-       
+
        public void testTextValues() {
-               
+
                confirmText("abc");
                confirmText("");
                confirmText(" ");
@@ -68,26 +67,26 @@ public final class TestTFunc extends TestCase {
                confirmText("123");
                confirmText("TRUE");
        }
-       
-       private static void confirmError(Eval arg) {
-               Eval eval = invokeT(arg);
+
+       private static void confirmError(ValueEval arg) {
+               ValueEval eval = invokeT(arg);
                assertTrue(arg == eval);
        }
 
        public void testErrorValues() {
-               
+
                confirmError(ErrorEval.VALUE_INVALID);
                confirmError(ErrorEval.NA);
                confirmError(ErrorEval.REF_INVALID);
        }
-       
-       private static void confirmString(Eval eval, String expected) {
+
+       private static void confirmString(ValueEval eval, String expected) {
                assertTrue(eval instanceof StringEval);
                assertEquals(expected, ((StringEval)eval).getStringValue());
        }
 
-       private static void confirmOther(Eval arg) {
-               Eval eval = invokeT(arg);
+       private static void confirmOther(ValueEval arg) {
+               ValueEval eval = invokeT(arg);
                confirmString(eval, "");
        }
 
@@ -98,8 +97,8 @@ public final class TestTFunc extends TestCase {
        }
 
        public void testRefValues() {
-               Eval eval;
-               
+               ValueEval eval;
+
                eval = invokeTWithReference(new StringEval("def"));
                confirmString(eval, "def");
                eval = invokeTWithReference(new StringEval(" "));
@@ -109,7 +108,7 @@ public final class TestTFunc extends TestCase {
                confirmString(eval, "");
                eval = invokeTWithReference(BoolEval.TRUE);
                confirmString(eval, "");
-               
+
                eval = invokeTWithReference(ErrorEval.NAME_INVALID);
                assertTrue(eval == ErrorEval.NAME_INVALID);
        }
index 1c65c9ca6d95fcb6b4c740771035190699cf01c1..a95b15157cd86c63c7f20dba8d74e802539398c6 100755 (executable)
@@ -22,36 +22,36 @@ import junit.framework.TestCase;
 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.StringEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
 /**
  * Tests for Excel function TRIM()
- * 
+ *
  * @author Josh Micich
  */
 public final class TestTrim extends TestCase {
 
-       
-       private static Eval invokeTrim(Eval text) {
-               Eval[] args = new Eval[] { text, };
+
+       private static ValueEval invokeTrim(ValueEval text) {
+               ValueEval[] args = new ValueEval[] { text, };
                return TextFunction.TRIM.evaluate(args, -1, (short)-1);
        }
 
-       private void confirmTrim(Eval text, String expected) {
-               Eval result = invokeTrim(text);
+       private void confirmTrim(ValueEval text, String expected) {
+               ValueEval result = invokeTrim(text);
                assertEquals(StringEval.class, result.getClass());
                assertEquals(expected, ((StringEval)result).getStringValue());
        }
 
-       private void confirmTrim(Eval text, ErrorEval expectedError) {
-               Eval result = invokeTrim(text);
+       private void confirmTrim(ValueEval text, ErrorEval expectedError) {
+               ValueEval result = invokeTrim(text);
                assertEquals(ErrorEval.class, result.getClass());
                assertEquals(expectedError.getErrorCode(), ((ErrorEval)result).getErrorCode());
        }
-       
+
        public void testBasic() {
-               
+
                confirmTrim(new StringEval(" hi "), "hi");
                confirmTrim(new StringEval("hi "), "hi");
                confirmTrim(new StringEval("  hi"), "hi");
@@ -59,13 +59,13 @@ public final class TestTrim extends TestCase {
                confirmTrim(new StringEval(""), "");
                confirmTrim(new StringEval("   "), "");
        }
-       
+
        /**
         * Valid cases where text arg is not exactly a string
         */
        public void testUnusualArgs() {
-               
-               // text (first) arg type is number, other args are strings with fractional digits 
+
+               // text (first) arg type is number, other args are strings with fractional digits
                confirmTrim(new NumberEval(123456), "123456");
                confirmTrim(BoolEval.FALSE, "FALSE");
                confirmTrim(BoolEval.TRUE, "TRUE");
index 5f74fbf1a6612786fb5cf2259e6853b58ea7fb2c..19a6d68927e99c998aa308a5620f62216222d04b 100644 (file)
@@ -20,30 +20,30 @@ package org.apache.poi.hssf.record.formula.functions;
 import junit.framework.TestCase;
 
 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.StringEval;
+import org.apache.poi.hssf.record.formula.eval.ValueEval;
 
 /**
  * Tests for {@link Value}
- * 
+ *
  * @author Josh Micich
  */
 public final class TestValue extends TestCase {
 
-       private static Eval invokeValue(String strText) {
-               Eval[] args = new Eval[] { new StringEval(strText), };
+       private static ValueEval invokeValue(String strText) {
+               ValueEval[] args = new ValueEval[] { new StringEval(strText), };
                return new Value().evaluate(args, -1, (short) -1);
        }
 
        private static void confirmValue(String strText, double expected) {
-               Eval result = invokeValue(strText);
+               ValueEval result = invokeValue(strText);
                assertEquals(NumberEval.class, result.getClass());
                assertEquals(expected, ((NumberEval) result).getNumberValue(), 0.0);
        }
 
        private static void confirmValueError(String strText) {
-               Eval result = invokeValue(strText);
+               ValueEval result = invokeValue(strText);
                assertEquals(ErrorEval.class, result.getClass());
                assertEquals(ErrorEval.VALUE_INVALID, result);
        }
index 0d62b1fb0fae4a6f2e4c5ec4eb7064eab42a39fc..818409cae78d2e39c8e2662d36f677cade6ba137 100755 (executable)
@@ -20,45 +20,44 @@ package org.apache.poi.hssf.record.formula.functions;
 import junit.framework.TestCase;
 
 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.ValueEval;
 /**
  * Tests for Excel functions SUMX2MY2(), SUMX2PY2(), SUMXMY2()
- * 
+ *
  * @author Josh Micich
  */
 public final class TestXYNumericFunction extends TestCase {
        private static final Function SUM_SQUARES = new Sumx2py2();
        private static final Function DIFF_SQUARES = new Sumx2my2();
        private static final Function SUM_SQUARES_OF_DIFFS = new Sumxmy2();
-       
-       private static Eval invoke(Function function, Eval xArray, Eval yArray) {
-               Eval[] args = new Eval[] { xArray, yArray, };
+
+       private static ValueEval invoke(Function function, ValueEval xArray, ValueEval yArray) {
+               ValueEval[] args = new ValueEval[] { xArray, yArray, };
                return function.evaluate(args, -1, (short)-1);
        }
 
-       private void confirm(Function function, Eval xArray, Eval yArray, double expected) {
-               Eval result = invoke(function, xArray, yArray);
+       private void confirm(Function function, ValueEval xArray, ValueEval yArray, double expected) {
+               ValueEval result = invoke(function, xArray, yArray);
                assertEquals(NumberEval.class, result.getClass());
                assertEquals(expected, ((NumberEval)result).getNumberValue(), 0);
        }
-       private void confirmError(Function function, Eval xArray, Eval yArray, ErrorEval expectedError) {
-               Eval result = invoke(function, xArray, yArray);
+       private void confirmError(Function function, ValueEval xArray, ValueEval yArray, ErrorEval expectedError) {
+               ValueEval result = invoke(function, xArray, yArray);
                assertEquals(ErrorEval.class, result.getClass());
                assertEquals(expectedError.getErrorCode(), ((ErrorEval)result).getErrorCode());
        }
 
-       private void confirmError(Eval xArray, Eval yArray, ErrorEval expectedError) {
+       private void confirmError(ValueEval xArray, ValueEval yArray, ErrorEval expectedError) {
                confirmError(SUM_SQUARES, xArray, yArray, expectedError);
                confirmError(DIFF_SQUARES, xArray, yArray, expectedError);
                confirmError(SUM_SQUARES_OF_DIFFS, xArray, yArray, expectedError);
        }
-       
+
        public void testBasic() {
                ValueEval[] xValues = {
-                       new NumberEval(1),      
-                       new NumberEval(2),      
+                       new NumberEval(1),
+                       new NumberEval(2),
                };
                ValueEval areaEvalX = createAreaEval(xValues);
                confirm(SUM_SQUARES, areaEvalX, areaEvalX, 10.0);
@@ -66,27 +65,27 @@ public final class TestXYNumericFunction extends TestCase {
                confirm(SUM_SQUARES_OF_DIFFS, areaEvalX, areaEvalX, 0.0);
 
                ValueEval[] yValues = {
-                       new NumberEval(3),      
-                       new NumberEval(4),      
+                       new NumberEval(3),
+                       new NumberEval(4),
                };
                ValueEval areaEvalY = createAreaEval(yValues);
                confirm(SUM_SQUARES, areaEvalX, areaEvalY, 30.0);
                confirm(DIFF_SQUARES, areaEvalX, areaEvalY, -20.0);
                confirm(SUM_SQUARES_OF_DIFFS, areaEvalX, areaEvalY, 8.0);
        }
-       
+
        /**
         * number of items in array is not limited to 30
         */
        public void testLargeArrays() {
                ValueEval[] xValues = createMockNumberArray(100, 3);
                ValueEval[] yValues = createMockNumberArray(100, 2);
-               
+
                confirm(SUM_SQUARES, createAreaEval(xValues), createAreaEval(yValues), 1300.0);
                confirm(DIFF_SQUARES, createAreaEval(xValues), createAreaEval(yValues), 500.0);
                confirm(SUM_SQUARES_OF_DIFFS, createAreaEval(xValues), createAreaEval(yValues), 100.0);
        }
-       
+
 
        private ValueEval[] createMockNumberArray(int size, double value) {
                ValueEval[] result = new ValueEval[size];
@@ -103,20 +102,20 @@ public final class TestXYNumericFunction extends TestCase {
 
        public void testErrors() {
                ValueEval[] xValues = {
-                               ErrorEval.REF_INVALID,  
-                               new NumberEval(2),      
+                               ErrorEval.REF_INVALID,
+                               new NumberEval(2),
                };
                ValueEval areaEvalX = createAreaEval(xValues);
                ValueEval[] yValues = {
-                               new NumberEval(2),      
-                               ErrorEval.NULL_INTERSECTION,    
+                               new NumberEval(2),
+                               ErrorEval.NULL_INTERSECTION,
                };
                ValueEval areaEvalY = createAreaEval(yValues);
                ValueEval[] zValues = { // wrong size
-                               new NumberEval(2),      
+                               new NumberEval(2),
                };
                ValueEval areaEvalZ = createAreaEval(zValues);
-               
+
                // if either arg is an error, that error propagates
                confirmError(ErrorEval.REF_INVALID, ErrorEval.NAME_INVALID, ErrorEval.REF_INVALID);
                confirmError(areaEvalX, ErrorEval.NAME_INVALID, ErrorEval.NAME_INVALID);
@@ -128,10 +127,9 @@ public final class TestXYNumericFunction extends TestCase {
 
                // any error in an array item propagates up
                confirmError(areaEvalX, areaEvalX, ErrorEval.REF_INVALID);
-               
+
                // search for errors array by array, not pair by pair
                confirmError(areaEvalX, areaEvalY, ErrorEval.REF_INVALID);
                confirmError(areaEvalY, areaEvalX, ErrorEval.NULL_INTERSECTION);
-               
        }
 }