|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.poi.hssf.record.formula.eval.OperandResolver
public final class OperandResolver
Provides functionality for evaluating arguments to functions and operators.
| Method Summary | |
|---|---|
static ValueEval |
chooseSingleElementFromArea(AreaEval ae,
int srcCellRow,
short srcCellCol)
Implements (some perhaps not well known) Excel functionality to select a single cell from an area depending on the coordinates of the calling cell. |
static double |
coerceValueToDouble(ValueEval ev)
Applies some conversion rules if the supplied value is not already a number. |
static int |
coerceValueToInt(ValueEval ev)
Applies some conversion rules if the supplied value is not already an integer. Value is first coerced to a double ( See coerceValueToDouble() ). Excel typically converts doubles to integers by truncating toward negative infinity. The equivalent java code is: return (int)Math.floor(d);not: return (int)d; // wrong - rounds toward zero |
static java.lang.String |
coerceValueToString(ValueEval ve)
|
static ValueEval |
getSingleValue(Eval arg,
int srcCellRow,
short srcCellCol)
Retrieves a single value from a variety of different argument types according to standard Excel rules. |
static java.lang.Double |
parseDouble(java.lang.String pText)
Converts a string to a double using standard rules that Excel would use. Tolerates currency prefixes, commas, leading and trailing spaces. Some examples: " 123 " -> 123.0 ".123" -> 0.123 These not supported yet: " $ 1,000.00 " -> 1000.0 "$1.25E4" -> 12500.0 "5**2" -> 500 "250%" -> 2.5 |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static ValueEval getSingleValue(Eval arg,
int srcCellRow,
short srcCellCol)
throws EvaluationException
arg - the evaluated argument as passed to the function or operator.srcCellRow - used when arg is a single column AreaRefsrcCellCol - used when arg is a single row AreaRef
null or ErrorEval.
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.
EvaluationException
public static ValueEval chooseSingleElementFromArea(AreaEval ae,
int srcCellRow,
short srcCellCol)
throws EvaluationException
| A | B | C | D | |
|---|---|---|---|---|
| 1 | 15 | 20 | 25 | |
| 2 | 200 | |||
| 3 | 300 | |||
| 3 | 400 |
| A | B | C | D | |
|---|---|---|---|---|
| 1 | 15 | 20 | 25 | |
| 2 | 1215 | 1220 | #VALUE! | 200 |
| 3 | 1315 | 1320 | #VALUE! | 300 |
| 4 | #VALUE! | #VALUE! | #VALUE! | 400 |
null. Never
ErrorEval.
EvaluationException - if there is a problem with indexing into the area, or if the
evaluated cell has an error.
public static int coerceValueToInt(ValueEval ev)
throws EvaluationException
return (int)Math.floor(d);return (int)d; // wrong - rounds toward zero
EvaluationException
public static double coerceValueToDouble(ValueEval ev)
throws EvaluationException
ev - must be a NumberEval, StringEval or BoolEval
EvaluationException(#VALUE!) - only if a StringEval is supplied and cannot be parsed
as a double (See parseDouble() for allowable formats).
java.lang.RuntimeException - if the supplied parameter is not NumberEval,
StringEval or BoolEval
EvaluationExceptionpublic static java.lang.Double parseDouble(java.lang.String pText)
text -
null if the specified text cannot be parsed as a numberpublic static java.lang.String coerceValueToString(ValueEval ve)
ve - must be a NumberEval, StringEval, BoolEval, or BlankEval
null
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||