public abstract class JREvaluator extends java.lang.Object implements DatasetExpressionEvaluator
this
reference. This is the calculator
object. It has public utility methods that are ready to use inside report expressions.
Currently, there are only a few utility methods of the calculator object available as built-in functions inside report expressions. These are the following:
msg
- this function offers a convenient way to format messages based on the current
report locale, just as you would normally do when using a
java.text.MessageFormat
instance. Furthermore, several signatures for this
function take up to three message parameters in order to make the formatting
functionality easier to use.str
- this function is the equivalent of the $R{}
syntax. It gives access
to locale specific resources from the associated resource bundle.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
EXCEPTION_MESSAGE_KEY_RESOURCE_NOT_FOUND |
static java.lang.String |
PROPERTY_IGNORE_NPE
The expression evaluation engine in JasperReports has always ignored java.lang.NullPointerException
exceptions raised during expression evaluation.
|
Modifier | Constructor and Description |
---|---|
protected |
JREvaluator()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
customizedInit(java.util.Map<java.lang.String,JRFillParameter> parametersMap,
java.util.Map<java.lang.String,JRFillField> fieldsMap,
java.util.Map<java.lang.String,JRFillVariable> variablesMap)
Initializes the parameters, fields and variables of the evaluator.
|
protected abstract java.lang.Object |
evaluate(int id)
Evaluates an expression using current fields and variables values.
|
java.lang.Object |
evaluate(JRExpression expression) |
protected abstract java.lang.Object |
evaluateEstimated(int id)
Evaluates an expression using estimated variables values.
|
java.lang.Object |
evaluateEstimated(JRExpression expression) |
protected abstract java.lang.Object |
evaluateOld(int id)
Evaluates an expression using old fields and variables values.
|
java.lang.Object |
evaluateOld(JRExpression expression) |
<T extends FunctionSupport> |
getFunctionSupport(java.lang.Class<T> clazz) |
protected java.lang.String |
handleMissingResource(java.lang.String key,
java.lang.Exception e)
Handles the case when a resource is missing.
|
void |
init(java.util.Map<java.lang.String,JRFillParameter> parametersMap,
java.util.Map<java.lang.String,JRFillField> fieldsMap,
java.util.Map<java.lang.String,JRFillVariable> variablesMap,
WhenResourceMissingTypeEnum resourceMissingType,
boolean ignoreNPE)
Initializes the evaluator by setting the parameter, field and variable objects.
|
java.lang.String |
msg(java.lang.String pattern,
java.lang.Object arg0)
Constructs a message using a pattern with one parameter.
|
java.lang.String |
msg(java.lang.String pattern,
java.lang.Object[] args)
Constructs a message using a pattern with an Object array parameter.
|
java.lang.String |
msg(java.lang.String pattern,
java.lang.Object arg0,
java.lang.Object arg1)
Constructs a message using a pattern with two parameters.
|
java.lang.String |
msg(java.lang.String pattern,
java.lang.Object arg0,
java.lang.Object arg1,
java.lang.Object arg2)
Constructs a message using a pattern with three parameters.
|
java.lang.String |
str(java.lang.String key)
Returns a string for a given key from the resource bundle associated with the evaluator.
|
public static final java.lang.String PROPERTY_IGNORE_NPE
public static final java.lang.String EXCEPTION_MESSAGE_KEY_RESOURCE_NOT_FOUND
public void init(java.util.Map<java.lang.String,JRFillParameter> parametersMap, java.util.Map<java.lang.String,JRFillField> fieldsMap, java.util.Map<java.lang.String,JRFillVariable> variablesMap, WhenResourceMissingTypeEnum resourceMissingType, boolean ignoreNPE) throws JRException
init
in interface DatasetExpressionEvaluator
parametersMap
- the parameters indexed by namefieldsMap
- the fields indexed by namevariablesMap
- the variables indexed by nameresourceMissingType
- the resource missing typeJRException
public <T extends FunctionSupport> T getFunctionSupport(java.lang.Class<T> clazz)
public java.lang.String msg(java.lang.String pattern, java.lang.Object arg0)
pattern
- the message patternarg0
- the message parameterMessageFormat.format(java.lang.Object[],java.lang.StringBuffer, java.text.FieldPosition)
public java.lang.String msg(java.lang.String pattern, java.lang.Object arg0, java.lang.Object arg1)
pattern
- the message patternarg0
- the first message parameterarg1
- the second message parameterMessageFormat.format(java.lang.Object[],java.lang.StringBuffer, java.text.FieldPosition)
public java.lang.String msg(java.lang.String pattern, java.lang.Object arg0, java.lang.Object arg1, java.lang.Object arg2)
pattern
- the message patternarg0
- the first message parameterarg1
- the second message parameterarg2
- the third parameterMessageFormat.format(java.lang.Object[],java.lang.StringBuffer, java.text.FieldPosition)
public java.lang.String msg(java.lang.String pattern, java.lang.Object[] args)
pattern
- the message patternargs
- the parameter Object arrayMessageFormat.format(java.lang.Object[],java.lang.StringBuffer, java.text.FieldPosition)
public java.lang.String str(java.lang.String key)
key
- the keyResourceBundle.getString(java.lang.String)
public java.lang.Object evaluate(JRExpression expression) throws JRExpressionEvalException
evaluate
in interface DatasetExpressionEvaluator
JRExpressionEvalException
public java.lang.Object evaluateOld(JRExpression expression) throws JRExpressionEvalException
evaluateOld
in interface DatasetExpressionEvaluator
JRExpressionEvalException
public java.lang.Object evaluateEstimated(JRExpression expression) throws JRExpressionEvalException
evaluateEstimated
in interface DatasetExpressionEvaluator
JRExpressionEvalException
protected java.lang.String handleMissingResource(java.lang.String key, java.lang.Exception e) throws JRRuntimeException
key
- the resource keye
- the exceptionJRRuntimeException
- when the resource missing handling type is Errorprotected abstract void customizedInit(java.util.Map<java.lang.String,JRFillParameter> parametersMap, java.util.Map<java.lang.String,JRFillField> fieldsMap, java.util.Map<java.lang.String,JRFillVariable> variablesMap) throws JRException
parametersMap
- the parameters indexed by namefieldsMap
- the fields indexed by namevariablesMap
- the variables indexed by nameJRException
protected abstract java.lang.Object evaluate(int id) throws java.lang.Throwable
id
- the expression idjava.lang.Throwable
JRExpression.EVALUATION_DEFAULT
,
JRFillVariable.getValue()
,
JRFillField.getValue()
protected abstract java.lang.Object evaluateOld(int id) throws java.lang.Throwable
id
- the expression idjava.lang.Throwable
JRExpression.EVALUATION_OLD
,
JRFillVariable.getOldValue()
,
JRFillField.getOldValue()
protected abstract java.lang.Object evaluateEstimated(int id) throws java.lang.Throwable
id
- the expression idjava.lang.Throwable
JRExpression.EVALUATION_ESTIMATED
,
JRFillVariable.getEstimatedValue()
© 2001-2014 TIBCO Software Inc. www.jaspersoft.com