return new NumberEval(term);
}
private double getScalarValue(Eval arg) throws EvalEx {
Eval eval;
if (arg instanceof RefEval) {
RefEval re = (RefEval) arg;
eval = re.getInnerValueEval();
} else {
eval = arg;
}
if (eval == null) {
throw new RuntimeException("parameter may not be null");
}
if (eval instanceof AreaEval) {
AreaEval ae = (AreaEval) eval;
// an area ref can work as a scalar value if it is 1x1
if(!ae.isColumn() || !ae.isRow()) {
throw new EvalEx(ErrorEval.VALUE_INVALID);
}
eval = ae.getValues()[0];
}
if (!(eval instanceof ValueEval)) {
throw new RuntimeException("Unexpected value eval class ("
+ eval.getClass().getName() + ")");
}
return getProductTerm((ValueEval) eval, true);
}