Class JRCalculator
- java.lang.Object
-
- net.sf.jasperreports.engine.fill.JRCalculator
-
- All Implemented Interfaces:
JRFillExpressionEvaluator
public class JRCalculator extends java.lang.Object implements JRFillExpressionEvaluator
Evaluates JasperReports expressions.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 (
JasperReportobject) information that it will use at report-filling time to build an instance of theJRCalculatorclass.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 theJasperReportobject. 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
Fields Modifier and Type Field Description protected JRFillDatasetdatasetprotected JRFillElementDataset[]datasetsprotected java.util.Map<java.lang.String,JRFillField>fldsmprotected JRFillGroup[]groupsprotected java.util.Map<java.lang.String,JRFillParameter>parsmstatic java.lang.StringPROPERTY_LEGACY_BAND_EVALUATION_ENABLEDprotected JRFillVariable[]variablesprotected java.util.Map<java.lang.String,JRFillVariable>varsm
-
Constructor Summary
Constructors Modifier Constructor Description protectedJRCalculator(DatasetExpressionEvaluator evaluator)Creates a calculator using an expression evaluator.protectedJRCalculator(JREvaluator evaluator)Creates a calculator using an expression evaluator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcalculateVariables(boolean incrementDatasets)voidestimateGroupRuptures()Determines group breaks based on estimated report values.voidestimateVariables()java.lang.Objectevaluate(JRExpression expression)java.lang.Objectevaluate(JRExpression expression, byte evaluationType)Evaluates an expression.java.lang.ObjectevaluateEstimated(JRExpression expression)java.lang.ObjectevaluateOld(JRExpression expression)JRFillVariablegetColumnNumber()JRFillDatasetgetFillDataset()Returns the dataset used by the expression evaluator.JRFillVariablegetPageNumber()protected voidinit(JRFillDataset dataset)Initializes the calculator.voidinitializeVariables(ResetTypeEnum resetType, IncrementTypeEnum incrementType)protected voidrecalculateVariables()
-
-
-
Field Detail
-
PROPERTY_LEGACY_BAND_EVALUATION_ENABLED
public static final java.lang.String PROPERTY_LEGACY_BAND_EVALUATION_ENABLED
- See Also:
- Constant Field Values
-
dataset
protected JRFillDataset dataset
-
parsm
protected java.util.Map<java.lang.String,JRFillParameter> parsm
-
fldsm
protected java.util.Map<java.lang.String,JRFillField> fldsm
-
varsm
protected java.util.Map<java.lang.String,JRFillVariable> varsm
-
variables
protected JRFillVariable[] variables
-
groups
protected JRFillGroup[] groups
-
datasets
protected JRFillElementDataset[] datasets
-
-
Constructor Detail
-
JRCalculator
protected JRCalculator(DatasetExpressionEvaluator evaluator)
Creates a calculator using an expression evaluator.- Parameters:
evaluator- the expression evaluator
-
JRCalculator
protected JRCalculator(JREvaluator evaluator)
Creates a calculator using an expression evaluator.- Parameters:
evaluator- the expression evaluator
-
-
Method Detail
-
init
protected void init(JRFillDataset dataset) throws JRException
Initializes the calculator.- Parameters:
dataset- the dataset this calculator is used for- Throws:
JRException
-
getPageNumber
public JRFillVariable getPageNumber()
-
getColumnNumber
public JRFillVariable getColumnNumber()
-
calculateVariables
public void calculateVariables(boolean incrementDatasets) throws JRException- Throws:
JRException
-
recalculateVariables
protected void recalculateVariables() throws JRException- Throws:
JRException
-
estimateVariables
public void estimateVariables() throws JRException- Throws:
JRException
-
estimateGroupRuptures
public void estimateGroupRuptures() throws JRExceptionDetermines 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
public java.lang.Object evaluate(JRExpression expression, byte evaluationType) throws JRException
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
public java.lang.Object evaluateOld(JRExpression expression) throws JRExpressionEvalException
- Throws:
JRExpressionEvalException
-
evaluateEstimated
public java.lang.Object evaluateEstimated(JRExpression expression) throws JRExpressionEvalException
- Throws:
JRExpressionEvalException
-
evaluate
public java.lang.Object evaluate(JRExpression expression) throws JRExpressionEvalException
- Throws:
JRExpressionEvalException
-
getFillDataset
public JRFillDataset getFillDataset()
Description copied from interface:JRFillExpressionEvaluatorReturns the dataset used by the expression evaluator.- Specified by:
getFillDatasetin interfaceJRFillExpressionEvaluator
-
-