/**
* Formats nicer error messages for the junit output
*/
private static double invokeInternal(Object target, Eval[] args, int srcCellRow, int srcCellCol)
throws NumericEvalEx {
Eval evalResult;
// TODO - make OperationEval extend Function
try {
if (target instanceof Function) {
Function ff = (Function) target;
evalResult = ff.evaluate(args, srcCellRow, (short)srcCellCol);
} else {
OperationEval ff = (OperationEval) target;
evalResult = ff.evaluate(args, srcCellRow, (short)srcCellCol);
}
} catch (NotImplementedException e) {
throw new NumericEvalEx("Not implemented:" + e.getMessage());
}
if(evalResult == null) {
throw new NumericEvalEx("Result object was null");
}
if(evalResult instanceof ErrorEval) {
ErrorEval ee = (ErrorEval) evalResult;
throw new NumericEvalEx(formatErrorMessage(ee));
}
if(!(evalResult instanceof NumericValueEval)) {
throw new NumericEvalEx("Result object type (" + evalResult.getClass().getName()
+ ") is invalid. Expected implementor of ("
+ NumericValueEval.class.getName() + ")");
}
NumericValueEval result = (NumericValueEval) evalResult;