public class JRFillDataset extends Object implements JRDataset, DatasetFillContext
Modifier and Type | Class and Description |
---|---|
protected static interface |
JRFillDataset.CacheRecordIndexCallback |
protected static class |
JRFillDataset.CacheRecordIndexChainedCallback |
protected static class |
JRFillDataset.FillDatasetPositionRecordIndexCallback |
protected static class |
JRFillDataset.VariableCalculationReq
Class used to hold expression calculation requirements.
|
Modifier and Type | Field and Description |
---|---|
protected JRCalculator |
calculator
The calculator used by the dataset.
|
protected DatasetRecorder |
dataRecorder |
protected JRDataSource |
dataSource
The data source.
|
protected JRAbstractScriptlet |
delegateScriptlet |
protected JRFillElementDataset[] |
elementDatasets
The element datasets.
|
static String |
EXCEPTION_MESSAGE_KEY_NO_SUCH_FIELD |
static String |
EXCEPTION_MESSAGE_KEY_NO_SUCH_PARAMETER |
static String |
EXCEPTION_MESSAGE_KEY_NO_SUCH_SNAPSHOT_DATA |
static String |
EXCEPTION_MESSAGE_KEY_NO_SUCH_SNAPSHOT_PARAMETER |
static String |
EXCEPTION_MESSAGE_KEY_NO_SUCH_VARIABLE |
protected JRFillField[] |
fields
The dataset fields.
|
protected Map<String,JRFillField> |
fieldsMap
The dataset fields indexed by name.
|
protected FillDatasetPosition |
fillPosition |
protected DatasetFilter |
filter |
protected JRFillGroup[] |
groups
The dataset groups.
|
protected Locale |
locale
The
Locale to be used by the dataset. |
protected JRPropertiesMap |
mergedProperties |
protected JRFillElementDataset[] |
origElementDatasets
Used to save the original element datasets when
filterElementDatasets is called. |
protected JRFillParameter[] |
parameters
The dataset parameters.
|
protected Map<String,JRFillParameter> |
parametersMap
The dataset parameters indexed by name.
|
protected List<DatasetPropertyExpression> |
propertyExpressions |
protected JRQuery |
query
The dataset query.
|
protected int |
reportCount
The cursor used when iterating the data source.
|
protected Integer |
reportMaxCount
The value of the
max count parameter. |
protected ResourceBundle |
resourceBundle
The loaded resource bundle.
|
protected String |
resourceBundleBaseName
The resource bundle base name.
|
protected String |
scriptletClassName
The scriptlet class name.
|
protected List<JRAbstractScriptlet> |
scriptlets
The scriptlets used by the dataset.
|
protected JRPropertiesMap |
staticProperties |
protected TimeZone |
timeZone
The
TimeZone to be used by the dataset. |
protected Set<JRFillDataset.VariableCalculationReq> |
variableCalculationReqs
Set of
VariableCalculationReq objects. |
protected JRFillVariable[] |
variables
The dataset variables.
|
protected Map<String,JRFillVariable> |
variablesMap
The dataset variables indexed by name.
|
protected WhenResourceMissingTypeEnum |
whenResourceMissingType
The resource missing handle type.
|
Constructor and Description |
---|
JRFillDataset(BaseReportFiller filler,
JRDataset dataset,
JRFillObjectFactory factory)
Creates a fill dataset object.
|
Modifier and Type | Method and Description |
---|---|
protected void |
addCacheRecordIndexCallback(int recordIndex,
JRFillDataset.CacheRecordIndexCallback callback) |
protected void |
addVariableCalculationReq(String variableName,
CalculationEnum calculation)
Adds a variable calculation requirement.
|
protected void |
advanceCacheRecordIndexes() |
protected boolean |
advanceDataSource(boolean limit) |
protected void |
cacheEnd() |
protected void |
cacheInit() |
protected void |
cacheInitRecording() |
protected void |
cacheInitSnapshot() |
protected void |
cacheRecord() |
protected void |
checkVariableCalculationReqs(JRFillObjectFactory factory)
Checks if there are variable calculation requirements and creates the required variables.
|
Object |
clone() |
void |
closeDatasource()
Closes the data source used by this dataset if this data source was
obtained via a query executer.
|
protected void |
closeQueryExecuter() |
void |
contributeParameters(Map<String,Object> parameterValues) |
void |
createCalculator(JasperReport jasperReport)
Creates the calculator
|
protected static JRCalculator |
createCalculator(JasperReportsContext jasperReportsContext,
JasperReport jasperReport,
JRDataset dataset) |
protected List<JRAbstractScriptlet> |
createScriptlets(Map<String,Object> parameterValues)
Creates the scriptlets.
|
protected Locale |
defaultLocale() |
protected TimeZone |
defaultTimeZone() |
void |
disposeParameterContributors() |
Object |
evaluateExpression(JRExpression expression,
byte evaluation)
Evaluates an expression
|
void |
evaluateFieldProperties() |
protected void |
evaluateProperties(PropertyEvaluationTimeEnum evaluationTime) |
protected void |
filterElementDatasets(JRFillElementDataset elementDataset)
Filters the element datasets, leaving only one.
|
FillDatasetPosition |
getDatasetPosition() |
protected ParameterEvaluationTimeEnum |
getDefaultParameterEvaluationTime() |
protected PropertyEvaluationTimeEnum |
getDefaultPropertyEvaluationTime() |
JRField[] |
getFields()
Returns the dataset's fields.
|
Map<String,JRFillField> |
getFieldsMap() |
Object |
getFieldValue(String fieldName)
Returns the value of a field.
|
Object |
getFieldValue(String fieldName,
EvaluationType evaluation)
Returns the value of a field.
|
BaseReportFiller |
getFiller() |
JRFillField |
getFillField(String fieldName) |
FillDatasetPosition |
getFillPosition() |
JRFillVariable |
getFillVariable(String variableName) |
JRExpression |
getFilterExpression()
Returns the dataset filter expression.
|
JRGroup[] |
getGroups()
Returns the dataset's groups.
|
JasperReportsContext |
getJasperReportsContext() |
Locale |
getLocale()
Returns the locale used by the dataset.
|
String |
getName()
Returns the dataset name.
|
JRParameter[] |
getParameters()
Returns the dataset's parameters.
|
Map<String,JRFillParameter> |
getParametersMap() |
Object |
getParameterValue(String parameterName)
Returns the value of a parameter.
|
Object |
getParameterValue(String parameterName,
boolean ignoreMissing)
Returns the value of a parameter.
|
protected Map<String,Object> |
getParameterValuesMap()
Returns the map of parameter values.
|
JRPropertiesHolder |
getParentProperties()
Returns the parent properties holder, whose properties are used as defaults
for this object.
|
JRPropertiesMap |
getPropertiesMap()
Returns this object's properties map.
|
DatasetPropertyExpression[] |
getPropertyExpressions()
Returns the list of dynamic/expression-based properties for this dataset.
|
JRQuery |
getQuery()
Returns the query of the dataset.
|
RepositoryContext |
getRepositoryContext() |
String |
getResourceBundle()
Returns the resource bundle base name.
|
String |
getScriptletClass()
The name of the scriptlet class to be used when iterating this dataset.
|
JRScriptlet[] |
getScriptlets()
Returns the dataset's scriptlets.
|
JRSortField[] |
getSortFields()
Returns the dataset's sort fields.
|
TimeZone |
getTimeZone() |
UUID |
getUUID() |
JRFillVariable |
getVariable(String variableName) |
JRVariable[] |
getVariables()
Returns the dataset's variables.
|
Map<String,JRFillVariable> |
getVariablesMap() |
Object |
getVariableValue(String variableName)
Returns the value of a variable.
|
Object |
getVariableValue(String variableName,
EvaluationType evaluation)
Returns the value of a variable.
|
WhenResourceMissingTypeEnum |
getWhenResourceMissingTypeValue()
Returns the resource missing handling type.
|
boolean |
hasProperties()
Checks whether the object has any properties.
|
void |
inheritFromMain()
Inherits properties from the report.
|
void |
initCalculator()
Initializes the calculator.
|
void |
initDatasource()
Initializes the data source which will be used by this dataset.
|
protected void |
initElementDatasets(JRFillObjectFactory factory)
Initializes the element datasets.
|
protected boolean |
isIncludedInDataCache(JRFillParameter parameter) |
boolean |
isMainDataset()
Decides whether this dataset is the main report dataset or a sub dataset.
|
boolean |
isSortingData() |
protected ResourceBundle |
loadResourceBundle()
Loads the resource bundle corresponding to the resource bundle base name and locale.
|
boolean |
next()
Moves to the next record in the data source.
|
protected boolean |
next(boolean sorting)
Moves to the next record in the data source.
|
protected void |
reset() |
protected void |
resetVariables() |
protected void |
restoreElementDatasets()
Restores the original element datasets.
|
protected void |
revertToOldValues() |
protected void |
revertVariablesToOldValues() |
void |
setCacheRecordIndex(FillDatasetPosition position,
byte evaluationType) |
void |
setCacheSkipped(boolean cacheSkipped) |
protected void |
setCalculator(JRCalculator calculator) |
void |
setConnectionParameterValue(Map<String,Object> parameterValues,
Connection conn)
Sets the JDBC connection to be used.
|
void |
setDatasourceParameterValue(Map<String,Object> parameterValues,
JRDataSource ds)
Sets the data source to be used.
|
void |
setFillPosition(FillDatasetPosition fillPosition) |
void |
setJasperReportsContext(JasperReportsContext jasperReportsContext) |
protected void |
setOldValues() |
protected void |
setParameter(JRFillParameter parameter,
Object value)
Sets the value of the parameter.
|
protected void |
setParameter(String parameterName,
Object value)
Sets the value of a parameter.
|
void |
setParameterValues(Map<String,Object> parameterValues)
Reads built-in parameter values from the value map.
|
void |
setWhenResourceMissingType(WhenResourceMissingTypeEnum whenResourceMissingType)
Sets the resource missing handling type.
|
void |
start()
Starts the iteration on the data source.
|
public static final String EXCEPTION_MESSAGE_KEY_NO_SUCH_FIELD
public static final String EXCEPTION_MESSAGE_KEY_NO_SUCH_PARAMETER
public static final String EXCEPTION_MESSAGE_KEY_NO_SUCH_SNAPSHOT_DATA
public static final String EXCEPTION_MESSAGE_KEY_NO_SUCH_SNAPSHOT_PARAMETER
public static final String EXCEPTION_MESSAGE_KEY_NO_SUCH_VARIABLE
protected JRQuery query
protected JRFillParameter[] parameters
protected Map<String,JRFillParameter> parametersMap
protected JRFillField[] fields
protected Map<String,JRFillField> fieldsMap
protected JRFillVariable[] variables
protected Map<String,JRFillVariable> variablesMap
protected Set<JRFillDataset.VariableCalculationReq> variableCalculationReqs
VariableCalculationReq
objects.protected JRFillElementDataset[] elementDatasets
protected JRFillElementDataset[] origElementDatasets
filterElementDatasets
is called.protected JRFillGroup[] groups
protected String resourceBundleBaseName
protected WhenResourceMissingTypeEnum whenResourceMissingType
protected String scriptletClassName
protected JRDataSource dataSource
protected ResourceBundle resourceBundle
protected int reportCount
protected JRCalculator calculator
protected List<JRAbstractScriptlet> scriptlets
protected List<DatasetPropertyExpression> propertyExpressions
protected JRPropertiesMap staticProperties
protected JRPropertiesMap mergedProperties
protected JRAbstractScriptlet delegateScriptlet
protected DatasetFilter filter
protected FillDatasetPosition fillPosition
protected DatasetRecorder dataRecorder
public JRFillDataset(BaseReportFiller filler, JRDataset dataset, JRFillObjectFactory factory)
filler
- the fillerdataset
- the template datasetfactory
- the fill object factorypublic BaseReportFiller getFiller()
public void createCalculator(JasperReport jasperReport) throws JRException
jasperReport
- the reportJRException
protected void setCalculator(JRCalculator calculator)
protected static JRCalculator createCalculator(JasperReportsContext jasperReportsContext, JasperReport jasperReport, JRDataset dataset) throws JRException
JRException
public void initCalculator() throws JRException
JRException
public void inheritFromMain()
protected List<JRAbstractScriptlet> createScriptlets(Map<String,Object> parameterValues) throws JRException
JRException
protected void initElementDatasets(JRFillObjectFactory factory)
factory
- the fill object factory used by the fillerprotected void filterElementDatasets(JRFillElementDataset elementDataset)
This method is used when a dataset is instantiated by a chart or crosstab.
elementDataset
- the element dataset that should remainprotected void restoreElementDatasets()
This method should be called after filterElementDatasets
.
protected ResourceBundle loadResourceBundle()
public void setParameterValues(Map<String,Object> parameterValues) throws JRException
parameterValues
- the parameter valuesJRException
protected Locale defaultLocale()
protected TimeZone defaultTimeZone()
public void initDatasource() throws JRException
JRException
public boolean isSortingData()
public FillDatasetPosition getFillPosition()
public void setFillPosition(FillDatasetPosition fillPosition)
public void setCacheSkipped(boolean cacheSkipped)
protected void cacheInit() throws DataSnapshotException
DataSnapshotException
protected void cacheInitSnapshot() throws DataSnapshotException
DataSnapshotException
protected void cacheInitRecording()
protected boolean isIncludedInDataCache(JRFillParameter parameter)
protected ParameterEvaluationTimeEnum getDefaultParameterEvaluationTime()
protected PropertyEvaluationTimeEnum getDefaultPropertyEvaluationTime()
protected void cacheRecord()
protected void cacheEnd()
public void evaluateFieldProperties() throws JRException
JRException
public void contributeParameters(Map<String,Object> parameterValues) throws JRException
JRException
public void setJasperReportsContext(JasperReportsContext jasperReportsContext)
public JasperReportsContext getJasperReportsContext()
public RepositoryContext getRepositoryContext()
public void disposeParameterContributors()
protected Map<String,Object> getParameterValuesMap()
protected void reset()
public void setDatasourceParameterValue(Map<String,Object> parameterValues, JRDataSource ds)
parameterValues
- the parameter valuesds
- the data sourcepublic void setConnectionParameterValue(Map<String,Object> parameterValues, Connection conn)
parameterValues
- the parameter valuesconn
- the connectionpublic void closeDatasource()
JRQueryExecuter.close()
protected void closeQueryExecuter()
public void start()
protected void resetVariables()
public boolean next() throws JRException
true
if the data source was not exhaustedJRException
protected boolean next(boolean sorting) throws JRException
sorting
- whether the method is called as part of the data sorting phasetrue
if the data source was not exhaustedJRException
protected void advanceCacheRecordIndexes()
protected void setOldValues() throws JRException
JRException
protected void revertToOldValues()
protected void revertVariablesToOldValues()
protected boolean advanceDataSource(boolean limit) throws JRException
JRException
protected void setParameter(String parameterName, Object value) throws JRException
parameterName
- the parameter namevalue
- the valueJRException
protected void setParameter(JRFillParameter parameter, Object value) throws JRException
parameter
- the parametervalue
- the valueJRException
public JRFillVariable getVariable(String variableName)
public Object getVariableValue(String variableName)
variableName
- the variable namepublic Object getVariableValue(String variableName, EvaluationType evaluation)
DatasetFillContext
getVariableValue
in interface DatasetFillContext
variableName
- the variable nameevaluation
- the evaluation typepublic JRFillVariable getFillVariable(String variableName)
public Object getParameterValue(String parameterName)
getParameterValue
in interface DatasetFillContext
parameterName
- the parameter namepublic Object getParameterValue(String parameterName, boolean ignoreMissing)
parameterName
- the parameter nameignoreMissing
- if set, null
will be returned for inexisting parameterspublic Object getFieldValue(String fieldName)
fieldName
- the field namepublic Object getFieldValue(String fieldName, EvaluationType evaluation)
DatasetFillContext
getFieldValue
in interface DatasetFillContext
fieldName
- the field nameevaluation
- the evaluation typepublic JRFillField getFillField(String fieldName)
protected void addVariableCalculationReq(String variableName, CalculationEnum calculation)
variableName
- the variable namecalculation
- the required calculationprotected void checkVariableCalculationReqs(JRFillObjectFactory factory)
factory
- the fill object factorypublic UUID getUUID()
getUUID
in interface JRIdentifiable
public String getName()
JRDataset
public String getScriptletClass()
JRDataset
getScriptletClass
in interface JRDataset
public JRScriptlet[] getScriptlets()
JRDataset
getScriptlets
in interface JRDataset
public JRParameter[] getParameters()
JRDataset
getParameters
in interface JRDataset
public Map<String,JRFillParameter> getParametersMap()
public JRQuery getQuery()
JRDataset
The query is used by passing a connection is passed to the dataset when instantiating.
public JRField[] getFields()
JRDataset
public Map<String,JRFillField> getFieldsMap()
public JRSortField[] getSortFields()
JRDataset
getSortFields
in interface JRDataset
public JRVariable[] getVariables()
JRDataset
getVariables
in interface JRDataset
public Map<String,JRFillVariable> getVariablesMap()
public JRGroup[] getGroups()
JRDataset
public boolean isMainDataset()
JRDataset
isMainDataset
in interface JRDataset
true
if and only if this dataset is the main report datasetpublic String getResourceBundle()
JRDataset
The resource bundle is used when evaluating expressions.
getResourceBundle
in interface JRDataset
public WhenResourceMissingTypeEnum getWhenResourceMissingTypeValue()
JRDataset
getWhenResourceMissingTypeValue
in interface JRDataset
public void setWhenResourceMissingType(WhenResourceMissingTypeEnum whenResourceMissingType)
JRDataset
setWhenResourceMissingType
in interface JRDataset
whenResourceMissingType
- the resource missing handling typepublic boolean hasProperties()
JRPropertiesHolder
hasProperties
in interface JRPropertiesHolder
public JRPropertiesMap getPropertiesMap()
JRPropertiesHolder
getPropertiesMap
in interface JRPropertiesHolder
public JRPropertiesHolder getParentProperties()
JRPropertiesHolder
getParentProperties
in interface JRPropertiesHolder
null
if no parentpublic DatasetPropertyExpression[] getPropertyExpressions()
JRDataset
getPropertyExpressions
in interface JRDataset
protected void evaluateProperties(PropertyEvaluationTimeEnum evaluationTime) throws JRException
JRException
public JRExpression getFilterExpression()
JRDataset
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.
getFilterExpression
in interface JRDataset
public Object clone()
clone
in interface JRCloneable
clone
in class Object
public Object evaluateExpression(JRExpression expression, byte evaluation) throws JRException
expression
- the expressionevaluation
- the evaluation typeJRException
public Locale getLocale()
DatasetFillContext
getLocale
in interface DatasetFillContext
public TimeZone getTimeZone()
public FillDatasetPosition getDatasetPosition()
protected void addCacheRecordIndexCallback(int recordIndex, JRFillDataset.CacheRecordIndexCallback callback)
public void setCacheRecordIndex(FillDatasetPosition position, byte evaluationType)
Copyright © 2023 Cloud Software Group, Inc.. All rights reserved.