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 of JRDataset to be used for report design.
Author:
Lucian Chirita (lucianc@users.sourceforge.net)
See Also:
  • Field Details

  • Constructor Details

    • 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:
    • 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:
  • Method Details

    • 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:
    • setName

      public void setName(String name)
      Sets the name of the dataset.
      Parameters:
      name - the name of the dataset
      See Also:
    • getScriptlets

      public JRScriptlet[] getScriptlets()
      Description copied from interface: JRDataset
      Returns the dataset's scriptlets.
      Specified by:
      getScriptlets in interface JRDataset
      Overrides:
      getScriptlets in class JRBaseDataset
      Returns:
      the dataset's scriptlets
    • getScriptletsList

      public List<JRScriptlet> getScriptletsList()
      Returns the list of scriptlets, excluding the scriptletClass one.
      Returns:
      list of JRScriptlet objects
    • setScriptlets

      protected void setScriptlets(List<JRScriptlet> scriptlets)
    • getScriptletsMap

      public Map<String,JRScriptlet> getScriptletsMap()
      Returns the map of scriptlets, excluding the scriptletClass one, indexed by name.
      Returns:
      JRScriptlet objects 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:
    • addScriptlet

      public void addScriptlet(int index, JRScriptlet scriptlet) throws JRException
      Inserts a scriptlet at the specified position into the dataset.
      Parameters:
      index - the scriptlet position
      scriptlet - the scriptlet to insert
      Throws:
      JRException
      See Also:
    • removeScriptlet

      public JRScriptlet removeScriptlet(String scriptletName)
      Removes a scriptlet from the dataset.
      Parameters:
      scriptletName - the scriptlet name
      Returns:
      the removed scriptlet, or null if 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: JRDataset
      Returns the dataset's parameters.
      Specified by:
      getParameters in interface JRDataset
      Overrides:
      getParameters in class JRBaseDataset
      Returns:
      the dataset's parameters
    • getParametersList

      public List<JRParameter> getParametersList()
      Returns the list of parameters, including build-in ones.
      Returns:
      list of JRParameter objects
    • setParameters

      protected void setParameters(List<JRParameter> parameters) throws JRException
      Throws:
      JRException
    • getParametersMap

      public Map<String,JRParameter> getParametersMap()
      Returns the map of parameters, including build-in ones, indexed by name.
      Returns:
      JRParameter objects 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:
    • addParameter

      public void addParameter(int index, JRParameter parameter) throws JRException
      Inserts a parameter at the specified position into the dataset.
      Parameters:
      index - the parameter position
      parameter - the parameter to insert
      Throws:
      JRException
      See Also:
    • removeParameter

      public JRParameter removeParameter(String parameterName)
      Removes a parameter from the dataset.
      Parameters:
      parameterName - the parameter name
      Returns:
      the removed parameter, or null if 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:
    • 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:
    • getFields

      public JRField[] getFields()
      Description copied from interface: JRDataset
      Returns the dataset's fields.
      Specified by:
      getFields in interface JRDataset
      Overrides:
      getFields in class JRBaseDataset
      Returns:
      the dataset's fields
    • getFieldsList

      public List<JRField> getFieldsList()
      Returns the list of fields.
      Returns:
      list of JRField objects
    • setFields

      protected void setFields(List<JRField> fields) throws JRException
      Throws:
      JRException
    • getFieldsMap

      public Map<String,JRField> getFieldsMap()
      Returns the map of fields indexed by name.
      Returns:
      JRField objects 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:
    • addField

      public void addField(int index, JRField field) throws JRException
      Inserts a field at the specified position into the dataset.
      Parameters:
      index - the field position
      field - the field to insert
      Throws:
      JRException
      See Also:
    • removeField

      public JRField removeField(String fieldName)
      Removes a field from the dataset.
      Parameters:
      fieldName - the field name
      Returns:
      the removed field, or null if 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: JRDataset
      Returns the dataset's sort fields.
      Specified by:
      getSortFields in interface JRDataset
      Overrides:
      getSortFields in class JRBaseDataset
      Returns:
      the dataset's sort fields
    • getSortFieldsList

      public List<JRSortField> getSortFieldsList()
      Returns the list of sort fields.
      Returns:
      list of JRSortField objects
    • setSortFields

      protected void setSortFields(List<JRSortField> sortFields) throws JRException
      Throws:
      JRException
    • getSortFieldsMap

      public Map<String,JRSortField> getSortFieldsMap()
      Returns the map of sort fields indexed by name and type.
      Returns:
      JRField objects 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:
    • addSortField

      public void addSortField(int index, JRSortField sortField) throws JRException
      Inserts a sort field at specified position into the dataset.
      Parameters:
      index - the sort field position
      sortField - the sort field to insert
      Throws:
      JRException
      See Also:
    • 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: JRDataset
      Returns the dataset's variables.
      Specified by:
      getVariables in interface JRDataset
      Overrides:
      getVariables in class JRBaseDataset
      Returns:
      the dataset's variables
    • getVariablesList

      public List<JRVariable> getVariablesList()
      Returns the list of variables, including build-in ones.
      Returns:
      list of JRVariable objects
    • setVariables

      protected void setVariables(List<JRDesignVariable> variables) throws JRException
      Throws:
      JRException
    • getVariablesMap

      public Map<String,JRVariable> getVariablesMap()
      Returns the map of variable, including build-in ones, indexed by name.
      Returns:
      JRVariable objects 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:
    • addVariable

      public void addVariable(int index, JRDesignVariable variable) throws JRException
      Inserts a variable at specified position into the dataset.
      Parameters:
      index - the variable position
      variable - the variable to insert
      Throws:
      JRException
      See Also:
    • addVariable

      protected void addVariable(JRDesignVariable variable, boolean system) throws JRException
      Adds a variable to the dataset.
      Parameters:
      variable - the variable to add
      system - 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 JRException
      Inserts a variable at specified position into the dataset.
      Parameters:
      index - the variable position
      variable - the variable to insert
      system - 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 null if 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: JRDataset
      Returns the dataset's groups.
      Specified by:
      getGroups in interface JRDataset
      Overrides:
      getGroups in class JRBaseDataset
      Returns:
      the dataset's groups
    • getGroupsList

      public List<JRGroup> getGroupsList()
      Returns the list of groups.
      Returns:
      list of JRGroup objects
    • setGroups

      protected void setGroups(List<JRDesignGroup> groups) throws JRException
      Throws:
      JRException
    • getGroupsMap

      public Map<String,JRGroup> getGroupsMap()
      Returns the map of groups indexed by name.
      Returns:
      JRGroup objects 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:
    • addGroup

      public void addGroup(int index, JRDesignGroup group) throws JRException
      Inserts a group at the specified position into the dataset.
      Parameters:
      index - the group position
      group - the group to insert
      Throws:
      JRException
      See Also:
    • removeGroup

      public JRGroup removeGroup(String groupName)
      Removes a group from the dataset.
      Parameters:
      groupName - the group name
      Returns:
      the removed group, or null if 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
    • queryLanguageChanged

      protected void queryLanguageChanged(String oldLanguage, String newLanguage)
    • setProperty

      public void setProperty(String propName, String value)
      Adds/sets a property value.
      Parameters:
      propName - the name of the property
      value - 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:
    • removePropertyExpression

      public void removePropertyExpression(DatasetPropertyExpression propertyExpression)
      Remove a property expression.
      Parameters:
      propertyExpression - the property expression to remove
      See Also:
    • 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 (DatasetPropertyExpression instances)
      See Also:
    • getPropertyExpressions

      public DatasetPropertyExpression[] getPropertyExpressions()
      Description copied from interface: JRDataset
      Returns the list of dynamic/expression-based properties for this dataset.
      Specified by:
      getPropertyExpressions in interface JRDataset
      Overrides:
      getPropertyExpressions in class JRBaseDataset
      Returns:
      an array containing the expression-based properties of this dataset
    • setPropertyExpressions

      protected void setPropertyExpressions(List<DatasetPropertyExpression> properties)
    • 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:
    • clone

      public Object clone()
      Specified by:
      clone in interface JRCloneable
      Overrides:
      clone in class JRBaseDataset