/** * Retrieves a single value from a variety of different argument types according to standard * Excel rules. Does not perform any type conversion. * @param arg the evaluated argument as passed to the function or operator. * @param srcCellRow used when arg is a single column AreaRef * @param srcCellCol used when arg is a single row AreaRef * @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 * EvaluationException is thrown. */ public static ValueEval getSingleValue(ValueEval arg, int srcCellRow, int srcCellCol) throws EvaluationException { final ValueEval result; if (arg instanceof RefEval) { result = chooseSingleElementFromRef((RefEval) arg); } else if (arg instanceof AreaEval) { result = chooseSingleElementFromArea((AreaEval) arg, srcCellRow, srcCellCol); } else { result = arg; } if (result instanceof ErrorEval) { throw new EvaluationException((ErrorEval) result); } return result; }
/** * Retrieves a single value from a variety of different argument types according to standard * Excel rules. Does not perform any type conversion. * @param arg the evaluated argument as passed to the function or operator. * @param srcCellRow used when arg is a single column AreaRef * @param srcCellCol used when arg is a single row AreaRef * @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 * EvaluationException is thrown. */ public static ValueEval getSingleValue(ValueEval arg, int srcCellRow, int srcCellCol) throws EvaluationException { final ValueEval result; if (arg instanceof RefEval) { result = chooseSingleElementFromRef((RefEval) arg); } else if (arg instanceof AreaEval) { result = chooseSingleElementFromArea((AreaEval) arg, srcCellRow, srcCellCol); } else { result = arg; } if (result instanceof ErrorEval) { throw new EvaluationException((ErrorEval) result); } return result; }