renamed function implementations to avoid potential name clashes
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@893030 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
7bd00361c3
commit
7033e79c35
@ -55,14 +55,14 @@ public final class FunctionEval {
|
||||
Function[] retval = new Function[368];
|
||||
|
||||
retval[0] = new Count();
|
||||
retval[ID.IF] = new If();
|
||||
retval[ID.IF] = new IfFunc();
|
||||
retval[2] = LogicalFunction.ISNA;
|
||||
retval[3] = LogicalFunction.ISERROR;
|
||||
retval[ID.SUM] = AggregateFunction.SUM;
|
||||
retval[5] = AggregateFunction.AVERAGE;
|
||||
retval[6] = AggregateFunction.MIN;
|
||||
retval[7] = AggregateFunction.MAX;
|
||||
retval[8] = new Row(); // ROW
|
||||
retval[8] = new RowFunc(); // ROW
|
||||
retval[9] = new Column();
|
||||
retval[10] = new Na();
|
||||
retval[11] = new Npv();
|
||||
@ -103,7 +103,7 @@ public final class FunctionEval {
|
||||
retval[63] = NumericFunction.RAND;
|
||||
retval[64] = new Match();
|
||||
retval[65] = DateFunc.instance;
|
||||
retval[66] = new Time();
|
||||
retval[66] = new TimeFunc();
|
||||
retval[67] = CalendarFieldFunction.DAY;
|
||||
retval[68] = CalendarFieldFunction.MONTH;
|
||||
retval[69] = CalendarFieldFunction.YEAR;
|
||||
|
@ -28,6 +28,8 @@ import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||
|
||||
|
||||
/**
|
||||
* Implementation for the Excel function DATE
|
||||
*
|
||||
* @author Pavel Krupets (pkrupets at palmtreebusiness dot com)
|
||||
*/
|
||||
public final class DateFunc extends Fixed3ArgFunction {
|
||||
@ -52,16 +54,17 @@ public final class DateFunc extends Fixed3ArgFunction {
|
||||
return new NumberEval(result);
|
||||
}
|
||||
|
||||
private static double evaluate(int year, int month, int day) throws EvaluationException {
|
||||
private static double evaluate(int year, int month, int pDay) throws EvaluationException {
|
||||
|
||||
if (year < 0 || month < 0 || day < 0) {
|
||||
if (year < 0 || month < 0 || pDay < 0) {
|
||||
throw new EvaluationException(ErrorEval.VALUE_INVALID);
|
||||
}
|
||||
|
||||
if (year == 1900 && month == Calendar.FEBRUARY && day == 29) {
|
||||
if (year == 1900 && month == Calendar.FEBRUARY && pDay == 29) {
|
||||
return 60.0;
|
||||
}
|
||||
|
||||
int day = pDay;
|
||||
if (year == 1900) {
|
||||
if ((month == Calendar.JANUARY && day >= 60) ||
|
||||
(month == Calendar.FEBRUARY && day >= 30)) {
|
||||
|
@ -25,9 +25,11 @@ import org.apache.poi.hssf.record.formula.eval.OperandResolver;
|
||||
import org.apache.poi.hssf.record.formula.eval.ValueEval;
|
||||
|
||||
/**
|
||||
* Implementation for the Excel function IF
|
||||
*
|
||||
* @author Amol S. Deshmukh < amolweb at ya hoo dot com >
|
||||
*/
|
||||
public final class If extends Var2or3ArgFunction {
|
||||
public final class IfFunc extends Var2or3ArgFunction {
|
||||
|
||||
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) {
|
||||
boolean b;
|
@ -23,7 +23,12 @@ import org.apache.poi.hssf.record.formula.eval.NumberEval;
|
||||
import org.apache.poi.hssf.record.formula.eval.RefEval;
|
||||
import org.apache.poi.hssf.record.formula.eval.ValueEval;
|
||||
|
||||
public final class Row implements Function0Arg, Function1Arg {
|
||||
/**
|
||||
* Implementation for the Excel function ROW
|
||||
*
|
||||
* @author Josh Micich
|
||||
*/
|
||||
public final class RowFunc implements Function0Arg, Function1Arg {
|
||||
|
||||
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex) {
|
||||
return new NumberEval(srcRowIndex+1);
|
||||
@ -51,5 +56,4 @@ public final class Row implements Function0Arg, Function1Arg {
|
||||
}
|
||||
return ErrorEval.VALUE_INVALID;
|
||||
}
|
||||
|
||||
}
|
@ -25,11 +25,13 @@ import org.apache.poi.hssf.record.formula.eval.OperandResolver;
|
||||
import org.apache.poi.hssf.record.formula.eval.ValueEval;
|
||||
|
||||
/**
|
||||
* Implementation for the Excel function TIME
|
||||
*
|
||||
* @author Steven Butler (sebutler @ gmail dot com)
|
||||
*
|
||||
* Based on POI org.apache.hssf.record.formula.DateFunc.java
|
||||
* Based on POI {@link DateFunc}
|
||||
*/
|
||||
public final class Time extends Fixed3ArgFunction {
|
||||
public final class TimeFunc extends Fixed3ArgFunction {
|
||||
|
||||
private static final int SECONDS_PER_MINUTE = 60;
|
||||
private static final int SECONDS_PER_HOUR = 3600;
|
@ -63,7 +63,7 @@ import org.apache.poi.hssf.record.formula.eval.StringEval;
|
||||
import org.apache.poi.hssf.record.formula.eval.ValueEval;
|
||||
import org.apache.poi.hssf.record.formula.functions.Choose;
|
||||
import org.apache.poi.hssf.record.formula.functions.FreeRefFunction;
|
||||
import org.apache.poi.hssf.record.formula.functions.If;
|
||||
import org.apache.poi.hssf.record.formula.functions.IfFunc;
|
||||
import org.apache.poi.hssf.record.formula.udf.UDFFinder;
|
||||
import org.apache.poi.hssf.util.CellReference;
|
||||
import org.apache.poi.ss.formula.CollaboratingWorkbooksEnvironment.WorkbookNotFoundException;
|
||||
@ -373,7 +373,7 @@ public final class WorkbookEvaluator {
|
||||
ValueEval arg0 = stack.pop();
|
||||
boolean evaluatedPredicate;
|
||||
try {
|
||||
evaluatedPredicate = If.evaluateFirstArg(arg0, ec.getRowIndex(), ec.getColumnIndex());
|
||||
evaluatedPredicate = IfFunc.evaluateFirstArg(arg0, ec.getRowIndex(), ec.getColumnIndex());
|
||||
} catch (EvaluationException e) {
|
||||
stack.push(e.getErrorEval());
|
||||
int dist = attrPtg.getData();
|
||||
|
@ -43,7 +43,7 @@ public final class TestRowCol extends TestCase {
|
||||
}
|
||||
|
||||
public void testRow() {
|
||||
Function target = new Row();
|
||||
Function target = new RowFunc();
|
||||
{
|
||||
ValueEval[] args = { EvalFactory.createRefEval("C5"), };
|
||||
double actual = NumericFunctionInvoker.invoke(target, args);
|
||||
|
@ -30,7 +30,7 @@ import org.apache.poi.hssf.usermodel.HSSFSheet;
|
||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||
|
||||
/**
|
||||
* Tests for {@link Time}
|
||||
* Tests for {@link TimeFunc}
|
||||
*
|
||||
* @author @author Steven Butler (sebutler @ gmail dot com)
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user