public class JasperDesign extends JRBaseReport
The class contains all report properties and report elements inherited from the
JRReport
interface
in their design time state.
All its instances are subject to compilation before being used for filling and report generation. These instances are the raw material that the JasperReports library uses to generate reports. Such instances are usually obtained:
The first option for creating report designs relies on editing the JRXML files and using them
with the JasperCompileManager
in order to prepare them
for filling with data. Because they are well structured and are validated against a public
XSD when parsed, these files can be easily edited using simple editors or specialized
XML editors.
The second option is recommended only in case the parent application that uses JasperReports inside the reporting module needs to create report templates at runtime. In most cases this is not needed because the report templates do not need to change with every report execution, and hence static report templates could be used. Only the data used to fill these static report templates is dynamic.
However, there are cases when the actual report template is the result of some user input. The parent application might supply its users with a set of options when launching the reports that might take the form of some simplified report designer or wizard. In such cases, the actual report layout is not known or is not complete at design time, and can only be put together after the user's input is received.
The most common use case scenario that requires dynamically built or ad hoc report templates (as we call them) is one in which the columns that are going to be present in a table-like report layout are not known at design time. Instead, the user will give the number of columns and their order inside the desired report at runtime.
Developers have to make sure that the applications they create really need ad hoc reports and cannot rely solely on static report templates. Since dynamically built report templates have to be compiled on the fly at runtime, they can result in a certain loss of performance.
JRReport
,
JRBaseReport
,
JRXmlLoader
,
Serialized Formbackground, bottomMargin, columnCount, columnDirection, columnFooter, columnHeader, columnSpacing, columnWidth, datasets, defaultStyle, detailSection, formatFactoryClass, ignorePagination, importsSet, isFloatColumnFooter, isSummaryNewPage, isSummaryWithPageHeaderAndFooter, isTitleNewPage, language, lastPageFooter, leftMargin, mainDataset, name, noData, orientationValue, pageFooter, pageHeader, pageHeight, pageWidth, printOrderValue, PROPERTY_SECTION_TYPE, PROPERTY_WHEN_NO_DATA_TYPE, rightMargin, sectionType, styleResolver, styles, summary, templates, title, topMargin, whenNoDataTypeValue
CONFIG_PROPERTY_WHEN_NO_DATA_TYPE, LANGUAGE_GROOVY, LANGUAGE_JAVA
Constructor and Description |
---|
JasperDesign()
Constructs a JasperDesign object and fills it with the default variables and parameters.
|
JasperDesign(JasperReportsContext context) |
Modifier and Type | Method and Description |
---|---|
void |
addDataset(int index,
JRDesignDataset dataset)
Inserts a sub dataset at specified position into the report.
|
void |
addDataset(JRDesignDataset dataset)
Adds a sub dataset to the report.
|
void |
addField(JRField field) |
void |
addGroup(JRDesignGroup group)
Gets a map of report groups.
|
void |
addImport(String value)
Adds an import (needed if report expression require additional classes in order to compile).
|
void |
addParameter(JRParameter parameter)
Adds a report parameter.
|
void |
addPropertyExpression(DatasetPropertyExpression propertyExpression) |
void |
addScriptlet(JRScriptlet scriptlet)
Adds a report scriplet.
|
void |
addSortField(JRSortField sortField) |
void |
addStyle(int index,
JRStyle style)
Inserts a report style, that can be referenced by report elements, at specified position.
|
void |
addStyle(JRStyle style)
Adds a report style, that can be referenced by report elements.
|
void |
addTemplate(int index,
JRReportTemplate template)
Inserts a report template at specified position.
|
void |
addTemplate(JRReportTemplate template)
Adds a report template.
|
void |
addVariable(JRDesignVariable variable) |
protected List<JRCrosstab> |
getCrosstabs() |
Map<String,JRDataset> |
getDatasetMap()
Returns the sub datasets of the report indexed by name.
|
JRDataset[] |
getDatasets()
Returns the datasets of this report.
|
List<JRDataset> |
getDatasetsList()
Returns the list of report sub datasets.
|
Collection<JRExpression> |
getExpressions()
Returns a collection of all report expressions.
|
List<JRField> |
getFieldsList()
Gets a list of report fields.
|
Map<String,JRField> |
getFieldsMap()
Gets a map of report fields.
|
JRExpression |
getFilterExpression()
Returns the main dataset filter expression.
|
List<JRGroup> |
getGroupsList()
Gets an array of report groups.
|
Map<String,JRGroup> |
getGroupsMap()
Gets a list of report groups.
|
JRDesignDataset |
getMainDesignDataset()
Returns the main report dataset.
|
List<JRParameter> |
getParametersList()
Gets a list of report parameters (including built-in ones).
|
Map<String,JRParameter> |
getParametersMap()
Gets a map of report parameters (including built-in ones).
|
List<DatasetPropertyExpression> |
getPropertyExpressionsList() |
List<JRScriptlet> |
getScriptletsList()
Gets a list of report scriptlets (excluding the one specified by scriptletClass).
|
Map<String,JRScriptlet> |
getScriptletsMap()
Gets a map of report scriptlets (excluding the one specified by scriptletClass).
|
List<JRSortField> |
getSortFieldsList()
Gets a list of sort report fields.
|
JRStyle[] |
getStyles()
Gets an array of report level styles.
|
List<JRStyle> |
getStylesList()
Gets a list of report level styles.
|
Map<String,JRStyle> |
getStylesMap() |
JRReportTemplate[] |
getTemplates()
Returns the list of report templates.
|
List<JRReportTemplate> |
getTemplatesList()
Returns the list of report templates defined in the report.
|
List<JRVariable> |
getVariablesList()
Gets a list of report variables.
|
Map<String,JRVariable> |
getVariablesMap()
Gets a map of report variables.
|
boolean |
hasUUID()
Determines whether the report has an existing unique identifier.
|
void |
preprocess()
Performs preliminary processing and calculations prior to compilation.
|
JRDataset |
removeDataset(JRDataset dataset)
Removes a sub dataset from the report.
|
JRDataset |
removeDataset(String datasetName)
Removes a sub dataset from the report.
|
JRField |
removeField(JRField field) |
JRField |
removeField(String fieldName) |
JRGroup |
removeGroup(JRGroup group) |
JRGroup |
removeGroup(String groupName)
Removes a new group from the report design.
|
void |
removeImport(String value)
Removes an import.
|
JRParameter |
removeParameter(JRParameter parameter)
Removes a report parameter.
|
JRParameter |
removeParameter(String parameterName)
Removes a report parameter, based on its name.
|
void |
removePropertyExpression(DatasetPropertyExpression propertyExpression) |
DatasetPropertyExpression |
removePropertyExpression(String name) |
JRScriptlet |
removeScriptlet(JRScriptlet scriptlet)
Removes a report scriptlet.
|
JRScriptlet |
removeScriptlet(String scriptletName)
Removes a report scriptlet, based on its name.
|
JRSortField |
removeSortField(JRSortField sortField) |
JRSortField |
removeSortField(String fieldName)
Deprecated.
To be removed.
|
JRStyle |
removeStyle(JRStyle style)
Removes a report style from the list.
|
JRStyle |
removeStyle(String styleName)
Removes a report style from the list, based on the style name.
|
boolean |
removeTemplate(JRReportTemplate template)
Removes a report template.
|
JRVariable |
removeVariable(JRVariable variable) |
JRVariable |
removeVariable(String variableName) |
void |
resetDefaultStyle() |
void |
setBackground(JRBand background)
Sets the background band.
|
protected void |
setBandOrigin(JRBand band,
BandTypeEnum type) |
void |
setBottomMargin(int bottomMargin)
Sets the top margin.
|
void |
setColumnCount(int columnCount)
Specifies the number of report columns.
|
void |
setColumnDirection(RunDirectionEnum columnDirection)
Sets the column direction.
|
void |
setColumnFooter(JRBand columnFooter)
Sets the column footer band.
|
void |
setColumnHeader(JRBand columnHeader)
Sets the column header band.
|
void |
setColumnSpacing(int columnSpacing)
Sets the spacing between columns.
|
void |
setColumnWidth(int columnWidth)
Sets the column width.
|
void |
setDefaultStyle(JRStyle style) |
void |
setFilterExpression(JRExpression expression)
Sets the main dataset filter expression.
|
void |
setFloatColumnFooter(boolean isFloatColumnFooter)
Flag used to specify if the column footer section should be printed at the bottom of the column or if it
should immediately follow the last detail or group footer printed on the current column.
|
void |
setFormatFactoryClass(String formatFactoryClass) |
void |
setIgnorePagination(boolean ignorePagination)
Sets the value of the ignore pagination flag.
|
void |
setLanguage(String language)
Specifies the language used for report expressions (Java or Groovy).
|
void |
setLastPageFooter(JRBand lastPageFooter)
Sets the last page footer band.
|
void |
setLeftMargin(int leftMargin)
Sets the left margin.
|
void |
setMainDataset(JRDesignDataset dataset)
Sets the main report dataset.
|
void |
setName(String name)
Sets the report name.
|
void |
setNoData(JRBand noData)
Sets the noData band.
|
void |
setOrientation(OrientationEnum orientationValue)
Sets the report orientation.
|
void |
setPageFooter(JRBand pageFooter)
Sets the page footer band.
|
void |
setPageHeader(JRBand pageHeader)
Sets the page header band.
|
void |
setPageHeight(int pageHeight)
Sets page height (including margins etc.).
|
void |
setPageWidth(int pageWidth)
Sets page width (including margins etc.).
|
void |
setPrintOrder(PrintOrderEnum printOrderValue)
Sets the print order.
|
void |
setQuery(JRDesignQuery query)
Specifies the report query.
|
void |
setResourceBundle(String resourceBundle)
Sets the base name of the report associated resource bundle.
|
void |
setRightMargin(int rightMargin)
Sets the right margin.
|
void |
setScriptletClass(String scriptletClass) |
protected void |
setSectionOrigin(JRSection section,
BandTypeEnum type) |
void |
setSummary(JRBand summary)
Sets the summary band.
|
void |
setSummaryNewPage(boolean isSummaryNewPage)
Flag used to specify if the summary section should be printed on a separate last page.
|
void |
setSummaryWithPageHeaderAndFooter(boolean isSummaryWithPageHeaderAndFooter)
Flag used to specify if the summary section should be accompanied by the page header and footer.
|
void |
setTitle(JRBand title)
Sets the title band.
|
void |
setTitleNewPage(boolean isTitleNewPage)
Flag used to specify if the title section should be printed on a separate initial page.
|
void |
setTopMargin(int topMargin)
Sets the top margin.
|
void |
setUUID(UUID uuid)
Sets the unique identifier for the report.
|
copyTemplates, getAllBands, getBackground, getBottomMargin, getColumnCount, getColumnDirection, getColumnFooter, getColumnHeader, getColumnSpacing, getColumnWidth, getDefaultStyle, getDetailSection, getEventSupport, getFields, getFormatFactoryClass, getGroups, getImports, getLanguage, getLastPageFooter, getLeftMargin, getMainDataset, getName, getNoData, getOrientationValue, getPageFooter, getPageHeader, getPageHeight, getPageWidth, getParameters, getParentProperties, getPrintOrderValue, getPropertiesMap, getProperty, getPropertyExpressions, getPropertyNames, getQuery, getResourceBundle, getRightMargin, getScriptletClass, getScriptlets, getSectionType, getSortFields, getStyleResolver, getSummary, getTitle, getTopMargin, getUUID, getVariables, getWhenNoDataTypeValue, getWhenResourceMissingTypeValue, hasProperties, isFloatColumnFooter, isIgnorePagination, isSummaryNewPage, isSummaryWithPageHeaderAndFooter, isTitleNewPage, removeProperty, setJasperReportsContext, setProperty, setSectionType, setWhenNoDataType, setWhenResourceMissingType
public static final String EXCEPTION_MESSAGE_KEY_DUPLICATE_DATASET
public static final String EXCEPTION_MESSAGE_KEY_DUPLICATE_REPORT_STYLE
public static final String PROPERTY_BACKGROUND
public static final String PROPERTY_BOTTOM_MARGIN
public static final String PROPERTY_COLUMN_COUNT
public static final String PROPERTY_COLUMN_FOOTER
public static final String PROPERTY_COLUMN_HEADER
public static final String PROPERTY_COLUMN_SPACING
public static final String PROPERTY_COLUMN_WIDTH
public static final String PROPERTY_DATASETS
public static final String PROPERTY_DEFAULT_FONT
public static final String PROPERTY_DEFAULT_STLYE
public static final String PROPERTY_DETAIL
public static final String PROPERTY_FLOAT_COLUMN_FOOTER
public static final String PROPERTY_FONTS
public static final String PROPERTY_FORMAT_FACTORY_CLASS
public static final String PROPERTY_IGNORE_PAGINATION
public static final String PROPERTY_IMPORTS
public static final String PROPERTY_LANGUAGE
public static final String PROPERTY_LAST_PAGE_FOOTER
public static final String PROPERTY_LEFT_MARGIN
public static final String PROPERTY_MAIN_DATASET
public static final String PROPERTY_NAME
public static final String PROPERTY_NO_DATA
public static final String PROPERTY_ORIENTATION
public static final String PROPERTY_PAGE_FOOTER
public static final String PROPERTY_PAGE_HEADER
public static final String PROPERTY_PAGE_HEIGHT
public static final String PROPERTY_PAGE_WIDTH
public static final String PROPERTY_PRINT_ORDER
public static final String PROPERTY_COLUMN_DIRECTION
public static final String PROPERTY_RIGHT_MARGIN
public static final String PROPERTY_STYLES
public static final String PROPERTY_SUMMARY
public static final String PROPERTY_SUMMARY_NEW_PAGE
public static final String PROPERTY_SUMMARY_WITH_PAGE_HEADER_AND_FOOTER
public static final String PROPERTY_TEMPLATES
public static final String PROPERTY_TITLE
public static final String PROPERTY_TITLE_NEW_PAGE
public static final String PROPERTY_TOP_MARGIN
public JasperDesign()
public JasperDesign(JasperReportsContext context)
public void setName(String name)
public void setLanguage(String language)
public void setColumnCount(int columnCount)
public void setPrintOrder(PrintOrderEnum printOrderValue)
VERTICAL,
,
HORIZONTAL
public void setColumnDirection(RunDirectionEnum columnDirection)
public void setPageWidth(int pageWidth)
public void setPageHeight(int pageHeight)
public void setOrientation(OrientationEnum orientationValue)
ORIENTATION_PORTRAIT,
,
ORIENTATION_LANDSCAPE
public void setColumnWidth(int columnWidth)
public void setColumnSpacing(int columnSpacing)
public void setLeftMargin(int leftMargin)
public void setRightMargin(int rightMargin)
public void setTopMargin(int topMargin)
public void setBottomMargin(int bottomMargin)
public void setBackground(JRBand background)
public void setTitle(JRBand title)
public void setTitleNewPage(boolean isTitleNewPage)
isTitleNewPage
- true if the title section should be displayed on a separate initial page, false if
it will be displayed on the first page along with other sections.public void setSummary(JRBand summary)
public void setNoData(JRBand noData)
public void setSummaryNewPage(boolean isSummaryNewPage)
isSummaryNewPage
- true if the summary section should be displayed on a separate last page, false if
it will be displayed on the last page along with other sections, if there is enough space.public void setSummaryWithPageHeaderAndFooter(boolean isSummaryWithPageHeaderAndFooter)
isSummaryWithPageHeaderAndFooter
- true if the summary section should be displayed on pages that have the page header and footer,
false if it will be displayed on pages without header and footer.public void setFloatColumnFooter(boolean isFloatColumnFooter)
public void setPageHeader(JRBand pageHeader)
public void setPageFooter(JRBand pageFooter)
public void setLastPageFooter(JRBand lastPageFooter)
public void setColumnHeader(JRBand columnHeader)
public void setColumnFooter(JRBand columnFooter)
public void setScriptletClass(String scriptletClass)
public void setFormatFactoryClass(String formatFactoryClass)
public void setResourceBundle(String resourceBundle)
public void addImport(String value)
public void removeImport(String value)
public void resetDefaultStyle()
public void setDefaultStyle(JRStyle style)
public JRStyle[] getStyles()
getStyles
in interface JRReport
getStyles
in class JRBaseReport
public List<JRStyle> getStylesList()
public void addStyle(JRStyle style) throws JRException
JRException
public void addStyle(int index, JRStyle style) throws JRException
JRException
public JRStyle removeStyle(String styleName)
public List<JRScriptlet> getScriptletsList()
public Map<String,JRScriptlet> getScriptletsMap()
public void addScriptlet(JRScriptlet scriptlet) throws JRException
JRException
public JRScriptlet removeScriptlet(String scriptletName)
public void addPropertyExpression(DatasetPropertyExpression propertyExpression)
public void removePropertyExpression(DatasetPropertyExpression propertyExpression)
public DatasetPropertyExpression removePropertyExpression(String name)
public List<DatasetPropertyExpression> getPropertyExpressionsList()
public JRScriptlet removeScriptlet(JRScriptlet scriptlet)
public List<JRParameter> getParametersList()
public Map<String,JRParameter> getParametersMap()
public void addParameter(JRParameter parameter) throws JRException
JRException
public JRParameter removeParameter(String parameterName)
public JRParameter removeParameter(JRParameter parameter)
public void setQuery(JRDesignQuery query)
public void addField(JRField field) throws JRException
JRException
public List<JRSortField> getSortFieldsList()
public void addSortField(JRSortField sortField) throws JRException
JRException
public JRSortField removeSortField(String fieldName)
public JRSortField removeSortField(JRSortField sortField)
public List<JRVariable> getVariablesList()
public Map<String,JRVariable> getVariablesMap()
public void addVariable(JRDesignVariable variable) throws JRException
JRException
public JRVariable removeVariable(String variableName)
public JRVariable removeVariable(JRVariable variable)
public void addGroup(JRDesignGroup group) throws JRException
JRException
public JRGroup removeGroup(String groupName)
public Collection<JRExpression> getExpressions()
public JRDataset[] getDatasets()
JRReport
getDatasets
in interface JRReport
getDatasets
in class JRBaseReport
public List<JRDataset> getDatasetsList()
JRDesignDataset
objectspublic Map<String,JRDataset> getDatasetMap()
public void addDataset(JRDesignDataset dataset) throws JRException
dataset
- the datasetJRException
public void addDataset(int index, JRDesignDataset dataset) throws JRException
index
- the positiondataset
- the datasetJRException
public JRDataset removeDataset(String datasetName)
datasetName
- the dataset namepublic JRDataset removeDataset(JRDataset dataset)
dataset
- the dataset to be removedpublic JRDesignDataset getMainDesignDataset()
public void setMainDataset(JRDesignDataset dataset)
This method can be used as an alternative to setting the parameters, fields, etc directly on the report.
dataset
- the datasetpublic void preprocess()
protected List<JRCrosstab> getCrosstabs()
public void setIgnorePagination(boolean ignorePagination)
ignorePagination
- whether to ignore pagination when generating the reportJRReport.isIgnorePagination()
public JRExpression getFilterExpression()
JRDataset.getFilterExpression()
public void setFilterExpression(JRExpression expression)
expression
- the boolean expression to use as main dataset filter expressionJRDesignDataset.setFilterExpression(JRExpression)
,
JRDataset.getFilterExpression()
public void addTemplate(JRReportTemplate template)
template
- the template to add.getTemplates()
public void addTemplate(int index, JRReportTemplate template)
index
- the template position.template
- the template to insert.getTemplates()
public boolean removeTemplate(JRReportTemplate template)
template
- the template to removetrue
if and only if the template has been found and removedpublic JRReportTemplate[] getTemplates()
JRReport
template
.
Templates include styles which can be used in the report.
The order in which the templates are included in the report is important:
getTemplates
in interface JRReport
getTemplates
in class JRBaseReport
null
if noneJRTemplate
,
JRParameter.REPORT_TEMPLATES
public List<JRReportTemplate> getTemplatesList()
JRReportTemplate
objects for the reportgetTemplates()
,
addTemplate(JRReportTemplate)
protected void setBandOrigin(JRBand band, BandTypeEnum type)
protected void setSectionOrigin(JRSection section, BandTypeEnum type)
public void setUUID(UUID uuid)
uuid
- the identifierpublic boolean hasUUID()
JRBaseReport.getUUID()
would generate and return
an identifier.setUUID(UUID)
Copyright © 2021 TIBCO Software Inc.. All rights reserved.