Class JRDesignDataset
- java.lang.Object
-
- net.sf.jasperreports.engine.base.JRBaseDataset
-
- net.sf.jasperreports.engine.design.JRDesignDataset
-
- All Implemented Interfaces:
Serializable,Cloneable,JRChangeEventsSupport,JRCloneable,JRDataset,JRIdentifiable,JRPropertiesHolder
public class JRDesignDataset extends JRBaseDataset
Implementation ofJRDatasetto be used for report design.- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class net.sf.jasperreports.engine.base.JRBaseDataset
fields, filterExpression, groups, isMain, name, parameters, propertiesMap, PROPERTY_WHEN_RESOURCE_MISSING_TYPE, query, resourceBundle, scriptletClass, scriptlets, sortFields, uuid, variables, whenResourceMissingTypeValue
-
-
Constructor Summary
Constructors Constructor Description JRDesignDataset(boolean isMain)Create a dataset.JRDesignDataset(JasperReportsContext jasperReportsContext, boolean isMain)Create a dataset.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddField(int index, JRField field)Inserts a field at the specified position into the dataset.voidaddField(JRField field)Adds a field to the dataset.voidaddGroup(int index, JRDesignGroup group)Inserts a group at the specified position into the dataset.voidaddGroup(JRDesignGroup group)Adds a group to the dataset.voidaddParameter(int index, JRParameter parameter)Inserts a parameter at the specified position into the dataset.voidaddParameter(JRParameter parameter)Adds a parameter to the dataset.voidaddPropertyExpression(DatasetPropertyExpression propertyExpression)Add a dynamic/expression-based property.voidaddScriptlet(int index, JRScriptlet scriptlet)Inserts a scriptlet at the specified position into the dataset.voidaddScriptlet(JRScriptlet scriptlet)Adds a scriptlet to the dataset.voidaddSortField(int index, JRSortField sortField)Inserts a sort field at specified position into the dataset.voidaddSortField(JRSortField sortField)Adds a sort field to the dataset.voidaddVariable(int index, JRDesignVariable variable)Inserts a variable at specified position into the dataset.protected voidaddVariable(int index, JRDesignVariable variable, boolean system)Inserts a variable at specified position into the dataset.voidaddVariable(JRDesignVariable variable)Adds a variable to the dataset.protected voidaddVariable(JRDesignVariable variable, boolean system)Adds a variable to the dataset.Objectclone()JRField[]getFields()Returns the dataset's fields.List<JRField>getFieldsList()Returns the list of fields.Map<String,JRField>getFieldsMap()Returns the map of fields indexed by name.JRGroup[]getGroups()Returns the dataset's groups.List<JRGroup>getGroupsList()Returns the list of groups.Map<String,JRGroup>getGroupsMap()Returns the map of groups indexed by name.JRParameter[]getParameters()Returns the dataset's parameters.List<JRParameter>getParametersList()Returns the list of parameters, including build-in ones.Map<String,JRParameter>getParametersMap()Returns the map of parameters, including build-in ones, indexed by name.DatasetPropertyExpression[]getPropertyExpressions()Returns the list of dynamic/expression-based properties for this dataset.List<DatasetPropertyExpression>getPropertyExpressionsList()Returns the list of property expressions.JRScriptlet[]getScriptlets()Returns the dataset's scriptlets.List<JRScriptlet>getScriptletsList()Returns the list of scriptlets, excluding the scriptletClass one.Map<String,JRScriptlet>getScriptletsMap()Returns the map of scriptlets, excluding the scriptletClass one, indexed by name.JRSortField[]getSortFields()Returns the dataset's sort fields.List<JRSortField>getSortFieldsList()Returns the list of sort fields.Map<String,JRSortField>getSortFieldsMap()Returns the map of sort fields indexed by name and type.JRVariable[]getVariables()Returns the dataset's variables.List<JRVariable>getVariablesList()Returns the list of variables, including build-in ones.Map<String,JRVariable>getVariablesMap()Returns the map of variable, including build-in ones, indexed by name.booleanhasUUID()Determines whether the report has an existing unique identifier.protected voidqueryLanguageChanged(String oldLanguage, String newLanguage)JRFieldremoveField(String fieldName)Removes a field from the dataset.JRFieldremoveField(JRField field)Removes a field from the dataset.JRGroupremoveGroup(String groupName)Removes a group from the dataset.JRGroupremoveGroup(JRGroup group)Removes a group from the dataset.JRParameterremoveParameter(String parameterName)Removes a parameter from the dataset.JRParameterremoveParameter(JRParameter parameter)Removes a parameter from the dataset.DatasetPropertyExpressionremovePropertyExpression(String name)Remove a property expression.voidremovePropertyExpression(DatasetPropertyExpression propertyExpression)Remove a property expression.JRScriptletremoveScriptlet(String scriptletName)Removes a scriptlet from the dataset.JRScriptletremoveScriptlet(JRScriptlet scriptlet)Removes a scriptlet from the dataset.JRSortFieldremoveSortField(JRSortField sortField)Removes a sort field from the dataset.JRVariableremoveVariable(String variableName)Removes a variable from the dataset.JRVariableremoveVariable(JRVariable variable)Removes a variable from the dataset.voidsetFilterExpression(JRExpression expression)Sets the dataset filter expression.voidsetName(String name)Sets the name of the dataset.voidsetProperty(String propName, String value)Adds/sets a property value.voidsetQuery(JRDesignQuery query)Sets the dataset query.voidsetResourceBundle(String resourceBundle)Sets the base name of resource bundle to be used by the dataset.voidsetScriptletClass(String scriptletClass)Sets the scriptlet class name.voidsetUUID(UUID uuid)Sets the unique identifier for the report.-
Methods inherited from class net.sf.jasperreports.engine.base.JRBaseDataset
getEventSupport, getFilterExpression, getName, getParentProperties, getPropertiesMap, getQuery, getResourceBundle, getScriptletClass, getUUID, getWhenResourceMissingTypeValue, hasProperties, isMainDataset, setWhenResourceMissingType
-
-
-
-
Field Detail
-
EXCEPTION_MESSAGE_KEY_DUPLICATE_GROUP
public static final String EXCEPTION_MESSAGE_KEY_DUPLICATE_GROUP
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_DUPLICATE_FIELD
public static final String EXCEPTION_MESSAGE_KEY_DUPLICATE_FIELD
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_DUPLICATE_PARAMETER
public static final String EXCEPTION_MESSAGE_KEY_DUPLICATE_PARAMETER
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_DUPLICATE_SCRIPTLET
public static final String EXCEPTION_MESSAGE_KEY_DUPLICATE_SCRIPTLET
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_DUPLICATE_SORT_FIELD
public static final String EXCEPTION_MESSAGE_KEY_DUPLICATE_SORT_FIELD
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_DUPLICATE_VARIABLE
public static final String EXCEPTION_MESSAGE_KEY_DUPLICATE_VARIABLE
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_UNKNOWN_BUILTIN_PARAMETER_TYPE
public static final String EXCEPTION_MESSAGE_KEY_UNKNOWN_BUILTIN_PARAMETER_TYPE
- See Also:
- Constant Field Values
-
PROPERTY_FIELDS
public static final String PROPERTY_FIELDS
- See Also:
- Constant Field Values
-
PROPERTY_FILTER_EXPRESSION
public static final String PROPERTY_FILTER_EXPRESSION
- See Also:
- Constant Field Values
-
PROPERTY_GROUPS
public static final String PROPERTY_GROUPS
- See Also:
- Constant Field Values
-
PROPERTY_NAME
public static final String PROPERTY_NAME
- See Also:
- Constant Field Values
-
PROPERTY_SCRIPTLETS
public static final String PROPERTY_SCRIPTLETS
- See Also:
- Constant Field Values
-
PROPERTY_PARAMETERS
public static final String PROPERTY_PARAMETERS
- See Also:
- Constant Field Values
-
PROPERTY_QUERY
public static final String PROPERTY_QUERY
- See Also:
- Constant Field Values
-
PROPERTY_RESOURCE_BUNDLE
public static final String PROPERTY_RESOURCE_BUNDLE
- See Also:
- Constant Field Values
-
PROPERTY_SCRIPTLET_CLASS
public static final String PROPERTY_SCRIPTLET_CLASS
- See Also:
- Constant Field Values
-
PROPERTY_SORT_FIELDS
public static final String PROPERTY_SORT_FIELDS
- See Also:
- Constant Field Values
-
PROPERTY_VARIABLES
public static final String PROPERTY_VARIABLES
- See Also:
- Constant Field Values
-
PROPERTY_PROPERTY_EXPRESSIONS
public static final String PROPERTY_PROPERTY_EXPRESSIONS
- See Also:
- Constant Field Values
-
scriptletsMap
protected Map<String,JRScriptlet> scriptletsMap
Scriptlets mapped by name.
-
scriptletsList
protected List<JRScriptlet> scriptletsList
-
parametersMap
protected Map<String,JRParameter> parametersMap
Parameters mapped by name.
-
parametersList
protected List<JRParameter> parametersList
-
sortFieldsMap
protected Map<String,JRSortField> sortFieldsMap
Sort fields mapped by name.
-
sortFieldsList
protected List<JRSortField> sortFieldsList
-
variablesMap
protected Map<String,JRVariable> variablesMap
Variables mapped by name.
-
variablesList
protected List<JRVariable> variablesList
-
-
Constructor Detail
-
JRDesignDataset
public JRDesignDataset(boolean isMain)
Create a dataset.- Parameters:
isMain- whether this is the main dataset of the report or a sub dataset- See Also:
JRDataset.isMainDataset()
-
JRDesignDataset
public JRDesignDataset(JasperReportsContext jasperReportsContext, boolean isMain)
Create a dataset.- Parameters:
isMain- whether this is the main dataset of the report or a sub dataset- See Also:
JRDataset.isMainDataset()
-
-
Method Detail
-
setUUID
public void setUUID(UUID uuid)
Sets the unique identifier for the report.- Parameters:
uuid- the identifier
-
hasUUID
public boolean hasUUID()
Determines whether the report has an existing unique identifier. Note that when no existing identifier is set,JRBaseDataset.getUUID()would generate and return an identifier.- Returns:
- whether the report has an externally set unique identifier
- See Also:
setUUID(UUID)
-
setName
public void setName(String name)
Sets the name of the dataset.- Parameters:
name- the name of the dataset- See Also:
JRDataset.getName()
-
getScriptlets
public JRScriptlet[] getScriptlets()
Description copied from interface:JRDatasetReturns the dataset's scriptlets.- Specified by:
getScriptletsin interfaceJRDataset- Overrides:
getScriptletsin classJRBaseDataset- Returns:
- the dataset's scriptlets
-
getScriptletsList
public List<JRScriptlet> getScriptletsList()
Returns the list of scriptlets, excluding the scriptletClass one.- Returns:
- list of
JRScriptletobjects
-
getScriptletsMap
public Map<String,JRScriptlet> getScriptletsMap()
Returns the map of scriptlets, excluding the scriptletClass one, indexed by name.- Returns:
JRScriptletobjects indexed by name
-
addScriptlet
public void addScriptlet(JRScriptlet scriptlet) throws JRException
Adds a scriptlet to the dataset.- Parameters:
scriptlet- the scriptlet to add- Throws:
JRException- See Also:
JRDataset.getScriptlets()
-
addScriptlet
public void addScriptlet(int index, JRScriptlet scriptlet) throws JRExceptionInserts a scriptlet at the specified position into the dataset.- Parameters:
index- the scriptlet positionscriptlet- the scriptlet to insert- Throws:
JRException- See Also:
JRDataset.getScriptlets()
-
removeScriptlet
public JRScriptlet removeScriptlet(String scriptletName)
Removes a scriptlet from the dataset.- Parameters:
scriptletName- the scriptlet name- Returns:
- the removed scriptlet, or
nullif the scriptlet was not found
-
removeScriptlet
public JRScriptlet removeScriptlet(JRScriptlet scriptlet)
Removes a scriptlet from the dataset.- Parameters:
scriptlet- the scriptlet to be removed- Returns:
- the scriptlet to be removed
-
getParameters
public JRParameter[] getParameters()
Description copied from interface:JRDatasetReturns the dataset's parameters.- Specified by:
getParametersin interfaceJRDataset- Overrides:
getParametersin classJRBaseDataset- Returns:
- the dataset's parameters
-
getParametersList
public List<JRParameter> getParametersList()
Returns the list of parameters, including build-in ones.- Returns:
- list of
JRParameterobjects
-
getParametersMap
public Map<String,JRParameter> getParametersMap()
Returns the map of parameters, including build-in ones, indexed by name.- Returns:
JRParameterobjects indexed by name
-
addParameter
public void addParameter(JRParameter parameter) throws JRException
Adds a parameter to the dataset.- Parameters:
parameter- the parameter to add- Throws:
JRException- See Also:
JRDataset.getParameters()
-
addParameter
public void addParameter(int index, JRParameter parameter) throws JRExceptionInserts a parameter at the specified position into the dataset.- Parameters:
index- the parameter positionparameter- the parameter to insert- Throws:
JRException- See Also:
JRDataset.getParameters()
-
removeParameter
public JRParameter removeParameter(String parameterName)
Removes a parameter from the dataset.- Parameters:
parameterName- the parameter name- Returns:
- the removed parameter, or
nullif the parameter was not found
-
removeParameter
public JRParameter removeParameter(JRParameter parameter)
Removes a parameter from the dataset.- Parameters:
parameter- the parameter to be removed- Returns:
- the parameter to be removed
-
setQuery
public void setQuery(JRDesignQuery query)
Sets the dataset query.- Parameters:
query- the query- See Also:
JRDataset.getQuery()
-
setScriptletClass
public void setScriptletClass(String scriptletClass)
Sets the scriptlet class name.If no scriptlet class name is specified, a default scriptlet is used.
- Parameters:
scriptletClass- the class name of the scriptlet- See Also:
JRDataset.getScriptletClass()
-
getFields
public JRField[] getFields()
Description copied from interface:JRDatasetReturns the dataset's fields.- Specified by:
getFieldsin interfaceJRDataset- Overrides:
getFieldsin classJRBaseDataset- Returns:
- the dataset's fields
-
getFieldsList
public List<JRField> getFieldsList()
Returns the list of fields.- Returns:
- list of
JRFieldobjects
-
getFieldsMap
public Map<String,JRField> getFieldsMap()
Returns the map of fields indexed by name.- Returns:
JRFieldobjects indexed by name
-
addField
public void addField(JRField field) throws JRException
Adds a field to the dataset.- Parameters:
field- the field to add- Throws:
JRException- See Also:
JRDataset.getFields()
-
addField
public void addField(int index, JRField field) throws JRExceptionInserts a field at the specified position into the dataset.- Parameters:
index- the field positionfield- the field to insert- Throws:
JRException- See Also:
JRDataset.getFields()
-
removeField
public JRField removeField(String fieldName)
Removes a field from the dataset.- Parameters:
fieldName- the field name- Returns:
- the removed field, or
nullif the field was not found
-
removeField
public JRField removeField(JRField field)
Removes a field from the dataset.- Parameters:
field- the field to be removed- Returns:
- the field to be removed
-
getSortFields
public JRSortField[] getSortFields()
Description copied from interface:JRDatasetReturns the dataset's sort fields.- Specified by:
getSortFieldsin interfaceJRDataset- Overrides:
getSortFieldsin classJRBaseDataset- Returns:
- the dataset's sort fields
-
getSortFieldsList
public List<JRSortField> getSortFieldsList()
Returns the list of sort fields.- Returns:
- list of
JRSortFieldobjects
-
getSortFieldsMap
public Map<String,JRSortField> getSortFieldsMap()
Returns the map of sort fields indexed by name and type.- Returns:
JRFieldobjects indexed by name
-
addSortField
public void addSortField(JRSortField sortField) throws JRException
Adds a sort field to the dataset.- Parameters:
sortField- the sort field to add- Throws:
JRException- See Also:
JRDataset.getSortFields()
-
addSortField
public void addSortField(int index, JRSortField sortField) throws JRExceptionInserts a sort field at specified position into the dataset.- Parameters:
index- the sort field positionsortField- the sort field to insert- Throws:
JRException- See Also:
JRDataset.getSortFields()
-
removeSortField
public JRSortField removeSortField(JRSortField sortField)
Removes a sort field from the dataset.- Parameters:
sortField- the sort field to be removed- Returns:
- the sort field to be removed
-
getVariables
public JRVariable[] getVariables()
Description copied from interface:JRDatasetReturns the dataset's variables.- Specified by:
getVariablesin interfaceJRDataset- Overrides:
getVariablesin classJRBaseDataset- Returns:
- the dataset's variables
-
getVariablesList
public List<JRVariable> getVariablesList()
Returns the list of variables, including build-in ones.- Returns:
- list of
JRVariableobjects
-
getVariablesMap
public Map<String,JRVariable> getVariablesMap()
Returns the map of variable, including build-in ones, indexed by name.- Returns:
JRVariableobjects indexed by name
-
addVariable
public void addVariable(JRDesignVariable variable) throws JRException
Adds a variable to the dataset.- Parameters:
variable- the variable to add- Throws:
JRException- See Also:
JRDataset.getVariables()
-
addVariable
public void addVariable(int index, JRDesignVariable variable) throws JRExceptionInserts a variable at specified position into the dataset.- Parameters:
index- the variable positionvariable- the variable to insert- Throws:
JRException- See Also:
JRDataset.getVariables()
-
addVariable
protected void addVariable(JRDesignVariable variable, boolean system) throws JRException
Adds a variable to the dataset.- Parameters:
variable- the variable to addsystem- whether the variable should be added before user defined variables or at the end of the variables list- Throws:
JRException
-
addVariable
protected void addVariable(int index, JRDesignVariable variable, boolean system) throws JRExceptionInserts a variable at specified position into the dataset.- Parameters:
index- the variable positionvariable- the variable to insertsystem- whether the variable should be inserted before user defined variables or at the end of the variables list- Throws:
JRException
-
removeVariable
public JRVariable removeVariable(String variableName)
Removes a variable from the dataset.- Parameters:
variableName- the variable name- Returns:
- the removed variable, or
nullif the variable was not found
-
removeVariable
public JRVariable removeVariable(JRVariable variable)
Removes a variable from the dataset.- Parameters:
variable- the variable to be removed- Returns:
- the variable to be removed
-
getGroups
public JRGroup[] getGroups()
Description copied from interface:JRDatasetReturns the dataset's groups.- Specified by:
getGroupsin interfaceJRDataset- Overrides:
getGroupsin classJRBaseDataset- Returns:
- the dataset's groups
-
getGroupsList
public List<JRGroup> getGroupsList()
Returns the list of groups.- Returns:
- list of
JRGroupobjects
-
getGroupsMap
public Map<String,JRGroup> getGroupsMap()
Returns the map of groups indexed by name.- Returns:
JRGroupobjects indexed by name
-
addGroup
public void addGroup(JRDesignGroup group) throws JRException
Adds a group to the dataset.- Parameters:
group- the group to add- Throws:
JRException- See Also:
JRDataset.getGroups()
-
addGroup
public void addGroup(int index, JRDesignGroup group) throws JRExceptionInserts a group at the specified position into the dataset.- Parameters:
index- the group positiongroup- the group to insert- Throws:
JRException- See Also:
JRDataset.getGroups()
-
removeGroup
public JRGroup removeGroup(String groupName)
Removes a group from the dataset.- Parameters:
groupName- the group name- Returns:
- the removed group, or
nullif the group was not found
-
removeGroup
public JRGroup removeGroup(JRGroup group)
Removes a group from the dataset.- Parameters:
group- the group to be removed- Returns:
- the group to be removed
-
setResourceBundle
public void setResourceBundle(String resourceBundle)
Sets the base name of resource bundle to be used by the dataset.- Parameters:
resourceBundle- the resource bundle base name
-
setProperty
public void setProperty(String propName, String value)
Adds/sets a property value.- Parameters:
propName- the name of the propertyvalue- the value of the property
-
addPropertyExpression
public void addPropertyExpression(DatasetPropertyExpression propertyExpression)
Add a dynamic/expression-based property.- Parameters:
propertyExpression- the property to add- See Also:
getPropertyExpressions()
-
removePropertyExpression
public void removePropertyExpression(DatasetPropertyExpression propertyExpression)
Remove a property expression.- Parameters:
propertyExpression- the property expression to remove- See Also:
addPropertyExpression(DatasetPropertyExpression)
-
removePropertyExpression
public DatasetPropertyExpression removePropertyExpression(String name)
Remove a property expression.- Parameters:
name- the name of the property to remove- Returns:
- the removed property expression (if found)
-
getPropertyExpressionsList
public List<DatasetPropertyExpression> getPropertyExpressionsList()
Returns the list of property expressions.- Returns:
- the list of property expressions (
DatasetPropertyExpressioninstances) - See Also:
addPropertyExpression(DatasetPropertyExpression)
-
getPropertyExpressions
public DatasetPropertyExpression[] getPropertyExpressions()
Description copied from interface:JRDatasetReturns the list of dynamic/expression-based properties for this dataset.- Specified by:
getPropertyExpressionsin interfaceJRDataset- Overrides:
getPropertyExpressionsin classJRBaseDataset- Returns:
- an array containing the expression-based properties of this dataset
-
setFilterExpression
public void setFilterExpression(JRExpression expression)
Sets the dataset filter expression.The expression value class should be
java.lang.Boolean.- Parameters:
expression- the boolean expression to use as filter expression- See Also:
JRDataset.getFilterExpression()
-
clone
public Object clone()
- Specified by:
clonein interfaceJRCloneable- Overrides:
clonein classJRBaseDataset
-
-