From: Josh Micich Date: Mon, 17 Aug 2009 22:34:22 +0000 (+0000) Subject: Removed obsolete Eval interface X-Git-Tag: REL_3_5-FINAL~40 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=acd4e8270e2de4f518806459ac71c61ee843afb4;p=poi.git Removed obsolete Eval interface git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@805192 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hssf/record/formula/atp/ParityFunction.java b/src/java/org/apache/poi/hssf/record/formula/atp/ParityFunction.java index 04ba61e120..602710e984 100644 --- a/src/java/org/apache/poi/hssf/record/formula/atp/ParityFunction.java +++ b/src/java/org/apache/poi/hssf/record/formula/atp/ParityFunction.java @@ -19,7 +19,7 @@ package org.apache.poi.hssf.record.formula.atp; 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; 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; @@ -56,7 +56,7 @@ final class ParityFunction implements FreeRefFunction { return BoolEval.valueOf(val == _desiredParity); } - private static int evaluateArgParity(Eval arg, int srcCellRow, int srcCellCol) throws EvaluationException { + private static int evaluateArgParity(ValueEval arg, int srcCellRow, int srcCellCol) throws EvaluationException { ValueEval ve = OperandResolver.getSingleValue(arg, srcCellRow, (short)srcCellCol); double d = OperandResolver.coerceValueToDouble(ve); diff --git a/src/java/org/apache/poi/hssf/record/formula/atp/YearFrac.java b/src/java/org/apache/poi/hssf/record/formula/atp/YearFrac.java index ea2dc38015..baab17991a 100644 --- a/src/java/org/apache/poi/hssf/record/formula/atp/YearFrac.java +++ b/src/java/org/apache/poi/hssf/record/formula/atp/YearFrac.java @@ -22,7 +22,7 @@ import java.util.GregorianCalendar; import java.util.regex.Pattern; 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.EvaluationException; import org.apache.poi.hssf.record.formula.eval.NumberEval; import org.apache.poi.hssf.record.formula.eval.OperandResolver; @@ -83,7 +83,7 @@ final class YearFrac implements FreeRefFunction { return new NumberEval(result); } - private static double evaluateDateArg(Eval arg, int srcCellRow, int srcCellCol) throws EvaluationException { + private static double evaluateDateArg(ValueEval arg, int srcCellRow, int srcCellCol) throws EvaluationException { ValueEval ve = OperandResolver.getSingleValue(arg, srcCellRow, (short) srcCellCol); if (ve instanceof StringEval) { @@ -153,7 +153,7 @@ final class YearFrac implements FreeRefFunction { return cal; } - private static int evaluateIntArg(Eval arg, int srcCellRow, int srcCellCol) throws EvaluationException { + private static int evaluateIntArg(ValueEval arg, int srcCellRow, int srcCellCol) throws EvaluationException { ValueEval ve = OperandResolver.getSingleValue(arg, srcCellRow, (short) srcCellCol); return OperandResolver.coerceValueToInt(ve); } diff --git a/src/java/org/apache/poi/hssf/record/formula/eval/Eval.java b/src/java/org/apache/poi/hssf/record/formula/eval/Eval.java deleted file mode 100644 index 1cf9047f7e..0000000000 --- a/src/java/org/apache/poi/hssf/record/formula/eval/Eval.java +++ /dev/null @@ -1,29 +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. -*/ -/* - * Created on May 8, 2005 - * - */ -package org.apache.poi.hssf.record.formula.eval; - -/** - * @author Amol S. Deshmukh < amolweb at ya hoo dot com > - * - */ -public interface Eval { - // TODO - remove this interface -} diff --git a/src/java/org/apache/poi/hssf/record/formula/eval/OperandResolver.java b/src/java/org/apache/poi/hssf/record/formula/eval/OperandResolver.java index 675aad4384..29f7a4dc2d 100755 --- a/src/java/org/apache/poi/hssf/record/formula/eval/OperandResolver.java +++ b/src/java/org/apache/poi/hssf/record/formula/eval/OperandResolver.java @@ -19,7 +19,7 @@ package org.apache.poi.hssf.record.formula.eval; /** * Provides functionality for evaluating arguments to functions and operators. - * + * * @author Josh Micich */ public final class OperandResolver { @@ -37,12 +37,12 @@ public final class OperandResolver { * @return a NumberEval, StringEval, BoolEval or BlankEval. * Never null or ErrorEval. * @throws EvaluationException(#VALUE!) if srcCellRow or srcCellCol do not properly index into - * an AreaEval. If the actual value retrieved is an ErrorEval, a corresponding + * an AreaEval. If the actual value retrieved is an ErrorEval, a corresponding * EvaluationException is thrown. */ - public static ValueEval getSingleValue(Eval arg, int srcCellRow, short srcCellCol) + public static ValueEval getSingleValue(ValueEval arg, int srcCellRow, short srcCellCol) throws EvaluationException { - Eval result; + ValueEval result; if (arg instanceof RefEval) { result = ((RefEval) arg).getInnerValueEval(); } else if (arg instanceof AreaEval) { @@ -63,7 +63,7 @@ public final class OperandResolver { * Implements (some perhaps not well known) Excel functionality to select a single cell from an * area depending on the coordinates of the calling cell. Here is an example demonstrating * both selection from a single row area and a single column area in the same formula. - * + * * * * @@ -71,10 +71,10 @@ public final class OperandResolver { * * *
  A  B  C  D 
1152025 
3   300
3   400
- * + * * If the formula "=1000+A1:B1+D2:D3" is put into the 9 cells from A2 to C4, the spreadsheet * will look like this: - * + * * * * @@ -82,28 +82,28 @@ public final class OperandResolver { * * *
  A  B  C  D 
1152025 
313151320#VALUE!300
4#VALUE!#VALUE!#VALUE!400
- * - * Note that the row area (A1:B1) does not include column C and the column area (D2:D3) does + * + * Note that the row area (A1:B1) does not include column C and the column area (D2:D3) does * not include row 4, so the values in C1(=25) and D4(=400) are not accessible to the formula * as written, but in the 4 cells A2:B3, the row and column selection works ok.

- * - * The same concept is extended to references across sheets, such that even multi-row, + * + * The same concept is extended to references across sheets, such that even multi-row, * multi-column areas can be useful.

- * + * * Of course with carefully (or carelessly) chosen parameters, cyclic references can occur and - * hence this method can throw a 'circular reference' EvaluationException. Note that + * hence this method can throw a 'circular reference' EvaluationException. Note that * this method does not attempt to detect cycles. Every cell in the specified Area ae - * has already been evaluated prior to this method call. Any cell (or cells) part of - * ae that would incur a cyclic reference error if selected by this method, will + * has already been evaluated prior to this method call. Any cell (or cells) part of + * ae that would incur a cyclic reference error if selected by this method, will * already have the value ErrorEval.CIRCULAR_REF_ERROR upon entry to this method. It * is assumed logic exists elsewhere to produce this behaviour. - * + * * @return whatever the selected cell's evaluated value is. Never null. Never * ErrorEval. * @throws EvaluationException if there is a problem with indexing into the area, or if the * evaluated cell has an error. */ - public static ValueEval chooseSingleElementFromArea(AreaEval ae, + public static ValueEval chooseSingleElementFromArea(AreaEval ae, int srcCellRow, short srcCellCol) throws EvaluationException { ValueEval result = chooseSingleElementFromAreaInternal(ae, srcCellRow, srcCellCol); if(result == null) { @@ -119,9 +119,9 @@ public final class OperandResolver { } /** - * @return possibly ErrorEval, and null + * @return possibly ErrorEval, and null */ - private static ValueEval chooseSingleElementFromAreaInternal(AreaEval ae, + private static ValueEval chooseSingleElementFromAreaInternal(AreaEval ae, int srcCellRow, short srcCellCol) throws EvaluationException { if(false) { @@ -140,10 +140,10 @@ public final class OperandResolver { Another reason there's little value in attempting to detect circular references here is that only direct circular references could be detected. If the cycle involved two or more - cells this method could not detect it. + cells this method could not detect it. Logic to detect evaluation cycles of all kinds has been coded in EvaluationCycleDetector - (and HSSFFormulaEvaluator). + (and HSSFFormulaEvaluator). */ } @@ -172,14 +172,14 @@ public final class OperandResolver { /** * Applies some conversion rules if the supplied value is not already an integer.
* Value is first coerced to a double ( See coerceValueToDouble() ). - * Note - BlankEval is converted to 0.

- * + * Note - BlankEval is converted to 0.

+ * * Excel typically converts doubles to integers by truncating toward negative infinity.
* The equivalent java code is:
*   return (int)Math.floor(d);
* not:
- *   return (int)d; // wrong - rounds toward zero - * + *   return (int)d; // wrong - rounds toward zero + * */ public static int coerceValueToInt(ValueEval ev) throws EvaluationException { if (ev == BlankEval.INSTANCE) { @@ -193,13 +193,13 @@ public final class OperandResolver { /** * Applies some conversion rules if the supplied value is not already a number. - * Note - BlankEval is converted to {@link NumberEval#ZERO}. - * @param ev must be a {@link NumberEval}, {@link StringEval}, {@link BoolEval} or + * Note - BlankEval is converted to {@link NumberEval#ZERO}. + * @param ev must be a {@link NumberEval}, {@link StringEval}, {@link BoolEval} or * {@link BlankEval} * @return actual, parsed or interpreted double value (respectively). * @throws EvaluationException(#VALUE!) only if a StringEval is supplied and cannot be parsed * as a double (See parseDouble() for allowable formats). - * @throws RuntimeException if the supplied parameter is not {@link NumberEval}, + * @throws RuntimeException if the supplied parameter is not {@link NumberEval}, * {@link StringEval}, {@link BoolEval} or {@link BlankEval} */ public static double coerceValueToDouble(ValueEval ev) throws EvaluationException { @@ -224,8 +224,8 @@ public final class OperandResolver { /** * Converts a string to a double using standard rules that Excel would use.
* Tolerates currency prefixes, commas, leading and trailing spaces.

- * - * Some examples:
+ * + * Some examples:
* " 123 " -> 123.0
* ".123" -> 0.123
* These not supported yet:
@@ -233,8 +233,7 @@ public final class OperandResolver { * "$1.25E4" -> 12500.0
* "5**2" -> 500
* "250%" -> 2.5
- * - * @param pText + * * @return null if the specified text cannot be parsed as a number */ public static Double parseDouble(String pText) { diff --git a/src/java/org/apache/poi/hssf/record/formula/eval/RangeEval.java b/src/java/org/apache/poi/hssf/record/formula/eval/RangeEval.java index cf3ed58477..8db93bb3ea 100644 --- a/src/java/org/apache/poi/hssf/record/formula/eval/RangeEval.java +++ b/src/java/org/apache/poi/hssf/record/formula/eval/RangeEval.java @@ -60,7 +60,7 @@ public final class RangeEval implements OperationEval { return aeA.offset(top-aeAfr, bottom-aeAfr, left-aeAfc, right-aeAfc); } - private static AreaEval evaluateRef(Eval arg) throws EvaluationException { + private static AreaEval evaluateRef(ValueEval arg) throws EvaluationException { if (arg instanceof AreaEval) { return (AreaEval) arg; } diff --git a/src/java/org/apache/poi/hssf/record/formula/eval/TwoOperandNumericOperation.java b/src/java/org/apache/poi/hssf/record/formula/eval/TwoOperandNumericOperation.java index f8ff34ab00..17587e838e 100644 --- a/src/java/org/apache/poi/hssf/record/formula/eval/TwoOperandNumericOperation.java +++ b/src/java/org/apache/poi/hssf/record/formula/eval/TwoOperandNumericOperation.java @@ -22,7 +22,7 @@ package org.apache.poi.hssf.record.formula.eval; */ abstract class TwoOperandNumericOperation implements OperationEval { - protected final double singleOperandEvaluate(Eval arg, int srcCellRow, short srcCellCol) throws EvaluationException { + protected final double singleOperandEvaluate(ValueEval arg, int srcCellRow, short srcCellCol) throws EvaluationException { ValueEval ve = OperandResolver.getSingleValue(arg, srcCellRow, srcCellCol); return OperandResolver.coerceValueToDouble(ve); } diff --git a/src/java/org/apache/poi/hssf/record/formula/eval/UserDefinedFunction.java b/src/java/org/apache/poi/hssf/record/formula/eval/UserDefinedFunction.java index 65252d08d4..384b576eec 100755 --- a/src/java/org/apache/poi/hssf/record/formula/eval/UserDefinedFunction.java +++ b/src/java/org/apache/poi/hssf/record/formula/eval/UserDefinedFunction.java @@ -44,7 +44,7 @@ final class UserDefinedFunction implements FreeRefFunction { throw new RuntimeException("function name argument missing"); } - Eval nameArg = args[0]; + ValueEval nameArg = args[0]; FreeRefFunction targetFunc; if (nameArg instanceof NameEval) { targetFunc = findInternalUserDefinedFunction((NameEval) nameArg); diff --git a/src/java/org/apache/poi/hssf/record/formula/eval/ValueEval.java b/src/java/org/apache/poi/hssf/record/formula/eval/ValueEval.java index 4581fa4d6e..9b6bbae6d8 100644 --- a/src/java/org/apache/poi/hssf/record/formula/eval/ValueEval.java +++ b/src/java/org/apache/poi/hssf/record/formula/eval/ValueEval.java @@ -1,29 +1,25 @@ -/* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ -/* - * Created on May 8, 2005 - * - */ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ + package org.apache.poi.hssf.record.formula.eval; /** * @author Amol S. Deshmukh < amolweb at ya hoo dot com > - * */ -public interface ValueEval extends Eval { - +public interface ValueEval { + // no methods } diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/BooleanFunction.java b/src/java/org/apache/poi/hssf/record/formula/functions/BooleanFunction.java index 76be216f2f..ac5fea80c2 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/BooleanFunction.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/BooleanFunction.java @@ -20,11 +20,10 @@ 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.ValueEval; 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.RefEval; -import org.apache.poi.hssf.record.formula.eval.ValueEval; /** * Here are the general rules concerning Boolean functions: @@ -52,7 +51,7 @@ public abstract class BooleanFunction implements Function { return BoolEval.valueOf(boolResult); } - private boolean calculate(Eval[] args) throws EvaluationException { + private boolean calculate(ValueEval[] args) throws EvaluationException { boolean result = getInitialResultValue(); boolean atleastOneNonBlank = false; @@ -61,7 +60,7 @@ public abstract class BooleanFunction implements Function { * Note: no short-circuit boolean loop exit because any ErrorEvals will override the result */ for (int i=0, iSize=args.length; inull if the arg evaluates to blank. */ - /* package */ static I_MatchPredicate createCriteriaPredicate(Eval arg, int srcRowIndex, int srcColumnIndex) { + /* package */ static I_MatchPredicate createCriteriaPredicate(ValueEval arg, int srcRowIndex, int srcColumnIndex) { - Eval evaluatedCriteriaArg = evaluateCriteriaArg(arg, srcRowIndex, srcColumnIndex); + ValueEval evaluatedCriteriaArg = evaluateCriteriaArg(arg, srcRowIndex, srcColumnIndex); if(evaluatedCriteriaArg instanceof NumberEval) { return new NumberMatcher(((NumberEval)evaluatedCriteriaArg).getNumberValue(), CmpOp.OP_NONE); @@ -466,7 +465,7 @@ public final class Countif implements Function { * * @return the de-referenced criteria arg (possibly {@link ErrorEval}) */ - private static Eval evaluateCriteriaArg(Eval arg, int srcRowIndex, int srcColumnIndex) { + private static ValueEval evaluateCriteriaArg(ValueEval arg, int srcRowIndex, int srcColumnIndex) { try { return OperandResolver.getSingleValue(arg, srcRowIndex, (short)srcColumnIndex); } catch (EvaluationException e) { diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Find.java b/src/java/org/apache/poi/hssf/record/formula/functions/Find.java index 802b8161f5..0e9e81b08e 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Find.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Find.java @@ -17,11 +17,10 @@ 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.ErrorEval; -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.EvaluationException; +import org.apache.poi.hssf.record.formula.eval.NumberEval; +import org.apache.poi.hssf.record.formula.eval.ValueEval; /** * Implementation of the FIND() function.

@@ -37,7 +36,7 @@ import org.apache.poi.hssf.record.formula.eval.EvaluationException; */ public final class Find extends TextFunction { - protected ValueEval evaluateFunc(Eval[] args, int srcCellRow, short srcCellCol) + protected ValueEval evaluateFunc(ValueEval[] args, int srcCellRow, short srcCellCol) throws EvaluationException { int nArgs = args.length; diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Hlookup.java b/src/java/org/apache/poi/hssf/record/formula/functions/Hlookup.java index 35a0b3ae34..7d6bec1489 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Hlookup.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Hlookup.java @@ -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; @@ -43,7 +42,7 @@ import org.apache.poi.hssf.record.formula.functions.LookupUtils.ValueVector; public final class Hlookup implements Function { public ValueEval evaluate(ValueEval[] args, int srcCellRow, short srcCellCol) { - Eval arg3 = null; + ValueEval arg3 = null; switch(args.length) { case 4: arg3 = args[3]; // important: assumed array element is never null diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Index.java b/src/java/org/apache/poi/hssf/record/formula/functions/Index.java index acdd6adde8..261fc92a87 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Index.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Index.java @@ -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.MissingArgEval; import org.apache.poi.hssf.record.formula.eval.OperandResolver; @@ -53,7 +52,7 @@ public final class Index implements Function { // too few arguments return ErrorEval.VALUE_INVALID; } - Eval firstArg = args[0]; + ValueEval firstArg = args[0]; if (firstArg instanceof RefEval) { // convert to area ref for simpler code in getValueFromArea() firstArg = ((RefEval)firstArg).offset(0, 0, 0, 0); @@ -180,7 +179,7 @@ public final class Index implements Function { * @return the resolved 1-based index. Zero if the arg was missing or blank * @throws EvaluationException if the arg is an error value evaluates to a negative numeric value */ - private static int resolveIndexArg(Eval arg, int srcCellRow, short srcCellCol) throws EvaluationException { + private static int resolveIndexArg(ValueEval arg, int srcCellRow, short srcCellCol) throws EvaluationException { ValueEval ev = OperandResolver.getSingleValue(arg, srcCellRow, srcCellCol); if (ev == MissingArgEval.instance) { diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/IsNa.java b/src/java/org/apache/poi/hssf/record/formula/functions/IsNa.java index d8f9ac9ecb..a170405fe7 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/IsNa.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/IsNa.java @@ -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; @@ -43,7 +42,7 @@ public final class IsNa implements Function { if(args.length != 1) { return ErrorEval.VALUE_INVALID; } - Eval arg = args[0]; + ValueEval arg = args[0]; try { OperandResolver.getSingleValue(arg, srcCellRow, srcCellCol); diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Isblank.java b/src/java/org/apache/poi/hssf/record/formula/functions/Isblank.java index 51e8ee441f..5b9f6f51c4 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Isblank.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Isblank.java @@ -20,7 +20,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.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; @@ -35,7 +34,7 @@ public final class Isblank implements Function { if(args.length != 1) { return ErrorEval.VALUE_INVALID; } - Eval arg = args[0]; + ValueEval arg = args[0]; ValueEval singleCellValue; try { diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Isref.java b/src/java/org/apache/poi/hssf/record/formula/functions/Isref.java index f5d8ac7e38..87af93f8fe 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Isref.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Isref.java @@ -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; @@ -33,7 +32,7 @@ public final class Isref implements Function { return ErrorEval.VALUE_INVALID; } - Eval eval = operands[0]; + ValueEval eval = operands[0]; if (eval instanceof RefEval || eval instanceof AreaEval) { return BoolEval.TRUE; } diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/LookupUtils.java b/src/java/org/apache/poi/hssf/record/formula/functions/LookupUtils.java index 376d9a4e0a..c551235c45 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/LookupUtils.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/LookupUtils.java @@ -21,7 +21,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.EvaluationException; import org.apache.poi.hssf.record.formula.eval.NumberEval; import org.apache.poi.hssf.record.formula.eval.NumericValueEval; @@ -323,7 +322,7 @@ final class LookupUtils { * @return column or row index as a zero-based value, never negative. * @throws EvaluationException when the specified arg cannot be coerced to a non-negative integer */ - public static int resolveRowOrColIndexArg(Eval rowColIndexArg, int srcCellRow, int srcCellCol) throws EvaluationException { + public static int resolveRowOrColIndexArg(ValueEval rowColIndexArg, int srcCellRow, int srcCellCol) throws EvaluationException { if(rowColIndexArg == null) { throw new IllegalArgumentException("argument must not be null"); } @@ -362,7 +361,7 @@ final class LookupUtils { * The second argument (table_array) should be an area ref, but can actually be a cell ref, in * which case it is interpreted as a 1x1 area ref. Other scalar values cause #VALUE! error. */ - public static AreaEval resolveTableArrayArg(Eval eval) throws EvaluationException { + public static AreaEval resolveTableArrayArg(ValueEval eval) throws EvaluationException { if (eval instanceof AreaEval) { return (AreaEval) eval; } @@ -386,7 +385,7 @@ final class LookupUtils { * @return * @throws EvaluationException */ - public static boolean resolveRangeLookupArg(Eval rangeLookupArg, int srcCellRow, short srcCellCol) throws EvaluationException { + public static boolean resolveRangeLookupArg(ValueEval rangeLookupArg, int srcCellRow, short srcCellCol) throws EvaluationException { if(rangeLookupArg == null) { // range_lookup arg not provided return true; // default is TRUE diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Match.java b/src/java/org/apache/poi/hssf/record/formula/functions/Match.java index 9f61937440..17c756162a 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Match.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Match.java @@ -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.NumberEval; import org.apache.poi.hssf.record.formula.eval.NumericValueEval; @@ -123,7 +122,7 @@ public final class Match implements Function { } } - private static ValueVector evaluateLookupRange(Eval eval) throws EvaluationException { + private static ValueVector evaluateLookupRange(ValueEval eval) throws EvaluationException { if (eval instanceof RefEval) { RefEval re = (RefEval) eval; return new SingleValueVector(re.getInnerValueEval()); @@ -155,9 +154,9 @@ public final class Match implements Function { - private static double evaluateMatchTypeArg(Eval arg, int srcCellRow, short srcCellCol) + private static double evaluateMatchTypeArg(ValueEval arg, int srcCellRow, short srcCellCol) throws EvaluationException { - Eval match_type = OperandResolver.getSingleValue(arg, srcCellRow, srcCellCol); + ValueEval match_type = OperandResolver.getSingleValue(arg, srcCellRow, srcCellCol); if(match_type instanceof ErrorEval) { throw new EvaluationException((ErrorEval)match_type); diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Mode.java b/src/java/org/apache/poi/hssf/record/formula/functions/Mode.java index 4c6295615d..c31cd08d1b 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Mode.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Mode.java @@ -25,7 +25,6 @@ import org.apache.poi.hssf.record.formula.eval.AreaEval; import org.apache.poi.hssf.record.formula.eval.BlankEval; import org.apache.poi.hssf.record.formula.eval.BoolEval; import org.apache.poi.hssf.record.formula.eval.ErrorEval; -import org.apache.poi.hssf.record.formula.eval.Eval; import org.apache.poi.hssf.record.formula.eval.EvaluationException; import org.apache.poi.hssf.record.formula.eval.NumberEval; import org.apache.poi.hssf.record.formula.eval.RefEval; @@ -92,7 +91,7 @@ public final class Mode implements Function { return new NumberEval(result); } - private static void collectValues(Eval arg, List temp) throws EvaluationException { + private static void collectValues(ValueEval arg, List temp) throws EvaluationException { if (arg instanceof AreaEval) { AreaEval ae = (AreaEval) arg; int width = ae.getWidth(); @@ -114,7 +113,7 @@ public final class Mode implements Function { } - private static void collectValue(Eval arg, List temp, boolean mustBeNumber) + private static void collectValue(ValueEval arg, List temp, boolean mustBeNumber) throws EvaluationException { if (arg instanceof ErrorEval) { throw new EvaluationException((ErrorEval) arg); diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/MultiOperandNumericFunction.java b/src/java/org/apache/poi/hssf/record/formula/functions/MultiOperandNumericFunction.java index 67bfaa038b..69aae428b4 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/MultiOperandNumericFunction.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/MultiOperandNumericFunction.java @@ -21,7 +21,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.EvaluationException; import org.apache.poi.hssf.record.formula.eval.NumberEval; import org.apache.poi.hssf.record.formula.eval.OperandResolver; @@ -118,7 +117,7 @@ public abstract class MultiOperandNumericFunction implements Function { * * @return never null */ - protected final double[] getNumberArray(Eval[] operands) throws EvaluationException { + protected final double[] getNumberArray(ValueEval[] operands) throws EvaluationException { if (operands.length > getMaxNumOperands()) { throw EvaluationException.invalidValue(); } @@ -133,7 +132,7 @@ public abstract class MultiOperandNumericFunction implements Function { /** * Collects values from a single argument */ - private void collectValues(Eval operand, DoubleList temp) throws EvaluationException { + private void collectValues(ValueEval operand, DoubleList temp) throws EvaluationException { if (operand instanceof AreaEval) { AreaEval ae = (AreaEval) operand; @@ -152,7 +151,7 @@ public abstract class MultiOperandNumericFunction implements Function { collectValue(re.getInnerValueEval(), true, temp); return; } - collectValue((ValueEval)operand, false, temp); + collectValue(operand, false, temp); } private void collectValue(ValueEval ve, boolean isViaReference, DoubleList temp) throws EvaluationException { if (ve == null) { diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/NumericFunction.java b/src/java/org/apache/poi/hssf/record/formula/functions/NumericFunction.java index 310be7bb15..9dd6a84ce1 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/NumericFunction.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/NumericFunction.java @@ -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; @@ -33,7 +32,7 @@ public abstract class NumericFunction implements Function { static final double TEN = 10.0; static final double LOG_10_TO_BASE_e = Math.log(TEN); - protected static final double singleOperandEvaluate(Eval arg, int srcCellRow, short srcCellCol) throws EvaluationException { + protected static final double singleOperandEvaluate(ValueEval arg, int srcCellRow, short srcCellCol) throws EvaluationException { ValueEval ve = OperandResolver.getSingleValue(arg, srcCellRow, srcCellCol); double result = OperandResolver.coerceValueToDouble(ve); checkValue(result); @@ -57,7 +56,7 @@ public abstract class NumericFunction implements Function { return new NumberEval(result); } - protected abstract double eval(Eval[] args, int srcCellRow, short srcCellCol) throws EvaluationException; + protected abstract double eval(ValueEval[] args, int srcCellRow, short srcCellCol) throws EvaluationException; /* -------------------------------------------------------------------------- */ // intermediate sub-classes (one-arg, two-arg and multi-arg) @@ -66,7 +65,7 @@ public abstract class NumericFunction implements Function { protected OneArg() { // no fields to initialise } - protected final double eval(Eval[] args, int srcCellRow, short srcCellCol) throws EvaluationException { + protected final double eval(ValueEval[] args, int srcCellRow, short srcCellCol) throws EvaluationException { if (args.length != 1) { throw new EvaluationException(ErrorEval.VALUE_INVALID); } @@ -80,7 +79,7 @@ public abstract class NumericFunction implements Function { protected TwoArg() { // no fields to initialise } - protected final double eval(Eval[] args, int srcCellRow, short srcCellCol) throws EvaluationException { + protected final double eval(ValueEval[] args, int srcCellRow, short srcCellCol) throws EvaluationException { if (args.length != 2) { throw new EvaluationException(ErrorEval.VALUE_INVALID); } @@ -98,7 +97,7 @@ public abstract class NumericFunction implements Function { _minArgs = minArgs; _maxArgs = maxArgs; } - protected final double eval(Eval[] args, int srcCellRow, short srcCellCol) throws EvaluationException { + protected final double eval(ValueEval[] args, int srcCellRow, short srcCellCol) throws EvaluationException { int nArgs = args.length; if (nArgs < _minArgs || nArgs > _maxArgs) { throw new EvaluationException(ErrorEval.VALUE_INVALID); diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Offset.java b/src/java/org/apache/poi/hssf/record/formula/functions/Offset.java index c83e1b8f57..c3df6062ff 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Offset.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Offset.java @@ -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.EvaluationException; import org.apache.poi.hssf.record.formula.eval.NumericValueEval; import org.apache.poi.hssf.record.formula.eval.OperandResolver; @@ -207,7 +206,7 @@ public final class Offset implements Function { return baseRef.offset(orRow.getFirstIndex(), orRow.getLastIndex(), orCol.getFirstIndex(), orCol.getLastIndex()); } - private static BaseRef evaluateBaseRef(Eval eval) throws EvaluationException { + private static BaseRef evaluateBaseRef(ValueEval eval) throws EvaluationException { if(eval instanceof RefEval) { return new BaseRef((RefEval)eval); @@ -224,7 +223,7 @@ public final class Offset implements Function { /** * OFFSET's numeric arguments (2..5) have similar processing rules */ - private static int evaluateIntArg(Eval eval, int srcCellRow, short srcCellCol) throws EvaluationException { + private static int evaluateIntArg(ValueEval eval, int srcCellRow, short srcCellCol) throws EvaluationException { double d = evaluateDoubleArg(eval, srcCellRow, srcCellCol); return convertDoubleToInt(d); @@ -240,7 +239,7 @@ public final class Offset implements Function { return (int)Math.floor(d); } - private static double evaluateDoubleArg(Eval eval, int srcCellRow, short srcCellCol) throws EvaluationException { + private static double evaluateDoubleArg(ValueEval eval, int srcCellRow, short srcCellCol) throws EvaluationException { ValueEval ve = OperandResolver.getSingleValue(eval, srcCellRow, srcCellCol); if (ve instanceof NumericValueEval) { diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Replace.java b/src/java/org/apache/poi/hssf/record/formula/functions/Replace.java index 8ff69491c6..3a32d64308 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Replace.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Replace.java @@ -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.StringEval; import org.apache.poi.hssf.record.formula.eval.ValueEval; @@ -40,7 +39,7 @@ import org.apache.poi.hssf.record.formula.eval.ValueEval; */ public final class Replace extends TextFunction { - protected ValueEval evaluateFunc(Eval[] args, int srcCellRow, short srcCellCol) + protected ValueEval evaluateFunc(ValueEval[] args, int srcCellRow, short srcCellCol) throws EvaluationException { if (args.length != 4) { return ErrorEval.VALUE_INVALID; diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Rows.java b/src/java/org/apache/poi/hssf/record/formula/functions/Rows.java index 7272a07c5d..77e347fe17 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Rows.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Rows.java @@ -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.NumberEval; import org.apache.poi.hssf.record.formula.eval.RefEval; import org.apache.poi.hssf.record.formula.eval.ValueEval; @@ -43,7 +42,7 @@ public final class Rows implements Function { // too many arguments return ErrorEval.VALUE_INVALID; } - Eval firstArg = args[0]; + ValueEval firstArg = args[0]; int result; if (firstArg instanceof AreaEval) { diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Substitute.java b/src/java/org/apache/poi/hssf/record/formula/functions/Substitute.java index 2cd3a719c4..287d9ff2fe 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Substitute.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Substitute.java @@ -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.StringEval; 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 Substitute extends TextFunction { - protected ValueEval evaluateFunc(Eval[] args, int srcCellRow, short srcCellCol) + protected ValueEval evaluateFunc(ValueEval[] args, int srcCellRow, short srcCellCol) throws EvaluationException { if (args.length < 3 || args.length > 4) { return ErrorEval.VALUE_INVALID; diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/Sumif.java b/src/java/org/apache/poi/hssf/record/formula/functions/Sumif.java index 97ba463d92..e60d43befc 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/Sumif.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/Sumif.java @@ -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.NumberEval; import org.apache.poi.hssf.record.formula.eval.RefEval; @@ -100,7 +99,7 @@ public final class Sumif implements Function { * @return a range of the same dimensions as aeRange using eval to define the top left corner. * @throws EvaluationException if eval is not a reference */ - private static AreaEval createSumRange(Eval eval, AreaEval aeRange) throws EvaluationException { + private static AreaEval createSumRange(ValueEval eval, AreaEval aeRange) throws EvaluationException { if (eval instanceof AreaEval) { return ((AreaEval) eval).offset(0, aeRange.getHeight()-1, 0, aeRange.getWidth()-1); } @@ -110,7 +109,7 @@ public final class Sumif implements Function { throw new EvaluationException(ErrorEval.VALUE_INVALID); } - private static AreaEval convertRangeArg(Eval eval) throws EvaluationException { + private static AreaEval convertRangeArg(ValueEval eval) throws EvaluationException { if (eval instanceof AreaEval) { return (AreaEval) eval; } diff --git a/src/java/org/apache/poi/hssf/record/formula/functions/TextFunction.java b/src/java/org/apache/poi/hssf/record/formula/functions/TextFunction.java index ff55e1921f..b6ed8148de 100644 --- a/src/java/org/apache/poi/hssf/record/formula/functions/TextFunction.java +++ b/src/java/org/apache/poi/hssf/record/formula/functions/TextFunction.java @@ -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.NumberEval; import org.apache.poi.hssf.record.formula.eval.OperandResolver; @@ -34,11 +33,11 @@ public abstract class TextFunction implements Function { protected static final String EMPTY_STRING = ""; - protected static final String evaluateStringArg(Eval eval, int srcRow, short srcCol) throws EvaluationException { + protected static final String evaluateStringArg(ValueEval eval, int srcRow, short srcCol) throws EvaluationException { ValueEval ve = OperandResolver.getSingleValue(eval, srcRow, srcCol); return OperandResolver.coerceValueToString(ve); } - protected static final int evaluateIntArg(Eval arg, int srcCellRow, short srcCellCol) throws EvaluationException { + protected static final int evaluateIntArg(ValueEval arg, int srcCellRow, short srcCellCol) throws EvaluationException { ValueEval ve = OperandResolver.getSingleValue(arg, srcCellRow, srcCellCol); return OperandResolver.coerceValueToInt(ve); } @@ -51,7 +50,7 @@ public abstract class TextFunction implements Function { } } - protected abstract ValueEval evaluateFunc(Eval[] args, int srcCellRow, short srcCellCol) throws EvaluationException; + protected abstract ValueEval evaluateFunc(ValueEval[] args, int srcCellRow, short srcCellCol) throws EvaluationException; /* ---------------------------------------------------------------------- */ @@ -60,7 +59,7 @@ public abstract class TextFunction implements Function { protected SingleArgTextFunc() { // no fields to initialise } - protected ValueEval evaluateFunc(Eval[] args, int srcCellRow, short srcCellCol) + protected ValueEval evaluateFunc(ValueEval[] args, int srcCellRow, short srcCellCol) throws EvaluationException { if (args.length != 1) { return ErrorEval.VALUE_INVALID; @@ -110,7 +109,7 @@ public abstract class TextFunction implements Function { */ public static final Function MID = new TextFunction() { - protected ValueEval evaluateFunc(Eval[] args, int srcCellRow, short srcCellCol) + protected ValueEval evaluateFunc(ValueEval[] args, int srcCellRow, short srcCellCol) throws EvaluationException { if (args.length != 3) { return ErrorEval.VALUE_INVALID; @@ -145,7 +144,7 @@ public abstract class TextFunction implements Function { protected LeftRight(boolean isLeft) { _isLeft = isLeft; } - protected ValueEval evaluateFunc(Eval[] args, int srcCellRow, short srcCellCol) + protected ValueEval evaluateFunc(ValueEval[] args, int srcCellRow, short srcCellCol) throws EvaluationException { if (args.length != 2) { return ErrorEval.VALUE_INVALID; @@ -168,7 +167,7 @@ public abstract class TextFunction implements Function { public static final Function CONCATENATE = new TextFunction() { - protected ValueEval evaluateFunc(Eval[] args, int srcCellRow, short srcCellCol) + protected ValueEval evaluateFunc(ValueEval[] args, int srcCellRow, short srcCellCol) throws EvaluationException { StringBuffer sb = new StringBuffer(); for (int i=0, iSize=args.length; i