Class JRFillDataset
- All Implemented Interfaces:
Cloneable,DatasetFillContext,JRCloneable,JRDataset,JRIdentifiable,JRPropertiesHolder
- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceprotected static classprotected static classprotected static classClass used to hold expression calculation requirements. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected JRCalculatorThe calculator used by the dataset.protected DatasetRecorderprotected JRDataSourceThe data source.protected JRAbstractScriptletprotected JRFillElementDataset[]The element datasets.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected JRFillField[]The dataset fields.protected Map<String, JRFillField> The dataset fields indexed by name.protected FillDatasetPositionprotected DatasetFilterprotected JRFillGroup[]The dataset groups.protected Map<String, JRFillGroup> The dataset groups indexed by name.protected LocaleTheLocaleto be used by the dataset.protected JRPropertiesMapprotected JRFillElementDataset[]Used to save the original element datasets whenfilterElementDatasetsis called.protected JRFillParameter[]The dataset parameters.protected Map<String, JRFillParameter> The dataset parameters indexed by name.protected List<DatasetPropertyExpression> protected JRQueryThe dataset query.protected intThe cursor used when iterating the data source.protected IntegerThe value of themax countparameter.protected ResourceBundleThe loaded resource bundle.protected StringThe resource bundle base name.protected StringThe scriptlet class name.protected List<JRAbstractScriptlet> The scriptlets used by the dataset.protected JRPropertiesMapprotected TimeZoneTheTimeZoneto be used by the dataset.protected Set<JRFillDataset.VariableCalculationReq> Set ofVariableCalculationReqobjects.protected JRFillVariable[]The dataset variables.protected Map<String, JRFillVariable> The dataset variables indexed by name.protected WhenResourceMissingTypeEnumThe resource missing handle type. -
Constructor Summary
ConstructorsConstructorDescriptionJRFillDataset(BaseReportFiller filler, JRDataset dataset, JRFillObjectFactory factory) Creates a fill dataset object. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddCacheRecordIndexCallback(int recordIndex, JRFillDataset.CacheRecordIndexCallback callback) protected voidaddVariableCalculationReq(String variableName, CalculationEnum calculation) Adds a variable calculation requirement.protected voidprotected booleanadvanceDataSource(boolean limit) protected voidcacheEnd()protected voidprotected voidprotected voidprotected voidprotected voidChecks if there are variable calculation requirements and creates the required variables.clone()voidCloses the data source used by this dataset if this data source was obtained via a query executer.protected voidvoidcontributeParameters(Map<String, Object> parameterValues) voidcreateCalculator(JasperReport jasperReport) Creates the calculatorprotected static JRCalculatorcreateCalculator(JasperReportsContext jasperReportsContext, JasperReport jasperReport, JRDataset dataset) protected List<JRAbstractScriptlet> createScriptlets(Map<String, Object> parameterValues) Creates the scriptlets.protected Localeprotected TimeZonevoidevaluateExpression(JRExpression expression, byte evaluation) Evaluates an expressionvoidprotected voidevaluateProperties(PropertyEvaluationTimeEnum evaluationTime) protected voidfilterElementDatasets(JRFillElementDataset elementDataset) Filters the element datasets, leaving only one.protected ParameterEvaluationTimeEnumprotected PropertyEvaluationTimeEnumJRField[]Returns the dataset's fields.getFieldValue(String fieldName) Returns the value of a field.getFieldValue(String fieldName, EvaluationType evaluation) Returns the value of a field.getFillField(String fieldName) getFillVariable(String variableName) Returns the dataset filter expression.JRGroup[]Returns the dataset's groups.Returns the locale used by the dataset.getName()Returns the dataset name.Returns the dataset's parameters.getParameterValue(String parameterName) Returns the value of a parameter.getParameterValue(String parameterName, boolean ignoreMissing) Returns the value of a parameter.Returns the map of parameter values.Returns the parent properties holder, whose properties are used as defaults for this object.Returns this object's properties map.Returns the list of dynamic/expression-based properties for this dataset.getQuery()Returns the query of the dataset.Returns the resource bundle base name.The name of the scriptlet class to be used when iterating this dataset.Returns the dataset's scriptlets.Returns the dataset's sort fields.getUUID()getVariable(String variableName) Returns the dataset's variables.getVariableValue(String variableName) Returns the value of a variable.getVariableValue(String variableName, EvaluationType evaluation) Returns the value of a variable.Returns the resource missing handling type.booleanChecks whether the object has any properties.voidInherits properties from the report.voidInitializes the calculator.voidInitializes the data source which will be used by this dataset.protected voidinitElementDatasets(JRFillObjectFactory factory) Initializes the element datasets.protected booleanisIncludedInDataCache(JRFillParameter parameter) booleanDecides whether this dataset is the main report dataset or a sub dataset.booleanprotected ResourceBundleLoads the resource bundle corresponding to the resource bundle base name and locale.booleannext()Moves to the next record in the data source.protected booleannext(boolean sorting) Moves to the next record in the data source.protected voidreset()protected voidprotected voidRestores the original element datasets.protected voidprotected voidvoidsetCacheRecordIndex(FillDatasetPosition position, byte evaluationType) voidsetCacheSkipped(boolean cacheSkipped) protected voidsetCalculator(JRCalculator calculator) voidsetConnectionParameterValue(Map<String, Object> parameterValues, Connection conn) Sets the JDBC connection to be used.voidsetDatasourceParameterValue(Map<String, Object> parameterValues, JRDataSource ds) Sets the data source to be used.voidsetFillPosition(FillDatasetPosition fillPosition) voidsetJasperReportsContext(JasperReportsContext jasperReportsContext) protected voidvoidsetParameter(String parameterName, Object value) Sets the value of a parameter.protected voidsetParameter(JRFillParameter parameter, Object value) Sets the value of the parameter.voidsetParameterValues(Map<String, Object> parameterValues) Reads built-in parameter values from the value map.voidsetRepositoryContext(RepositoryContext repositoryContext) voidsetWhenResourceMissingType(WhenResourceMissingTypeEnum whenResourceMissingType) Sets the resource missing handling type.voidstart()Starts the iteration on the data source.
-
Field Details
-
EXCEPTION_MESSAGE_KEY_NO_SUCH_FIELD
- See Also:
-
EXCEPTION_MESSAGE_KEY_NO_SUCH_PARAMETER
- See Also:
-
EXCEPTION_MESSAGE_KEY_NO_SUCH_SNAPSHOT_DATA
- See Also:
-
EXCEPTION_MESSAGE_KEY_NO_SUCH_SNAPSHOT_PARAMETER
- See Also:
-
EXCEPTION_MESSAGE_KEY_NO_SUCH_VARIABLE
- See Also:
-
query
The dataset query. -
parameters
The dataset parameters. -
parametersMap
The dataset parameters indexed by name. -
fields
The dataset fields. -
fieldsMap
The dataset fields indexed by name. -
variables
The dataset variables. -
variablesMap
The dataset variables indexed by name. -
variableCalculationReqs
Set ofVariableCalculationReqobjects. -
elementDatasets
The element datasets. -
origElementDatasets
Used to save the original element datasets whenfilterElementDatasetsis called. -
groups
The dataset groups. -
groupsMap
The dataset groups indexed by name. -
resourceBundleBaseName
The resource bundle base name. -
whenResourceMissingType
The resource missing handle type. -
scriptletClassName
The scriptlet class name. -
dataSource
The data source. -
locale
TheLocaleto be used by the dataset. -
resourceBundle
The loaded resource bundle. -
timeZone
TheTimeZoneto be used by the dataset. -
reportCount
protected int reportCountThe cursor used when iterating the data source. -
calculator
The calculator used by the dataset. -
scriptlets
The scriptlets used by the dataset. -
propertyExpressions
-
staticProperties
-
mergedProperties
-
delegateScriptlet
-
reportMaxCount
The value of themax countparameter. -
filter
-
fillPosition
-
dataRecorder
-
-
Constructor Details
-
JRFillDataset
Creates a fill dataset object.- Parameters:
filler- the fillerdataset- the template datasetfactory- the fill object factory
-
-
Method Details
-
getFiller
-
createCalculator
Creates the calculator- Parameters:
jasperReport- the report- Throws:
JRException
-
setCalculator
-
createCalculator
protected static JRCalculator createCalculator(JasperReportsContext jasperReportsContext, JasperReport jasperReport, JRDataset dataset) throws JRException - Throws:
JRException
-
initCalculator
Initializes the calculator.- Throws:
JRException
-
inheritFromMain
public void inheritFromMain()Inherits properties from the report. -
createScriptlets
protected List<JRAbstractScriptlet> createScriptlets(Map<String, Object> parameterValues) throws JRExceptionCreates the scriptlets.- Returns:
- the scriptlets list
- Throws:
JRException
-
initElementDatasets
Initializes the element datasets.- Parameters:
factory- the fill object factory used by the filler
-
filterElementDatasets
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
Loads the resource bundle corresponding to the resource bundle base name and locale. -
setParameterValues
Reads built-in parameter values from the value map.- Parameters:
parameterValues- the parameter values- Throws:
JRException
-
defaultLocale
-
defaultTimeZone
-
initDatasource
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() -
getFillPosition
-
setFillPosition
-
setCacheSkipped
public void setCacheSkipped(boolean cacheSkipped) -
cacheInit
- Throws:
DataSnapshotException
-
cacheInitSnapshot
- Throws:
DataSnapshotException
-
cacheInitRecording
protected void cacheInitRecording() -
isIncludedInDataCache
-
getDefaultParameterEvaluationTime
-
getDefaultPropertyEvaluationTime
-
cacheRecord
protected void cacheRecord() -
cacheEnd
protected void cacheEnd() -
evaluateFieldProperties
- Throws:
JRException
-
contributeParameters
- Throws:
JRException
-
setJasperReportsContext
-
setRepositoryContext
-
getJasperReportsContext
-
getRepositoryContext
-
disposeParameterContributors
public void disposeParameterContributors() -
getParameterValuesMap
Returns the map of parameter values.- Returns:
- the map of parameter values
-
reset
protected void reset() -
setDatasourceParameterValue
Sets the data source to be used.- Parameters:
parameterValues- the parameter valuesds- the data source
-
setConnectionParameterValue
Sets the JDBC connection to be used.- Parameters:
parameterValues- the parameter valuesconn- 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:
-
closeQueryExecuter
protected void closeQueryExecuter() -
start
public void start()Starts the iteration on the data source. -
resetVariables
protected void resetVariables() -
next
Moves to the next record in the data source.- Returns:
trueif the data source was not exhausted- Throws:
JRException
-
next
Moves to the next record in the data source.- Parameters:
sorting- whether the method is called as part of the data sorting phase- Returns:
trueif the data source was not exhausted- Throws:
JRException
-
advanceCacheRecordIndexes
protected void advanceCacheRecordIndexes() -
setOldValues
- Throws:
JRException
-
revertToOldValues
protected void revertToOldValues() -
revertVariablesToOldValues
protected void revertVariablesToOldValues() -
advanceDataSource
- Throws:
JRException
-
setParameter
Sets the value of a parameter.- Parameters:
parameterName- the parameter namevalue- the value- Throws:
JRException
-
setParameter
Sets the value of the parameter.- Parameters:
parameter- the parametervalue- the value- Throws:
JRException
-
getVariable
-
getVariableValue
Returns the value of a variable.- Parameters:
variableName- the variable name- Returns:
- the variable value
-
getVariableValue
Description copied from interface:DatasetFillContextReturns the value of a variable.- Specified by:
getVariableValuein interfaceDatasetFillContext- Parameters:
variableName- the variable nameevaluation- the evaluation type- Returns:
- the variable value
-
getFillVariable
-
getParameterValue
Returns the value of a parameter.- Specified by:
getParameterValuein interfaceDatasetFillContext- Parameters:
parameterName- the parameter name- Returns:
- the parameter value
-
getParameterValue
Returns the value of a parameter.- Parameters:
parameterName- the parameter nameignoreMissing- if set,nullwill be returned for inexisting parameters- Returns:
- the parameter value
-
getFieldValue
Returns the value of a field.- Parameters:
fieldName- the field name- Returns:
- the field value
-
getFieldValue
Description copied from interface:DatasetFillContextReturns the value of a field.- Specified by:
getFieldValuein interfaceDatasetFillContext- Parameters:
fieldName- the field nameevaluation- the evaluation type- Returns:
- the field value
-
getFillField
-
addVariableCalculationReq
Adds a variable calculation requirement.- Parameters:
variableName- the variable namecalculation- the required calculation
-
checkVariableCalculationReqs
Checks if there are variable calculation requirements and creates the required variables.- Parameters:
factory- the fill object factory
-
getUUID
- Specified by:
getUUIDin interfaceJRIdentifiable
-
getName
Description copied from interface:JRDatasetReturns the dataset name. -
getScriptletClass
Description copied from interface:JRDatasetThe name of the scriptlet class to be used when iterating this dataset.- Specified by:
getScriptletClassin interfaceJRDataset- Returns:
- the scriplet class name
-
getScriptlets
Description copied from interface:JRDatasetReturns the dataset's scriptlets.- Specified by:
getScriptletsin interfaceJRDataset- Returns:
- the dataset's scriptlets
-
getParameters
Description copied from interface:JRDatasetReturns the dataset's parameters.- Specified by:
getParametersin interfaceJRDataset- Returns:
- the dataset's parameters
-
getParametersMap
-
getQuery
Description copied from interface:JRDatasetReturns the query of the dataset.The query is used by passing a connection is passed to the dataset when instantiating.
-
getFields
Description copied from interface:JRDatasetReturns the dataset's fields. -
getFieldsMap
-
getSortFields
Description copied from interface:JRDatasetReturns the dataset's sort fields.- Specified by:
getSortFieldsin interfaceJRDataset- Returns:
- the dataset's sort fields
-
getVariables
Description copied from interface:JRDatasetReturns the dataset's variables.- Specified by:
getVariablesin interfaceJRDataset- Returns:
- the dataset's variables
-
getVariablesMap
-
getGroups
Description copied from interface:JRDatasetReturns the dataset's groups. -
isMainDataset
public boolean isMainDataset()Description copied from interface:JRDatasetDecides whether this dataset is the main report dataset or a sub dataset.- Specified by:
isMainDatasetin interfaceJRDataset- Returns:
trueif and only if this dataset is the main report dataset
-
getResourceBundle
Description copied from interface:JRDatasetReturns the resource bundle base name.The resource bundle is used when evaluating expressions.
- Specified by:
getResourceBundlein interfaceJRDataset- Returns:
- the resource bundle base name
-
getWhenResourceMissingType
Description copied from interface:JRDatasetReturns the resource missing handling type.- Specified by:
getWhenResourceMissingTypein interfaceJRDataset- Returns:
- the resource missing handling type
-
setWhenResourceMissingType
Description copied from interface:JRDatasetSets the resource missing handling type.- Specified by:
setWhenResourceMissingTypein interfaceJRDataset- Parameters:
whenResourceMissingType- the resource missing handling type
-
hasProperties
public boolean hasProperties()Description copied from interface:JRPropertiesHolderChecks whether the object has any properties.- Specified by:
hasPropertiesin interfaceJRPropertiesHolder- Returns:
- whether the object has any properties
-
getPropertiesMap
Description copied from interface:JRPropertiesHolderReturns this object's properties map.- Specified by:
getPropertiesMapin interfaceJRPropertiesHolder- Returns:
- this object's properties map
-
getParentProperties
Description copied from interface:JRPropertiesHolderReturns the parent properties holder, whose properties are used as defaults for this object.- Specified by:
getParentPropertiesin interfaceJRPropertiesHolder- Returns:
- the parent properties holder, or
nullif no parent
-
getPropertyExpressions
Description copied from interface:JRDatasetReturns the list of dynamic/expression-based properties for this dataset.- Specified by:
getPropertyExpressionsin interfaceJRDataset- Returns:
- an array containing the expression-based properties of this dataset
-
evaluateProperties
- Throws:
JRException
-
getFilterExpression
Description copied from interface:JRDatasetReturns the dataset filter expression.This expression is used to filter the rows of the
data sourcethat this dataset will iterate on.This expression (if not null) is evaluated immediately after a new row is
producedby the data source. The evaluation is performed using field and variable values corresponding to the new row. When the result of the evaluation isBoolean.TRUEthe row gets processed by the report filling engine. When the result is null orBoolean.FALSE, the current row will be skipped and the datasource will be asked for the next row.- Specified by:
getFilterExpressionin interfaceJRDataset- Returns:
- the dataset filter expression
-
clone
- Specified by:
clonein interfaceJRCloneable- Overrides:
clonein classObject
-
evaluateExpression
Evaluates an expression- Parameters:
expression- the expressionevaluation- the evaluation type- Returns:
- the evaluation result
- Throws:
JRException
-
getLocale
Description copied from interface:DatasetFillContextReturns the locale used by the dataset.- Specified by:
getLocalein interfaceDatasetFillContext
-
getTimeZone
-
getDatasetPosition
-
addCacheRecordIndexCallback
protected void addCacheRecordIndexCallback(int recordIndex, JRFillDataset.CacheRecordIndexCallback callback) -
setCacheRecordIndex
-