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
|
||||
}
|
|
@ -40,9 +40,9 @@ public final class OperandResolver {
|
|||
* 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) {
|
||||
|
@ -234,7 +234,6 @@ public final class OperandResolver {
|
|||
* "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