mirror of https://github.com/apache/poi.git
Removed obsolete Eval interface
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@805192 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
174458f38f
commit
acd4e8270e
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -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 <tt>NumberEval</tt>, <tt>StringEval</tt>, <tt>BoolEval</tt> or <tt>BlankEval</tt>.
|
||||
* Never <code>null</code> or <tt>ErrorEval</tt>.
|
||||
* @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.
|
||||
*
|
||||
*
|
||||
* <table border="1" cellpadding="1" cellspacing="1" summary="sample spreadsheet">
|
||||
* <tr><th> </th><th> A </th><th> B </th><th> C </th><th> D </th></tr>
|
||||
* <tr><th>1</th><td>15</td><td>20</td><td>25</td><td> </td></tr>
|
||||
|
@ -71,10 +71,10 @@ public final class OperandResolver {
|
|||
* <tr><th>3</th><td> </td><td> </td><td> </td><td>300</td></tr>
|
||||
* <tr><th>3</th><td> </td><td> </td><td> </td><td>400</td></tr>
|
||||
* </table>
|
||||
*
|
||||
*
|
||||
* If the formula "=1000+A1:B1+D2:D3" is put into the 9 cells from A2 to C4, the spreadsheet
|
||||
* will look like this:
|
||||
*
|
||||
*
|
||||
* <table border="1" cellpadding="1" cellspacing="1" summary="sample spreadsheet">
|
||||
* <tr><th> </th><th> A </th><th> B </th><th> C </th><th> D </th></tr>
|
||||
* <tr><th>1</th><td>15</td><td>20</td><td>25</td><td> </td></tr>
|
||||
|
@ -82,28 +82,28 @@ public final class OperandResolver {
|
|||
* <tr><th>3</th><td>1315</td><td>1320</td><td>#VALUE!</td><td>300</td></tr>
|
||||
* <tr><th>4</th><td>#VALUE!</td><td>#VALUE!</td><td>#VALUE!</td><td>400</td></tr>
|
||||
* </table>
|
||||
*
|
||||
* 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.<p/>
|
||||
*
|
||||
* 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.<p/>
|
||||
*
|
||||
*
|
||||
* Of course with carefully (or carelessly) chosen parameters, cyclic references can occur and
|
||||
* hence this method <b>can</b> throw a 'circular reference' EvaluationException. Note that
|
||||
* hence this method <b>can</b> throw a 'circular reference' EvaluationException. Note that
|
||||
* this method does not attempt to detect cycles. Every cell in the specified Area <tt>ae</tt>
|
||||
* has already been evaluated prior to this method call. Any cell (or cell<b>s</b>) part of
|
||||
* <tt>ae</tt> 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 cell<b>s</b>) part of
|
||||
* <tt>ae</tt> that would incur a cyclic reference error if selected by this method, will
|
||||
* already have the value <t>ErrorEval.CIRCULAR_REF_ERROR</tt> 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 <code>null</code>. Never
|
||||
* <tt>ErrorEval</tt>.
|
||||
* @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 <tt>ErrorEval</tt>, and <code>null</code>
|
||||
* @return possibly <tt>ErrorEval</tt>, and <code>null</code>
|
||||
*/
|
||||
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.<br/>
|
||||
* Value is first coerced to a <tt>double</tt> ( See <tt>coerceValueToDouble()</tt> ).
|
||||
* Note - <tt>BlankEval</tt> is converted to <code>0</code>.<p/>
|
||||
*
|
||||
* Note - <tt>BlankEval</tt> is converted to <code>0</code>.<p/>
|
||||
*
|
||||
* Excel typically converts doubles to integers by truncating toward negative infinity.<br/>
|
||||
* The equivalent java code is:<br/>
|
||||
* <code>return (int)Math.floor(d);</code><br/>
|
||||
* <b>not</b>:<br/>
|
||||
* <code>return (int)d; // wrong - rounds toward zero</code>
|
||||
*
|
||||
* <code>return (int)d; // wrong - rounds toward zero</code>
|
||||
*
|
||||
*/
|
||||
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 - <tt>BlankEval</tt> is converted to {@link NumberEval#ZERO}.
|
||||
* @param ev must be a {@link NumberEval}, {@link StringEval}, {@link BoolEval} or
|
||||
* Note - <tt>BlankEval</tt> 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 <tt>parseDouble()</tt> 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.<br/>
|
||||
* Tolerates currency prefixes, commas, leading and trailing spaces.<p/>
|
||||
*
|
||||
* Some examples:<br/>
|
||||
*
|
||||
* Some examples:<br/>
|
||||
* " 123 " -> 123.0<br/>
|
||||
* ".123" -> 0.123<br/>
|
||||
* These not supported yet:<br/>
|
||||
|
@ -233,8 +233,7 @@ public final class OperandResolver {
|
|||
* "$1.25E4" -> 12500.0<br/>
|
||||
* "5**2" -> 500<br/>
|
||||
* "250%" -> 2.5<br/>
|
||||
*
|
||||
* @param pText
|
||||
*
|
||||
* @return <code>null</code> if the specified text cannot be parsed as a number
|
||||
*/
|
||||
public static Double parseDouble(String pText) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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; i<iSize; i++) {
|
||||
Eval arg = args[i];
|
||||
ValueEval arg = args[i];
|
||||
if (arg instanceof AreaEval) {
|
||||
AreaEval ae = (AreaEval) arg;
|
||||
int height = ae.getHeight();
|
||||
|
@ -82,11 +81,8 @@ public abstract class BooleanFunction implements Function {
|
|||
if (arg instanceof RefEval) {
|
||||
ValueEval ve = ((RefEval) arg).getInnerValueEval();
|
||||
tempVe = OperandResolver.coerceValueToBoolean(ve, true);
|
||||
} else if (arg instanceof ValueEval) {
|
||||
ValueEval ve = (ValueEval) arg;
|
||||
tempVe = OperandResolver.coerceValueToBoolean(ve, false);
|
||||
} else {
|
||||
throw new RuntimeException("Unexpected eval (" + arg.getClass().getName() + ")");
|
||||
tempVe = OperandResolver.coerceValueToBoolean(arg, false);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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 Columns implements Function {
|
|||
// too many arguments
|
||||
return ErrorEval.VALUE_INVALID;
|
||||
}
|
||||
Eval firstArg = args[0];
|
||||
ValueEval firstArg = args[0];
|
||||
|
||||
int result;
|
||||
if (firstArg instanceof AreaEval) {
|
||||
|
|
|
@ -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.MissingArgEval;
|
||||
import org.apache.poi.hssf.record.formula.eval.NumberEval;
|
||||
import org.apache.poi.hssf.record.formula.eval.ValueEval;
|
||||
|
@ -60,7 +59,7 @@ public final class Count implements Function {
|
|||
|
||||
private static final I_MatchPredicate predicate = new I_MatchPredicate() {
|
||||
|
||||
public boolean matches(Eval valueEval) {
|
||||
public boolean matches(ValueEval valueEval) {
|
||||
|
||||
if(valueEval instanceof NumberEval) {
|
||||
// only numbers are counted
|
||||
|
|
|
@ -18,7 +18,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.Eval;
|
||||
import org.apache.poi.hssf.record.formula.eval.RefEval;
|
||||
import org.apache.poi.hssf.record.formula.eval.ValueEval;
|
||||
|
||||
|
@ -37,7 +36,7 @@ final class CountUtils {
|
|||
* Common interface for the matching criteria.
|
||||
*/
|
||||
public interface I_MatchPredicate {
|
||||
boolean matches(Eval x);
|
||||
boolean matches(ValueEval x);
|
||||
}
|
||||
/**
|
||||
* @return the number of evaluated cells in the range that match the specified criteria
|
||||
|
@ -66,7 +65,7 @@ final class CountUtils {
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
public static int countArg(Eval eval, I_MatchPredicate criteriaPredicate) {
|
||||
public static int countArg(ValueEval eval, I_MatchPredicate criteriaPredicate) {
|
||||
if (eval == null) {
|
||||
throw new IllegalArgumentException("eval must not be null");
|
||||
}
|
||||
|
|
|
@ -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.NumberEval;
|
||||
import org.apache.poi.hssf.record.formula.eval.ValueEval;
|
||||
import org.apache.poi.hssf.record.formula.functions.CountUtils.I_MatchPredicate;
|
||||
|
@ -58,7 +57,7 @@ public final class Counta implements Function {
|
|||
|
||||
private static final I_MatchPredicate predicate = new I_MatchPredicate() {
|
||||
|
||||
public boolean matches(Eval valueEval) {
|
||||
public boolean matches(ValueEval valueEval) {
|
||||
// Note - observed behavior of Excel:
|
||||
// Error values like #VALUE!, #REF!, #DIV/0!, #NAME? etc don't cause this COUNTA to return an error
|
||||
// in fact, they seem to get counted
|
||||
|
|
|
@ -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.EvaluationException;
|
||||
import org.apache.poi.hssf.record.formula.eval.NumberEval;
|
||||
import org.apache.poi.hssf.record.formula.eval.OperandResolver;
|
||||
|
@ -190,7 +189,7 @@ public final class Countif implements Function {
|
|||
return String.valueOf(_value);
|
||||
}
|
||||
|
||||
public boolean matches(Eval x) {
|
||||
public boolean matches(ValueEval x) {
|
||||
double testValue;
|
||||
if(x instanceof StringEval) {
|
||||
// if the target(x) is a string, but parses as a number
|
||||
|
@ -241,7 +240,7 @@ public final class Countif implements Function {
|
|||
return value ? 1 : 0;
|
||||
}
|
||||
|
||||
public boolean matches(Eval x) {
|
||||
public boolean matches(ValueEval x) {
|
||||
int testValue;
|
||||
if(x instanceof StringEval) {
|
||||
if (true) { // change to false to observe more intuitive behaviour
|
||||
|
@ -278,7 +277,7 @@ public final class Countif implements Function {
|
|||
return ErrorConstants.getText(_value);
|
||||
}
|
||||
|
||||
public boolean matches(Eval x) {
|
||||
public boolean matches(ValueEval x) {
|
||||
if(x instanceof ErrorEval) {
|
||||
int testValue = ((ErrorEval)x).getErrorCode();
|
||||
return evaluate(testValue - _value);
|
||||
|
@ -313,7 +312,7 @@ public final class Countif implements Function {
|
|||
return _pattern.pattern();
|
||||
}
|
||||
|
||||
public boolean matches(Eval x) {
|
||||
public boolean matches(ValueEval x) {
|
||||
if (x instanceof BlankEval) {
|
||||
switch(getCode()) {
|
||||
case CmpOp.NONE:
|
||||
|
@ -423,7 +422,7 @@ public final class Countif implements Function {
|
|||
/**
|
||||
* @return the number of evaluated cells in the range that match the specified criteria
|
||||
*/
|
||||
private double countMatchingCellsInArea(Eval rangeArg, I_MatchPredicate criteriaPredicate) {
|
||||
private double countMatchingCellsInArea(ValueEval rangeArg, I_MatchPredicate criteriaPredicate) {
|
||||
|
||||
if (rangeArg instanceof RefEval) {
|
||||
return CountUtils.countMatchingCell((RefEval) rangeArg, criteriaPredicate);
|
||||
|
@ -438,9 +437,9 @@ public final class Countif implements Function {
|
|||
* Creates a criteria predicate object for the supplied criteria arg
|
||||
* @return <code>null</code> 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) {
|
||||
|
|
|
@ -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.<p/>
|
||||
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<Double> temp) throws EvaluationException {
|
||||
private static void collectValues(ValueEval arg, List<Double> 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<Double> temp, boolean mustBeNumber)
|
||||
private static void collectValue(ValueEval arg, List<Double> temp, boolean mustBeNumber)
|
||||
throws EvaluationException {
|
||||
if (arg instanceof ErrorEval) {
|
||||
throw new EvaluationException((ErrorEval) arg);
|
||||
|
|
|
@ -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 <code>null</code>
|
||||
*/
|
||||
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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<iSize; i++) {
|
||||
|
@ -180,7 +179,7 @@ public abstract class TextFunction implements Function {
|
|||
|
||||
public static final Function EXACT = 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 != 2) {
|
||||
return ErrorEval.VALUE_INVALID;
|
||||
|
|
|
@ -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.MissingArgEval;
|
||||
import org.apache.poi.hssf.record.formula.eval.NumberEval;
|
||||
|
@ -51,12 +50,12 @@ public final class Time implements Function {
|
|||
}
|
||||
return new NumberEval(result);
|
||||
}
|
||||
private static int evalArg(Eval arg) throws EvaluationException {
|
||||
private static int evalArg(ValueEval arg) throws EvaluationException {
|
||||
if (arg == MissingArgEval.instance) {
|
||||
return 0;
|
||||
}
|
||||
// Excel silently truncates double values to integers
|
||||
return OperandResolver.coerceValueToInt((ValueEval) arg);
|
||||
return OperandResolver.coerceValueToInt(arg);
|
||||
}
|
||||
/**
|
||||
* Converts the supplied hours, minutes and seconds to an Excel time value.
|
||||
|
|
|
@ -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 Vlookup 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
|
||||
|
|
|
@ -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;
|
||||
|
@ -167,7 +166,7 @@ public abstract class XYNumericFunction implements Function {
|
|||
return result;
|
||||
}
|
||||
|
||||
private static ValueVector createValueVector(Eval arg) throws EvaluationException {
|
||||
private static ValueVector createValueVector(ValueEval arg) throws EvaluationException {
|
||||
if (arg instanceof ErrorEval) {
|
||||
throw new EvaluationException((ErrorEval) arg);
|
||||
}
|
||||
|
@ -177,9 +176,6 @@ public abstract class XYNumericFunction implements Function {
|
|||
if (arg instanceof RefEval) {
|
||||
return new RefValueArray((RefEval) arg);
|
||||
}
|
||||
if (arg instanceof ValueEval) {
|
||||
return new SingleCellValueArray((ValueEval) arg);
|
||||
}
|
||||
throw new RuntimeException("Unexpected eval class (" + arg.getClass().getName() + ")");
|
||||
return new SingleCellValueArray(arg);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.poi.hssf.record.formula.functions;
|
|||
import junit.framework.AssertionFailedError;
|
||||
|
||||
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.NumericValueEval;
|
||||
import org.apache.poi.hssf.record.formula.eval.OperationEval;
|
||||
import org.apache.poi.hssf.record.formula.eval.ValueEval;
|
||||
|
@ -82,7 +82,7 @@ public final class NumericFunctionInvoker {
|
|||
*/
|
||||
private static double invokeInternal(Object target, ValueEval[] args, int srcCellRow, int srcCellCol)
|
||||
throws NumericEvalEx {
|
||||
Eval evalResult;
|
||||
ValueEval evalResult;
|
||||
// TODO - make OperationEval extend Function
|
||||
try {
|
||||
if (target instanceof Function) {
|
||||
|
|
Loading…
Reference in New Issue