| jimm.datavision.Expression jimm.datavision.Formula
Formula | public class Formula extends Expression (Code) | | A formula is a Bean Scripting Framework (BSF) script evaluated at runtime.
It may contain database column values, other formulas, special values, and
aggregates.
Before being evaluated, the following substitutions are made withing
the evaluation string of a formula:
- {table_name.column_name} is replaced by the current value
of the column table_name.column_name, but only if the column exists.
If it doesn't, then the entire "{...}" text is kept as-is.
- {@id_number} is replaced by the results of evaluating the
formula whose id is id_number.
- {%special_value_name} is replaced by a special value
(report title, report run date, page number, or record number).
- {?id_number} is replaced by a parameter value (string,
number, or date).
- {!id_number} is replaced by a user column's value (string,
number, or date).
|
shouldEvaluate | protected boolean shouldEvaluate(Code) | | |
showException | protected boolean showException(Code) | | |
useCache | protected boolean useCache(Code) | | |
Formula | public Formula(Long id, Report report, String name)(Code) | | Constructor.
Parameters: id - the unique identifier for the new formula; if null ,generate a new id Parameters: report - the report containing this formula Parameters: name - the formula name |
Formula | public Formula(Long id, Report report, String name, String evalString)(Code) | | Constructor. If id is null , generates a new id number.
This number is one higher than any previously-seen id number. This does
not guarantee that no later formula will be created manually with
the same id number.
Parameters: id - the unique identifier for the new formula; if null ,generate a new id Parameters: report - the report containing this formula Parameters: name - the formula name Parameters: evalString - the string to evaulate at runtime. |
eval | public Object eval()(Code) | | Evaluate this formula and return the result as either a
String or a Double . Before evaluation, special
fields, formulas, and column references are subtituted with their
values.
After substitution, if the formula contains a null anywhere
then null is returned.
the result of evaluating the formula as either aString or a Double ; possibly null |
eval | public Object eval(Field formulaField)(Code) | | Evaluate this formula and return the result. Before evaluation, special
fields, formulas, and column references are subtituted with their
values. null values are replaced by "nil".
After substitution, if the formula contains a null anywhere
then null is returned. If the BSF script throws an exception,
then null is returned.
During substitution, we take care not to replace "#{...}" Ruby string
substition operators.
The formulaField is used when the formula contains a
"group.count" special field.
Parameters: formulaField - the field containing this formula; may benull the result of evaluating the formula as a BSF script; possiblynull |
evaluate | protected Object evaluate(Field formulaField)(Code) | | Modifies the formula text so it is ready to evaluate, then gives it to the
report to evaluate and returns the result.
Formula.eval calls this method
and stores the return value into cachedEvalResult.
Parameters: formulaField - the field that is using this formula, used toevaluate any special fields in the formula; may be null the result of evaluating the formula as a BSF script; possiblynull See Also: SpecialField.value |
getLanguage | public String getLanguage()(Code) | | Returns the scripting language this formula uses.
the language to use when evaluating this formula |
quoted | protected String quoted(Object obj)(Code) | | Returns a string representation of an object enclosed in double quotes.
Each double quote and backslash within the object's string
representation is escaped with a backslash character.
Parameters: obj - any object a double-quoted string representation of the object |
setExpression | public void setExpression(String newExpression)(Code) | | |
shouldEvaluate | public void shouldEvaluate()(Code) | | Tells this formula to evaluate the BSF script the next time
eval is called.
|
unquoted | public Object unquoted(Object obj)(Code) | | If obj is a String and it is surrounded by
double quotes, return an unquoted copy. All doubled double quotes
are turned into single double quotes.
Parameters: obj - any object obj if it is not a String , an unquotedcopy if it is a String |
useCache | public void useCache()(Code) | | Tells this formula to evaluate only when shouldEvaluate is
true and to return the cached value otherwise.
|
writeAdditionalAttributes | protected void writeAdditionalAttributes(XMLWriter out)(Code) | | |
|
|