Class JRCalculator
- All Implemented Interfaces:
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.
- Author:
- Teodor Danciu (teodord@users.sourceforge.net)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JRFillDatasetprotected JRFillElementDataset[]protected Map<String, JRFillField> protected JRFillGroup[]protected Map<String, JRFillGroup> protected Map<String, JRFillParameter> protected JRFillVariable[]protected Map<String, JRFillVariable> -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJRCalculator(DatasetExpressionEvaluator evaluator) Creates a calculator using an expression evaluator.protectedJRCalculator(JREvaluator evaluator) Creates a calculator using an expression evaluator. -
Method Summary
Modifier and TypeMethodDescriptionvoidcalculateVariables(boolean incrementDatasets) voidDetermines group breaks based on estimated report values.voidevaluate(JRExpression expression) evaluate(JRExpression expression, byte evaluationType) Evaluates an expression.evaluateEstimated(JRExpression expression) evaluateOld(JRExpression expression) Returns the dataset used by the expression evaluator.protected voidinit(JRFillDataset dataset) Initializes the calculator.voidinitializeVariables(ResetTypeEnum resetType, IncrementTypeEnum incrementType) protected void
-
Field Details
-
dataset
-
parsm
-
fldsm
-
varsm
-
grpsm
-
variables
-
groups
-
datasets
-
-
Constructor Details
-
JRCalculator
Creates a calculator using an expression evaluator.- Parameters:
evaluator- the expression evaluator
-
JRCalculator
Creates a calculator using an expression evaluator.- Parameters:
evaluator- the expression evaluator
-
-
Method Details
-
init
Initializes the calculator.- Parameters:
dataset- the dataset this calculator is used for- Throws:
JRException
-
getPageNumber
-
getColumnNumber
-
calculateVariables
- Throws:
JRException
-
recalculateVariables
- Throws:
JRException
-
estimateVariables
- Throws:
JRException
-
estimateGroupRuptures
Determines group breaks based on estimated report values.estimateVariables()needs to be called prior to this method.- Throws:
JRException
-
initializeVariables
public void initializeVariables(ResetTypeEnum resetType, IncrementTypeEnum incrementType) throws JRException - Throws:
JRException
-
evaluate
Description copied from interface:JRFillExpressionEvaluatorEvaluates an expression.- Specified by:
evaluatein interfaceJRFillExpressionEvaluator- Parameters:
expression- the expression to evaluateevaluationType- one ofJRExpression.EVALUATION_DEFAULT,JRExpression.EVALUATION_OLD,JRExpression.EVALUATION_ESTIMATED- Returns:
- the result
- Throws:
JRException
-
evaluateOld
- Throws:
JRExpressionEvalException
-
evaluateEstimated
- Throws:
JRExpressionEvalException
-
evaluate
- Throws:
JRExpressionEvalException
-
getFillDataset
Description copied from interface:JRFillExpressionEvaluatorReturns the dataset used by the expression evaluator.- Specified by:
getFillDatasetin interfaceJRFillExpressionEvaluator
-