Package net.sf.jasperreports.engine
Class JRExpressionCollector
- java.lang.Object
-
- net.sf.jasperreports.engine.JRExpressionCollector
-
public class JRExpressionCollector extends Object
An expression collector traverses a report and collects report expressions out of it.The expressions are then included into evaluator classes which are compiled and used at report fill time to evaluate expressions.
- Author:
- Teodor Danciu (teodord@users.sourceforge.net)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
JRExpressionCollector.CrosstabExpressionVerifier
protected static class
JRExpressionCollector.DatasetExpressionVerifier
protected static interface
JRExpressionCollector.ExpressionVerifier
protected static class
JRExpressionCollector.GeneratedIds
-
Field Summary
Fields Modifier and Type Field Description static String
EXCEPTION_MESSAGE_KEY_EXPRESSION_NOT_FOUND
static String
EXCEPTION_MESSAGE_KEY_TWO_GENERATED_IDS
-
Constructor Summary
Constructors Modifier Constructor Description protected
JRExpressionCollector(JasperReportsContext jasperReportsContext, JRExpressionCollector parent, JRReport report)
protected
JRExpressionCollector(JasperReportsContext jasperReportsContext, JRExpressionCollector parent, JRReport report, JRExpressionCollector.ExpressionVerifier expressionVerifier)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addExpression(JRExpression expression)
Collects an expression.protected boolean
canUseId(List<JRExpressionCollector> collectors, JRExpression expression, Integer id)
protected boolean
canUseId(JRExpression expression, Integer id)
Collection<JRExpression>
collect()
protected void
collect(JRCellContents cell)
void
collect(JRCrosstab crosstab)
Collects expressions from a crosstab.protected void
collect(DataAxisLevel level, JRExpressionCollector datasetCollector)
void
collect(MultiAxisData data)
void
collect(JRBreak breakElement)
void
collect(JRComponentElement componentElement)
Collects expressions from a component element wrapper.Collection<JRExpression>
collect(JRDataset dataset)
Collects expressions from a dataset.void
collect(JRDatasetRun datasetRun)
Collects expressions from a subdataset run object.void
collect(JRElementDataset dataset)
Collects expressions from an element dataset.void
collect(JREllipse ellipse)
void
collect(JRFrame frame)
void
collect(JRGenericElement element)
Collects expressions from a generic element.void
collect(JRImage image)
void
collect(JRLine line)
void
collect(JRRectangle rectangle)
protected void
collect(JRReportTemplate template)
void
collect(JRStaticText staticText)
void
collect(JRStyle style)
Collects expressions used in a style definition.void
collect(JRStyle style, boolean skipFaulty)
Collects expressions used in a style definition.void
collect(JRSubreport subreport)
void
collect(JRTextField textField)
void
collectAnchor(JRAnchor anchor)
void
collectElement(JRElement element)
static List<JRExpression>
collectExpressions(JasperReportsContext jasperReportsContext, JRReport report)
static List<JRExpression>
collectExpressions(JasperReportsContext jasperReportsContext, JRReport report, JRCrosstab crosstab)
Deprecated.To be removed.void
collectHyperlink(JRHyperlink hyperlink)
void
collectHyperlinkParameter(JRHyperlinkParameter parameter)
static JRExpressionCollector
collector(JasperReportsContext jasperReportsContext, JRReport report)
static JRExpressionCollector
collector(JasperReportsContext jasperReportsContext, JRReport report, JRCrosstab crosstab)
protected List<JRExpressionCollector>
collectorsForExpression(Integer id, JRExpression expression)
protected void
collectPropertyExpression(JRPropertyExpression propertyExpression)
void
collectPropertyExpressions(JRPropertyExpression[] propertyExpressions)
protected void
collectTemplates()
JRExpressionCollector
getCollector(JRCrosstab crosstab)
Returns the expression collector for a crosstab.JRExpressionCollector
getCollector(JRDataset dataset)
Returns the expression collector for a dataset.JRExpressionCollector
getCollector(JRElementDataset elementDataset)
Returns the expression collector to which expressions in an element dataset belong.Integer
getCrosstabId(JRCrosstab crosstab)
JRExpressionCollector
getDatasetCollector(String datasetName)
Returns the expression collector for a report subdataset.JRExpression
getExpression(int expressionId)
Object
getExpressionContext(JRExpression expression)
Integer
getExpressionId(JRExpression expression)
List<JRExpression>
getExpressions()
Returns the collected expressions.List<JRExpression>
getExpressions(JRCrosstab crosstab)
Returns the expressions collected for a crosstab.List<JRExpression>
getExpressions(JRDataset dataset)
Returns the expressions collected for a dataset.JasperReportsContext
getJasperReportsContext()
Collection<JRExpression>
getReportExpressions()
Return all the expressions collected from the report.protected boolean
hasExpression(Integer id, JRExpression expression)
protected Object
popContextObject()
protected void
pushContextObject(Object context)
protected void
reassignId(JRExpression expression, Integer id)
protected JRExpressionCollector
rootCollector()
protected void
setExpressionContext(JRExpression expression)
-
-
-
Field Detail
-
EXCEPTION_MESSAGE_KEY_EXPRESSION_NOT_FOUND
public static final String EXCEPTION_MESSAGE_KEY_EXPRESSION_NOT_FOUND
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_TWO_GENERATED_IDS
public static final String EXCEPTION_MESSAGE_KEY_TWO_GENERATED_IDS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
JRExpressionCollector
protected JRExpressionCollector(JasperReportsContext jasperReportsContext, JRExpressionCollector parent, JRReport report)
-
JRExpressionCollector
protected JRExpressionCollector(JasperReportsContext jasperReportsContext, JRExpressionCollector parent, JRReport report, JRExpressionCollector.ExpressionVerifier expressionVerifier)
-
-
Method Detail
-
collector
public static JRExpressionCollector collector(JasperReportsContext jasperReportsContext, JRReport report)
-
collectExpressions
public static List<JRExpression> collectExpressions(JasperReportsContext jasperReportsContext, JRReport report)
-
collector
public static JRExpressionCollector collector(JasperReportsContext jasperReportsContext, JRReport report, JRCrosstab crosstab)
-
collectExpressions
public static List<JRExpression> collectExpressions(JasperReportsContext jasperReportsContext, JRReport report, JRCrosstab crosstab)
Deprecated.To be removed.
-
addExpression
public void addExpression(JRExpression expression)
Collects an expression.- Parameters:
expression
- the expression to collect
-
canUseId
protected boolean canUseId(JRExpression expression, Integer id)
-
reassignId
protected void reassignId(JRExpression expression, Integer id)
-
canUseId
protected boolean canUseId(List<JRExpressionCollector> collectors, JRExpression expression, Integer id)
-
rootCollector
protected JRExpressionCollector rootCollector()
-
hasExpression
protected boolean hasExpression(Integer id, JRExpression expression)
-
collectorsForExpression
protected List<JRExpressionCollector> collectorsForExpression(Integer id, JRExpression expression)
-
pushContextObject
protected void pushContextObject(Object context)
-
popContextObject
protected Object popContextObject()
-
setExpressionContext
protected void setExpressionContext(JRExpression expression)
-
getCollector
public JRExpressionCollector getCollector(JRElementDataset elementDataset)
Returns the expression collector to which expressions in an element dataset belong.If the element dataset includes a subdataset run, a (sub) expression collector that corresponds to the subdataset will be returned. Otherwise, this/the main expression collector will be returned.
- Parameters:
elementDataset
- an element dataset- Returns:
- the expression collector to be used for the element dataset
-
getDatasetCollector
public JRExpressionCollector getDatasetCollector(String datasetName)
Returns the expression collector for a report subdataset.- Parameters:
datasetName
- the subdataset name- Returns:
- the expression collector for the subdataset
-
getCollector
public JRExpressionCollector getCollector(JRDataset dataset)
Returns the expression collector for a dataset.- Parameters:
dataset
- the dataset- Returns:
- the dataset expression collector
-
getCollector
public JRExpressionCollector getCollector(JRCrosstab crosstab)
Returns the expression collector for a crosstab.- Parameters:
crosstab
- the crosstab- Returns:
- the crosstab expression collector
-
getExpressions
public List<JRExpression> getExpressions()
Returns the collected expressions.- Returns:
- the collected expressions
-
getReportExpressions
public Collection<JRExpression> getReportExpressions()
Return all the expressions collected from the report.- Returns:
- all the expressions collected from the report
-
getExpressions
public List<JRExpression> getExpressions(JRDataset dataset)
Returns the expressions collected for a dataset.- Parameters:
dataset
- the dataset- Returns:
- the expressions
-
getExpressions
public List<JRExpression> getExpressions(JRCrosstab crosstab)
Returns the expressions collected for a crosstab.- Parameters:
crosstab
- the crosstab- Returns:
- the expressions
-
getExpressionId
public Integer getExpressionId(JRExpression expression)
-
getExpression
public JRExpression getExpression(int expressionId)
-
getCrosstabId
public Integer getCrosstabId(JRCrosstab crosstab)
-
getExpressionContext
public Object getExpressionContext(JRExpression expression)
-
collect
public Collection<JRExpression> collect()
-
collectTemplates
protected void collectTemplates()
-
collect
protected void collect(JRReportTemplate template)
-
collect
public void collect(JRStyle style)
Collects expressions used in a style definition.- Parameters:
style
- the style to collect expressions from
-
collect
public void collect(JRStyle style, boolean skipFaulty)
Collects expressions used in a style definition.- Parameters:
style
- the style to collect expressions from
-
collectElement
public void collectElement(JRElement element)
-
collectPropertyExpressions
public void collectPropertyExpressions(JRPropertyExpression[] propertyExpressions)
-
collectPropertyExpression
protected void collectPropertyExpression(JRPropertyExpression propertyExpression)
-
collectAnchor
public void collectAnchor(JRAnchor anchor)
-
collectHyperlink
public void collectHyperlink(JRHyperlink hyperlink)
-
collectHyperlinkParameter
public void collectHyperlinkParameter(JRHyperlinkParameter parameter)
-
collect
public void collect(JRBreak breakElement)
-
collect
public void collect(JRLine line)
-
collect
public void collect(JRRectangle rectangle)
-
collect
public void collect(JREllipse ellipse)
-
collect
public void collect(JRImage image)
-
collect
public void collect(JRStaticText staticText)
-
collect
public void collect(JRTextField textField)
-
collect
public void collect(JRSubreport subreport)
-
collect
public void collect(JRCrosstab crosstab)
Collects expressions from a crosstab.- Parameters:
crosstab
- the crosstab
-
collect
public Collection<JRExpression> collect(JRDataset dataset)
Collects expressions from a dataset.- Parameters:
dataset
- the dataset- Returns:
- collected expressions
-
collect
public void collect(JRElementDataset dataset)
Collects expressions from an element dataset.- Parameters:
dataset
- the element dataset
-
collect
public void collect(JRDatasetRun datasetRun)
Collects expressions from a subdataset run object.- Parameters:
datasetRun
- the subdataset run
-
collect
protected void collect(JRCellContents cell)
-
collect
public void collect(JRFrame frame)
-
collect
public void collect(JRComponentElement componentElement)
Collects expressions from a component element wrapper.Common element expressions are collected, and then the component compiler's
ComponentCompiler.collectExpressions(Component, JRExpressionCollector)
is called to collect component expressions.- Parameters:
componentElement
- the component element
-
collect
public void collect(JRGenericElement element)
Collects expressions from a generic element.- Parameters:
element
- the generic element
-
collect
public void collect(MultiAxisData data)
-
collect
protected void collect(DataAxisLevel level, JRExpressionCollector datasetCollector)
-
getJasperReportsContext
public JasperReportsContext getJasperReportsContext()
-
-