public class JRCalculator extends Object implements JRFillExpressionEvaluator
The expressions calculator is the entity inside JasperReports that evaluates
expressions and increments variables or datasets at report-filling time. When a report
template is compiled, the report compiler produces and stores in the compiled report
template (JasperReport
object) information that it
will use at report-filling time to build an instance of the
JRCalculator
class.
The Java-based report compilers generate a Java source file and compile it on the fly.
This generated class is a subclass of the JRCalculator
,
and the bytecode produced by compiling it is stored inside the
JasperReport
object. At report-filling time, this
bytecode is loaded and the resulting class is instantiated to obtain the calculator object
needed for expression evaluation.
Only the report compiler creates the calculator instance because only the report compiler can make sense of the information it stored in the compiled report template at report compilation time.
Modifier and Type | Field and Description |
---|---|
protected JRFillDataset |
dataset |
protected JRFillElementDataset[] |
datasets |
protected Map<String,JRFillField> |
fldsm |
protected JRFillGroup[] |
groups |
protected Map<String,JRFillParameter> |
parsm |
protected JRFillVariable[] |
variables |
protected Map<String,JRFillVariable> |
varsm |
Modifier | Constructor and Description |
---|---|
protected |
JRCalculator(DatasetExpressionEvaluator evaluator)
Creates a calculator using an expression evaluator.
|
protected |
JRCalculator(JREvaluator evaluator)
Creates a calculator using an expression evaluator.
|
Modifier and Type | Method and Description |
---|---|
void |
calculateVariables() |
void |
estimateGroupRuptures()
Determines group breaks based on estimated report values.
|
void |
estimateVariables() |
Object |
evaluate(JRExpression expression) |
Object |
evaluate(JRExpression expression,
byte evaluationType)
Evaluates an expression.
|
Object |
evaluateEstimated(JRExpression expression) |
Object |
evaluateOld(JRExpression expression) |
JRFillVariable |
getColumnNumber() |
JRFillDataset |
getFillDataset()
Returns the dataset used by the expression evaluator.
|
JRFillVariable |
getPageNumber() |
protected void |
init(JRFillDataset dataset)
Initializes the calculator.
|
void |
initializeVariables(ResetTypeEnum resetType,
IncrementTypeEnum incrementType) |
protected JRFillDataset dataset
protected Map<String,JRFillParameter> parsm
protected Map<String,JRFillField> fldsm
protected Map<String,JRFillVariable> varsm
protected JRFillVariable[] variables
protected JRFillGroup[] groups
protected JRFillElementDataset[] datasets
protected JRCalculator(DatasetExpressionEvaluator evaluator)
evaluator
- the expression evaluatorprotected JRCalculator(JREvaluator evaluator)
evaluator
- the expression evaluatorprotected void init(JRFillDataset dataset) throws JRException
dataset
- the dataset this calculator is used forJRException
public JRFillVariable getPageNumber()
public JRFillVariable getColumnNumber()
public void calculateVariables() throws JRException
JRException
public void estimateVariables() throws JRException
JRException
public void estimateGroupRuptures() throws JRException
estimateVariables()
needs to be called prior to this method.
JRException
public void initializeVariables(ResetTypeEnum resetType, IncrementTypeEnum incrementType) throws JRException
JRException
public Object evaluate(JRExpression expression, byte evaluationType) throws JRException
JRFillExpressionEvaluator
evaluate
in interface JRFillExpressionEvaluator
expression
- the expression to evaluateevaluationType
- one of JRExpression.EVALUATION_DEFAULT
,
JRExpression.EVALUATION_OLD
, JRExpression.EVALUATION_ESTIMATED
JRException
public Object evaluateOld(JRExpression expression) throws JRExpressionEvalException
JRExpressionEvalException
public Object evaluateEstimated(JRExpression expression) throws JRExpressionEvalException
JRExpressionEvalException
public Object evaluate(JRExpression expression) throws JRExpressionEvalException
JRExpressionEvalException
public JRFillDataset getFillDataset()
JRFillExpressionEvaluator
getFillDataset
in interface JRFillExpressionEvaluator
Copyright © 2016. All rights reserved.