Class JRFillDataset

    • Field Detail

      • EXCEPTION_MESSAGE_KEY_NO_SUCH_FIELD

        public static final java.lang.String EXCEPTION_MESSAGE_KEY_NO_SUCH_FIELD
        See Also:
        Constant Field Values
      • EXCEPTION_MESSAGE_KEY_NO_SUCH_PARAMETER

        public static final java.lang.String EXCEPTION_MESSAGE_KEY_NO_SUCH_PARAMETER
        See Also:
        Constant Field Values
      • EXCEPTION_MESSAGE_KEY_NO_SUCH_SNAPSHOT_DATA

        public static final java.lang.String EXCEPTION_MESSAGE_KEY_NO_SUCH_SNAPSHOT_DATA
        See Also:
        Constant Field Values
      • EXCEPTION_MESSAGE_KEY_NO_SUCH_SNAPSHOT_PARAMETER

        public static final java.lang.String EXCEPTION_MESSAGE_KEY_NO_SUCH_SNAPSHOT_PARAMETER
        See Also:
        Constant Field Values
      • EXCEPTION_MESSAGE_KEY_NO_SUCH_VARIABLE

        public static final java.lang.String EXCEPTION_MESSAGE_KEY_NO_SUCH_VARIABLE
        See Also:
        Constant Field Values
      • query

        protected JRQuery query
        The dataset query.
      • parameters

        protected JRFillParameter[] parameters
        The dataset parameters.
      • parametersMap

        protected java.util.Map<java.lang.String,​JRFillParameter> parametersMap
        The dataset parameters indexed by name.
      • fields

        protected JRFillField[] fields
        The dataset fields.
      • fieldsMap

        protected java.util.Map<java.lang.String,​JRFillField> fieldsMap
        The dataset fields indexed by name.
      • variables

        protected JRFillVariable[] variables
        The dataset variables.
      • variablesMap

        protected java.util.Map<java.lang.String,​JRFillVariable> variablesMap
        The dataset variables indexed by name.
      • groups

        protected JRFillGroup[] groups
        The dataset groups.
      • resourceBundleBaseName

        protected java.lang.String resourceBundleBaseName
        The resource bundle base name.
      • scriptletClassName

        protected java.lang.String scriptletClassName
        The scriptlet class name.
      • dataSource

        protected JRDataSource dataSource
        The data source.
      • locale

        protected java.util.Locale locale
        The Locale to be used by the dataset.
      • resourceBundle

        protected java.util.ResourceBundle resourceBundle
        The loaded resource bundle.
      • timeZone

        protected java.util.TimeZone timeZone
        The TimeZone to be used by the dataset.
      • reportCount

        protected int reportCount
        The cursor used when iterating the data source.
      • calculator

        protected JRCalculator calculator
        The calculator used by the dataset.
      • scriptlets

        protected java.util.List<JRAbstractScriptlet> scriptlets
        The scriptlets used by the dataset.
      • reportMaxCount

        protected java.lang.Integer reportMaxCount
        The value of the max count parameter.
    • Constructor Detail

      • JRFillDataset

        public JRFillDataset​(BaseReportFiller filler,
                             JRDataset dataset,
                             JRFillObjectFactory factory)
        Creates a fill dataset object.
        Parameters:
        filler - the filler
        dataset - the template dataset
        factory - the fill object factory
    • Method Detail

      • createCalculator

        public void createCalculator​(JasperReport jasperReport)
                              throws JRException
        Creates the calculator
        Parameters:
        jasperReport - the report
        Throws:
        JRException
      • setCalculator

        protected void setCalculator​(JRCalculator calculator)
      • initCalculator

        public void initCalculator()
                            throws JRException
        Initializes the calculator.
        Throws:
        JRException
      • inheritFromMain

        public void inheritFromMain()
        Inherits properties from the report.
      • createScriptlets

        protected java.util.List<JRAbstractScriptlet> createScriptlets​(java.util.Map<java.lang.String,​java.lang.Object> parameterValues)
                                                                throws JRException
        Creates the scriptlets.
        Returns:
        the scriptlets list
        Throws:
        JRException
      • initElementDatasets

        protected void initElementDatasets​(JRFillObjectFactory factory)
        Initializes the element datasets.
        Parameters:
        factory - the fill object factory used by the filler
      • filterElementDatasets

        protected void filterElementDatasets​(JRFillElementDataset elementDataset)
        Filters the element datasets, leaving only one.

        This method is used when a dataset is instantiated by a chart or crosstab.

        Parameters:
        elementDataset - the element dataset that should remain
      • restoreElementDatasets

        protected void restoreElementDatasets()
        Restores the original element datasets.

        This method should be called after filterElementDatasets.

      • loadResourceBundle

        protected java.util.ResourceBundle loadResourceBundle()
        Loads the resource bundle corresponding to the resource bundle base name and locale.
      • setParameterValues

        public void setParameterValues​(java.util.Map<java.lang.String,​java.lang.Object> parameterValues)
                                throws JRException
        Reads built-in parameter values from the value map.
        Parameters:
        parameterValues - the parameter values
        Throws:
        JRException
      • defaultLocale

        protected java.util.Locale defaultLocale()
      • defaultTimeZone

        protected java.util.TimeZone defaultTimeZone()
      • initDatasource

        public void initDatasource()
                            throws JRException
        Initializes the data source which will be used by this dataset. If the dataset includes a query, this involves invoking the appropriate query executer to execute the query and create a data source from the results.
        Throws:
        JRException
      • isSortingData

        public boolean isSortingData()
      • setCacheSkipped

        public void setCacheSkipped​(boolean cacheSkipped)
      • cacheInitRecording

        protected void cacheInitRecording()
      • isIncludedInDataCache

        protected boolean isIncludedInDataCache​(JRFillParameter parameter)
      • cacheRecord

        protected void cacheRecord()
      • cacheEnd

        protected void cacheEnd()
      • contributeParameters

        public void contributeParameters​(java.util.Map<java.lang.String,​java.lang.Object> parameterValues)
                                  throws JRException
        Throws:
        JRException
      • setJasperReportsContext

        public void setJasperReportsContext​(JasperReportsContext jasperReportsContext)
      • setRepositoryContext

        public void setRepositoryContext​(RepositoryContext repositoryContext)
      • disposeParameterContributors

        public void disposeParameterContributors()
      • getParameterValuesMap

        protected java.util.Map<java.lang.String,​java.lang.Object> getParameterValuesMap()
        Returns the map of parameter values.
        Returns:
        the map of parameter values
      • reset

        protected void reset()
      • setDatasourceParameterValue

        public void setDatasourceParameterValue​(java.util.Map<java.lang.String,​java.lang.Object> parameterValues,
                                                JRDataSource ds)
        Sets the data source to be used.
        Parameters:
        parameterValues - the parameter values
        ds - the data source
      • setConnectionParameterValue

        public void setConnectionParameterValue​(java.util.Map<java.lang.String,​java.lang.Object> parameterValues,
                                                java.sql.Connection conn)
        Sets the JDBC connection to be used.
        Parameters:
        parameterValues - the parameter values
        conn - the connection
      • closeDatasource

        public void closeDatasource()
        Closes the data source used by this dataset if this data source was obtained via a query executer.
        See Also:
        JRQueryExecuter.close()
      • closeQueryExecuter

        protected void closeQueryExecuter()
      • start

        public void start()
        Starts the iteration on the data source.
      • resetVariables

        protected void resetVariables()
      • next

        public boolean next()
                     throws JRException
        Moves to the next record in the data source.
        Returns:
        true if the data source was not exhausted
        Throws:
        JRException
      • next

        protected boolean next​(boolean sorting)
                        throws JRException
        Moves to the next record in the data source.
        Parameters:
        sorting - whether the method is called as part of the data sorting phase
        Returns:
        true if the data source was not exhausted
        Throws:
        JRException
      • advanceCacheRecordIndexes

        protected void advanceCacheRecordIndexes()
      • revertToOldValues

        protected void revertToOldValues()
      • revertVariablesToOldValues

        protected void revertVariablesToOldValues()
      • advanceDataSource

        protected boolean advanceDataSource​(boolean limit)
                                     throws JRException
        Throws:
        JRException
      • setParameter

        public void setParameter​(java.lang.String parameterName,
                                 java.lang.Object value)
                          throws JRException
        Sets the value of a parameter.
        Parameters:
        parameterName - the parameter name
        value - the value
        Throws:
        JRException
      • setParameter

        protected void setParameter​(JRFillParameter parameter,
                                    java.lang.Object value)
                             throws JRException
        Sets the value of the parameter.
        Parameters:
        parameter - the parameter
        value - the value
        Throws:
        JRException
      • getVariable

        public JRFillVariable getVariable​(java.lang.String variableName)
      • getVariableValue

        public java.lang.Object getVariableValue​(java.lang.String variableName)
        Returns the value of a variable.
        Parameters:
        variableName - the variable name
        Returns:
        the variable value
      • getVariableValue

        public java.lang.Object getVariableValue​(java.lang.String variableName,
                                                 EvaluationType evaluation)
        Description copied from interface: DatasetFillContext
        Returns the value of a variable.
        Specified by:
        getVariableValue in interface DatasetFillContext
        Parameters:
        variableName - the variable name
        evaluation - the evaluation type
        Returns:
        the variable value
      • getFillVariable

        public JRFillVariable getFillVariable​(java.lang.String variableName)
      • getParameterValue

        public java.lang.Object getParameterValue​(java.lang.String parameterName)
        Returns the value of a parameter.
        Specified by:
        getParameterValue in interface DatasetFillContext
        Parameters:
        parameterName - the parameter name
        Returns:
        the parameter value
      • getParameterValue

        public java.lang.Object getParameterValue​(java.lang.String parameterName,
                                                  boolean ignoreMissing)
        Returns the value of a parameter.
        Parameters:
        parameterName - the parameter name
        ignoreMissing - if set, null will be returned for inexisting parameters
        Returns:
        the parameter value
      • getFieldValue

        public java.lang.Object getFieldValue​(java.lang.String fieldName)
        Returns the value of a field.
        Parameters:
        fieldName - the field name
        Returns:
        the field value
      • getFieldValue

        public java.lang.Object getFieldValue​(java.lang.String fieldName,
                                              EvaluationType evaluation)
        Description copied from interface: DatasetFillContext
        Returns the value of a field.
        Specified by:
        getFieldValue in interface DatasetFillContext
        Parameters:
        fieldName - the field name
        evaluation - the evaluation type
        Returns:
        the field value
      • getFillField

        public JRFillField getFillField​(java.lang.String fieldName)
      • addVariableCalculationReq

        protected void addVariableCalculationReq​(java.lang.String variableName,
                                                 CalculationEnum calculation)
        Adds a variable calculation requirement.
        Parameters:
        variableName - the variable name
        calculation - the required calculation
      • checkVariableCalculationReqs

        protected void checkVariableCalculationReqs​(JRFillObjectFactory factory)
        Checks if there are variable calculation requirements and creates the required variables.
        Parameters:
        factory - the fill object factory
      • getName

        public java.lang.String getName()
        Description copied from interface: JRDataset
        Returns the dataset name.
        Specified by:
        getName in interface JRDataset
        Returns:
        the name of the dataset
      • getScriptletClass

        public java.lang.String getScriptletClass()
        Description copied from interface: JRDataset
        The name of the scriptlet class to be used when iterating this dataset.
        Specified by:
        getScriptletClass in interface JRDataset
        Returns:
        the scriplet class name
      • getScriptlets

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

        public JRParameter[] getParameters()
        Description copied from interface: JRDataset
        Returns the dataset's parameters.
        Specified by:
        getParameters in interface JRDataset
        Returns:
        the dataset's parameters
      • getParametersMap

        public java.util.Map<java.lang.String,​JRFillParameter> getParametersMap()
      • getQuery

        public JRQuery getQuery()
        Description copied from interface: JRDataset
        Returns the query of the dataset.

        The query is used by passing a connection is passed to the dataset when instantiating.

        Specified by:
        getQuery in interface JRDataset
        Returns:
        the query of the dataset
      • getFields

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

        public java.util.Map<java.lang.String,​JRFillField> getFieldsMap()
      • getSortFields

        public JRSortField[] getSortFields()
        Description copied from interface: JRDataset
        Returns the dataset's sort fields.
        Specified by:
        getSortFields in interface JRDataset
        Returns:
        the dataset's sort fields
      • getVariables

        public JRVariable[] getVariables()
        Description copied from interface: JRDataset
        Returns the dataset's variables.
        Specified by:
        getVariables in interface JRDataset
        Returns:
        the dataset's variables
      • getVariablesMap

        public java.util.Map<java.lang.String,​JRFillVariable> getVariablesMap()
      • getGroups

        public JRGroup[] getGroups()
        Description copied from interface: JRDataset
        Returns the dataset's groups.
        Specified by:
        getGroups in interface JRDataset
        Returns:
        the dataset's groups
      • isMainDataset

        public boolean isMainDataset()
        Description copied from interface: JRDataset
        Decides whether this dataset is the main report dataset or a sub dataset.
        Specified by:
        isMainDataset in interface JRDataset
        Returns:
        true if and only if this dataset is the main report dataset
      • getResourceBundle

        public java.lang.String getResourceBundle()
        Description copied from interface: JRDataset
        Returns the resource bundle base name.

        The resource bundle is used when evaluating expressions.

        Specified by:
        getResourceBundle in interface JRDataset
        Returns:
        the resource bundle base name
      • hasProperties

        public boolean hasProperties()
        Description copied from interface: JRPropertiesHolder
        Checks whether the object has any properties.
        Specified by:
        hasProperties in interface JRPropertiesHolder
        Returns:
        whether the object has any properties
      • 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
        Returns:
        an array containing the expression-based properties of this dataset
      • getFilterExpression

        public JRExpression getFilterExpression()
        Description copied from interface: JRDataset
        Returns the dataset filter expression.

        This expression is used to filter the rows of the data source that this dataset will iterate on.

        This expression (if not null) is evaluated immediately after a new row is produced by the data source. The evaluation is performed using field and variable values corresponding to the new row. When the result of the evaluation is Boolean.TRUE the row gets processed by the report filling engine. When the result is null or Boolean.FALSE, the current row will be skipped and the datasource will be asked for the next row.

        Specified by:
        getFilterExpression in interface JRDataset
        Returns:
        the dataset filter expression
      • clone

        public java.lang.Object clone()
        Specified by:
        clone in interface JRCloneable
        Overrides:
        clone in class java.lang.Object
      • evaluateExpression

        public java.lang.Object evaluateExpression​(JRExpression expression,
                                                   byte evaluation)
                                            throws JRException
        Evaluates an expression
        Parameters:
        expression - the expression
        evaluation - the evaluation type
        Returns:
        the evaluation result
        Throws:
        JRException
      • getTimeZone

        public java.util.TimeZone getTimeZone()
      • setCacheRecordIndex

        public void setCacheRecordIndex​(FillDatasetPosition position,
                                        byte evaluationType)