Class JRVerifier
- java.lang.Object
-
- net.sf.jasperreports.engine.design.JRVerifier
-
public class JRVerifier extends Object
A report verifier.The verifier checks that a report design meets certain rules in order to pass report compilation.
- Author:
- Teodor Danciu ([email protected])
-
-
Field Summary
Fields Modifier and Type Field Description static String
PROPERTY_ALLOW_ELEMENT_NEGATIVE_WIDTH
static String
PROPERTY_ALLOW_ELEMENT_NEGATIVE_X
static String
PROPERTY_ALLOW_ELEMENT_NEGATIVE_Y
Property that determines whether elements positioned at negative Y offsets on bands, frames and other element containers are allowed in a report.static String
PROPERTY_ALLOW_ELEMENT_OVERLAP
A property that determines whether elements are allowed to overlap.
-
Constructor Summary
Constructors Modifier Constructor Description protected
JRVerifier(JasperReportsContext jasperReportsContext, JasperDesign jasperDesign, JRExpressionCollector expressionCollector)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addBrokenRule(Exception e, Object source)
Logs a broken report rule which was caused by an exception.void
addBrokenRule(String message, Object source)
Logs a broken rule for the report.protected static void
addBrokenRule(Collection<JRValidationFault> brokenRules, String message, Object source)
protected boolean
allowElementNegativeX(JRElement element)
protected boolean
allowElementNegativeY(JRElement element)
protected JRDesignDataset
currentDataset()
JRComponentElement
getCurrentComponentElement()
Returns the component element which is currently verified, if any.protected String
getElementPositionText(JRElement element)
JasperDesign
getReportDesign()
protected boolean
isAllowedToOverlap(JRElement element)
protected void
popCurrentComponentElement()
void
popSubdatasetContext()
protected void
pushCurrentComponentElement(JRComponentElement element)
void
pushSubdatasetContext(String subdatasetName)
protected boolean
toVerifyElementOverlap()
void
verify(JRCategoryDataset dataset)
protected void
verify(JRCategorySeries series)
void
verify(JRGanttDataset dataset)
protected void
verify(JRGanttSeries series)
void
verify(JRHighLowDataset dataset)
void
verify(JRPieDataset dataset)
protected void
verify(JRPieSeries series)
void
verify(JRTimePeriodDataset dataset)
protected void
verify(JRTimePeriodSeries series)
protected void
verify(JRTimeSeries series)
void
verify(JRTimeSeriesDataset dataset)
void
verify(JRValueDataset dataset)
Verify the design of a value dataset.void
verify(JRXyDataset dataset)
protected void
verify(JRXySeries series)
void
verify(JRXyzDataset dataset)
protected void
verify(JRXyzSeries series)
void
verify(MultiAxisData data)
static void
verifyBandHeights(Collection<JRValidationFault> brokenRules, JRReport report, int pageHeight, int topMargin, int bottomMargin)
Validates that the report band heights fit on a page of certain size.protected void
verifyCommonReturnValue(CommonReturnValue returnValue)
protected void
verifyComponentElement(JRComponentElement element)
protected void
verifyCrosstabNextGroup(JRCrosstabGroup group, JRCrosstabGroup nextGroup)
void
verifyDatasetRun(JRDatasetRun datasetRun)
Verifies a subdataset run object.protected Collection<JRValidationFault>
verifyDesign()
static Collection<JRValidationFault>
verifyDesign(JasperDesign jasperDesign)
Validates areport design
.static Collection<JRValidationFault>
verifyDesign(JasperReportsContext jasperReportsContext, JasperDesign jasperDesign, JRExpressionCollector expressionCollector)
Validates areport design
.void
verifyElement(JRElement element)
void
verifyElementDataset(JRElementDataset dataset)
protected void
verifyElementOverlap(JRElement element1, JRElement element2)
protected void
verifyElementsOverlap(JRElement[] elements)
protected void
verifyEmptyBackground()
void
verifyExpression(JRExpression expression, Object parent, String mandatoryMessage)
protected void
verifyFormatFactoryClass()
protected void
verifyGenericElement(JRGenericElement element)
void
verifyHyperlink(JRHyperlink hyperlink)
protected void
verifyHyperlinkParameter(JRHyperlinkParameter parameter)
protected void
verifyPart(JRPart part)
protected void
verifyPropertyExpression(JRPropertyExpression propertyExpression)
protected void
verifyProperyExpressions(JRPropertyExpression[] propertyExpressions)
protected void
verifyReportElement(JRElement element)
protected void
verifyReportTemplates()
protected void
verifyReturnValue(ExpressionReturnValue returnValue)
protected void
verifyReturnValue(VariableReturnValue returnValue)
protected void
verifyTemplate(JRReportTemplate template)
protected boolean
verifyTemplateSourceType(Class<?> valueClass)
Deprecated.To be removed.
-
-
-
Field Detail
-
PROPERTY_ALLOW_ELEMENT_OVERLAP
public static final String PROPERTY_ALLOW_ELEMENT_OVERLAP
A property that determines whether elements are allowed to overlap.If this value is set to
false
, the report is verified not to contain elements that overlap. This is useful when the report is meant to be exported to grid-based formats such as HTML, XLS or CSV. Setting this property tofalse
ensures that element overlap issues are caught at report compile time.Additionally, when this property is set to false
false
, the report is verified not to have any content in the background section as this content would likely be overlapped by other sections and would not show in grid-based exporters.By default, the property is set to
true
which means that no element overlap checks are performed.The property can be set at the following levels:
- At global level (in jasperreports.properties) to provide a default value.
- At report level, to indicate whether element overlap checks are to be performed for the report. If not set, the global property value is used.
- At report element level to specify that the particular element is
allowed to overlap or be overlapped by other elements, when the report
or global property determines report element overlap verification.
The element level property is only effective when set to
true
; setting the property tofalse
does not make the verifier check for overlaps when the report is not set to be checked for element overlaps.
Note that print when expressions or export filters cannot be taken into consideration while checking for overlapping elements as this check is performed at report compilation time. If a report contains two elements that overlap but have print when expressions that guarantee that only one of them will be printed, or if export filters are in place to exclude one of the elements, one of them should be explicitly marked to allow element overlap when the report is configured to check for overlaps.
- See Also:
- Constant Field Values
-
PROPERTY_ALLOW_ELEMENT_NEGATIVE_WIDTH
public static final String PROPERTY_ALLOW_ELEMENT_NEGATIVE_WIDTH
- See Also:
- Constant Field Values
-
PROPERTY_ALLOW_ELEMENT_NEGATIVE_X
public static final String PROPERTY_ALLOW_ELEMENT_NEGATIVE_X
- See Also:
- Constant Field Values
-
PROPERTY_ALLOW_ELEMENT_NEGATIVE_Y
public static final String PROPERTY_ALLOW_ELEMENT_NEGATIVE_Y
Property that determines whether elements positioned at negative Y offsets on bands, frames and other element containers are allowed in a report.Elements placed at negative Y offsets can cause unexpected problems in grid-based exporters where they can overlap elements from previous bands/element containers.
If the property is set to
false
, elements in the report are verified to have positive Y offsets. Otherwise, no check is performed on element Y offsets.The property can be set at element, report and global levels. By default the property is set to
true
.- Since:
- 3.7.3
- See Also:
JRElement.getY()
, Constant Field Values
-
-
Constructor Detail
-
JRVerifier
protected JRVerifier(JasperReportsContext jasperReportsContext, JasperDesign jasperDesign, JRExpressionCollector expressionCollector)
-
-
Method Detail
-
getReportDesign
public JasperDesign getReportDesign()
-
addBrokenRule
public void addBrokenRule(String message, Object source)
Logs a broken rule for the report.- Parameters:
message
- the messagesource
- the source object to which the rule applies; can be null if not available
-
addBrokenRule
protected static void addBrokenRule(Collection<JRValidationFault> brokenRules, String message, Object source)
-
addBrokenRule
public void addBrokenRule(Exception e, Object source)
Logs a broken report rule which was caused by an exception.- Parameters:
e
- the exception that caused the broken rulesource
- the source object if available
-
verifyDesign
public static Collection<JRValidationFault> verifyDesign(JasperReportsContext jasperReportsContext, JasperDesign jasperDesign, JRExpressionCollector expressionCollector)
Validates areport design
.- Parameters:
jasperDesign
- the report designexpressionCollector
- a collector which was used to collect expressions from the report design; if null, a new collector will be created and used to collect the expressions- Returns:
- a list of
design faults
; the report design is valid if and only if the list is empty
-
verifyDesign
public static Collection<JRValidationFault> verifyDesign(JasperDesign jasperDesign)
Validates areport design
.- Parameters:
jasperDesign
- the report design- Returns:
- a list of
design faults
; the report design is valid if and only if the list is empty
-
verifyDesign
protected Collection<JRValidationFault> verifyDesign()
-
verifyEmptyBackground
protected void verifyEmptyBackground()
-
verifyBandHeights
public static void verifyBandHeights(Collection<JRValidationFault> brokenRules, JRReport report, int pageHeight, int topMargin, int bottomMargin)
Validates that the report band heights fit on a page of certain size.- Parameters:
brokenRules
- the list of rules to which the validation failures are to be addedreport
- the report whose bands are to be validatedpageHeight
- the height of the pagetopMargin
- the page top marginbottomMargin
- the page bottom margin
-
verifyFormatFactoryClass
protected void verifyFormatFactoryClass()
-
verifyReportTemplates
protected void verifyReportTemplates()
-
verifyTemplate
protected void verifyTemplate(JRReportTemplate template)
-
verifyTemplateSourceType
protected boolean verifyTemplateSourceType(Class<?> valueClass)
Deprecated.To be removed.
-
toVerifyElementOverlap
protected boolean toVerifyElementOverlap()
-
isAllowedToOverlap
protected boolean isAllowedToOverlap(JRElement element)
-
verifyElementsOverlap
protected void verifyElementsOverlap(JRElement[] elements)
-
verifyElement
public void verifyElement(JRElement element)
-
verifyHyperlink
public void verifyHyperlink(JRHyperlink hyperlink)
-
verifyHyperlinkParameter
protected void verifyHyperlinkParameter(JRHyperlinkParameter parameter)
-
verifyReturnValue
protected void verifyReturnValue(VariableReturnValue returnValue)
-
verifyReturnValue
protected void verifyReturnValue(ExpressionReturnValue returnValue)
-
verifyCommonReturnValue
protected void verifyCommonReturnValue(CommonReturnValue returnValue)
-
verifyCrosstabNextGroup
protected void verifyCrosstabNextGroup(JRCrosstabGroup group, JRCrosstabGroup nextGroup)
-
verifyElementDataset
public void verifyElementDataset(JRElementDataset dataset)
-
verifyDatasetRun
public void verifyDatasetRun(JRDatasetRun datasetRun)
Verifies a subdataset run object.- Parameters:
datasetRun
- the subdataset run
-
verify
public void verify(JRCategoryDataset dataset)
-
verify
protected void verify(JRCategorySeries series)
-
verify
public void verify(JRPieDataset dataset)
-
verify
protected void verify(JRPieSeries series)
-
verify
public void verify(JRHighLowDataset dataset)
-
verify
public void verify(JRTimePeriodDataset dataset)
-
verify
protected void verify(JRTimePeriodSeries series)
-
verify
public void verify(JRTimeSeriesDataset dataset)
-
verify
protected void verify(JRTimeSeries series)
-
verify
public void verify(JRValueDataset dataset)
Verify the design of a value dataset. Since value dataset's only contain a single value and do not support hyperlinks there is nothing to verify.
-
verify
public void verify(JRXyDataset dataset)
-
verify
protected void verify(JRXySeries series)
-
verify
protected void verify(JRGanttSeries series)
-
verify
public void verify(JRXyzDataset dataset)
-
verify
public void verify(JRGanttDataset dataset)
-
verify
protected void verify(JRXyzSeries series)
-
verifyReportElement
protected void verifyReportElement(JRElement element)
-
allowElementNegativeX
protected boolean allowElementNegativeX(JRElement element)
-
allowElementNegativeY
protected boolean allowElementNegativeY(JRElement element)
-
verifyProperyExpressions
protected void verifyProperyExpressions(JRPropertyExpression[] propertyExpressions)
-
verifyPropertyExpression
protected void verifyPropertyExpression(JRPropertyExpression propertyExpression)
-
verifyComponentElement
protected void verifyComponentElement(JRComponentElement element)
-
getCurrentComponentElement
public JRComponentElement getCurrentComponentElement()
Returns the component element which is currently verified, if any.This method can be used in the
ComponentCompiler.verify(Component, JRVerifier)
method to get a handle of the wrapping componenet element.- Returns:
- the currently verified component element
-
pushCurrentComponentElement
protected void pushCurrentComponentElement(JRComponentElement element)
-
popCurrentComponentElement
protected void popCurrentComponentElement()
-
verifyGenericElement
protected void verifyGenericElement(JRGenericElement element)
-
verifyExpression
public void verifyExpression(JRExpression expression, Object parent, String mandatoryMessage)
-
verify
public void verify(MultiAxisData data)
-
verifyPart
protected void verifyPart(JRPart part)
-
pushSubdatasetContext
public void pushSubdatasetContext(String subdatasetName)
-
popSubdatasetContext
public void popSubdatasetContext()
-
currentDataset
protected JRDesignDataset currentDataset()
-
-