net.sf.jasperreports.engine.fill
Class JRFillDataset

java.lang.Object
  extended bynet.sf.jasperreports.engine.fill.JRFillDataset
All Implemented Interfaces:
JRDataset

public class JRFillDataset
extends java.lang.Object
implements JRDataset

Version:
$Id: JRFillDataset.java,v 1.8 2005/11/28 10:23:24 teodord Exp $
Author:
Lucian Chirita (lucianc@users.sourceforge.net)

Nested Class Summary
protected static class JRFillDataset.VariableCalculationReq
          Class used to hold expression calculation requirements.
 
Field Summary
protected  JRCalculator calculator
          The calculator used by the dataset.
protected  JRDataSource dataSource
          The data source.
protected  java.sql.PreparedStatement dataSourceStatement
          The statement used to fire the query.
protected  JRFillElementDataset[] elementDatasets
          The element datasets.
protected  JRFillField[] fields
          The dataset fields.
protected  java.util.Map fieldsMap
          The dataset fields indexed by name.
protected  JRFillGroup[] groups
          The dataset groups.
protected  java.util.Locale locale
          The Locale to be used by the dataset.
protected  JRFillElementDataset[] origElementDatasets
          Used to save the original element datasets when filterElementDatasets is called.
protected  JRFillParameter[] parameters
          The dataset parameter.
protected  java.util.Map parametersMap
          The dataset parameters indexed by name.
protected  JRQuery query
          The dataset query.
protected  int reportCount
          The cursor used when iterating the data source.
protected  java.lang.Integer reportMaxCount
          The value of the max count parameter.
protected  java.util.ResourceBundle resourceBundle
          The loaded resource bundle.
protected  java.lang.String resourceBundleBaseName
          The resource bundle base name.
protected  JRAbstractScriptlet scriptlet
          The scriptlet used by the dataset.
protected  java.lang.Class scriptletClass
          The scriptlet class.
protected  java.lang.String scriptletClassName
          The scriptlet class name.
protected  java.util.Set variableCalculationReqs
          Set of VariableCalculationReq objects.
protected  JRFillVariable[] variables
          The dataset variables.
protected  java.util.Map variablesMap
          The dataset variables indexed by name.
protected  byte whenResourceMissingType
          The resource missing handle type.
 
Fields inherited from interface net.sf.jasperreports.engine.JRDataset
WHEN_RESOURCE_MISSING_TYPE_EMPTY, WHEN_RESOURCE_MISSING_TYPE_ERROR, WHEN_RESOURCE_MISSING_TYPE_KEY, WHEN_RESOURCE_MISSING_TYPE_NULL
 
Constructor Summary
protected JRFillDataset(JRBaseFiller filler, JRDataset dataset, JRFillObjectFactory factory)
          Creates a fill dataset object.
 
Method Summary
protected  void addVariableCalculationReq(java.lang.String variableName, byte calculation)
          Adds a variable calculation requirement.
protected  void checkVariableCalculationReqs(JRFillObjectFactory factory)
          Checks if there are variable calculation requirements and creates the required variables.
protected  void closeStatement()
          Closes the statement used to fire the query.
protected  void createCalculator(JasperReport jasperReport)
          Creates the calculator
protected static JRCalculator createCalculator(JasperReport jasperReport, JRDataset dataset)
           
protected  JRDataSource createDataSource(java.util.Map parameterValues, java.sql.Connection conn)
          Creates the data source from a connection.
protected  JRAbstractScriptlet createScriptlet()
          Creates the scriptlet.
protected  void filterElementDatasets(JRFillElementDataset elementDataset)
          Filters the element datasets, leaving only one.
 JRField[] getFields()
          Returns the dataset's fields.
 java.lang.Object getFieldValue(java.lang.String fieldName)
          Returns the value of a field.
 JRGroup[] getGroups()
          Returns the dataset's groups.
 java.lang.String getName()
          Returns the dataset name.
 JRParameter[] getParameters()
          Returns the dataset's parameters.
 java.lang.Object getParameterValue(java.lang.String parameterName)
          Returns the value of a parameter.
 JRQuery getQuery()
          Returns the query of the dataset.
 java.lang.String getResourceBundle()
          Returns the resource bundle base name.
 java.lang.String getScriptletClass()
          The name of the scriptlet class to be used when iterating this dataset.
 JRVariable[] getVariables()
          Returns the dataset's variables.
 java.lang.Object getVariableValue(java.lang.String variableName)
          Returns the value of a variable.
 byte getWhenResourceMissingType()
          Returns the resource missing handling type.
protected  void inheritFromMain()
          Inherits properties from the report.
protected  void initCalculator()
          Initializes the calculator.
protected  void initElementDatasets(JRFillObjectFactory factory)
          Initializes the element datasets.
protected  JRAbstractScriptlet initScriptlet()
          Creates and initializes the scriptlet.
 boolean isMainDataset()
          Decides whether this dataset is the main report dataset or a sub dataset.
protected  java.util.ResourceBundle loadResourceBundle()
          Loads the resource bundle corresponding to the resource bundle base name and locale.
protected  boolean next()
          Moves to the next record in the data source.
protected  void restoreElementDatasets()
          Restores the original element datasets.
protected  void setCalculator(JRCalculator calculator)
           
protected  void setDatasource(java.util.Map parameterValues, JRDataSource ds)
          Sets the data source to be used.
protected  void setParameter(JRFillParameter parameter, java.lang.Object value)
          Sets the value of the parameter.
protected  void setParameter(java.lang.String parameterName, java.lang.Object value)
          Sets the value of a parameter.
protected  void setParameters(java.util.Map parameterValues)
          Reads built-in parameter values from the value map.
protected  void setParameterValues(java.util.Map parameterValues)
          Sets the parameter values from the values map.
 void setWhenResourceMissingType(byte whenResourceMissingType)
          Sets the resource missing handling type.
protected  void start()
          Starts the iteration on the data source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

query

protected JRQuery query
The dataset query.


parameters

protected JRFillParameter[] parameters
The dataset parameter.


parametersMap

protected java.util.Map parametersMap
The dataset parameters indexed by name.


fields

protected JRFillField[] fields
The dataset fields.


fieldsMap

protected java.util.Map fieldsMap
The dataset fields indexed by name.


variables

protected JRFillVariable[] variables
The dataset variables.


variablesMap

protected java.util.Map variablesMap
The dataset variables indexed by name.


variableCalculationReqs

protected java.util.Set variableCalculationReqs
Set of VariableCalculationReq objects.


elementDatasets

protected JRFillElementDataset[] elementDatasets
The element datasets.


origElementDatasets

protected JRFillElementDataset[] origElementDatasets
Used to save the original element datasets when filterElementDatasets is called.


groups

protected JRFillGroup[] groups
The dataset groups.


resourceBundleBaseName

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


whenResourceMissingType

protected byte whenResourceMissingType
The resource missing handle type.


scriptletClassName

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


scriptletClass

protected java.lang.Class scriptletClass
The scriptlet class.


reportMaxCount

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


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.


reportCount

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


calculator

protected JRCalculator calculator
The calculator used by the dataset.


scriptlet

protected JRAbstractScriptlet scriptlet
The scriptlet used by the dataset.


dataSourceStatement

protected java.sql.PreparedStatement dataSourceStatement
The statement used to fire the query.

Constructor Detail

JRFillDataset

protected JRFillDataset(JRBaseFiller filler,
                        JRDataset dataset,
                        JRFillObjectFactory factory)
Creates a fill dataset object.

Parameters:
filler - the filelr
dataset - the template dataset
factory - the fill object factory
Method Detail

createCalculator

protected void createCalculator(JasperReport jasperReport)
                         throws JRException
Creates the calculator

Parameters:
jasperReport - the report
Throws:
JRException

setCalculator

protected void setCalculator(JRCalculator calculator)

createCalculator

protected static JRCalculator createCalculator(JasperReport jasperReport,
                                               JRDataset dataset)
                                        throws JRException
Throws:
JRException

initCalculator

protected void initCalculator()
                       throws JRException
Initializes the calculator.

Throws:
JRException

inheritFromMain

protected void inheritFromMain()
Inherits properties from the report.


initScriptlet

protected JRAbstractScriptlet initScriptlet()
                                     throws JRException
Creates and initializes the scriptlet.

Returns:
the scriptlet
Throws:
JRException

createScriptlet

protected JRAbstractScriptlet createScriptlet()
                                       throws JRException
Creates the scriptlet.

Returns:
the scriptlet
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.


setParameters

protected void setParameters(java.util.Map parameterValues)
                      throws JRException
Reads built-in parameter values from the value map.

Parameters:
parameterValues - the parameter values
Throws:
JRException

setParameterValues

protected void setParameterValues(java.util.Map parameterValues)
                           throws JRException
Sets the parameter values from the values map.

Parameters:
parameterValues - the values map
Throws:
JRException

createDataSource

protected JRDataSource createDataSource(java.util.Map parameterValues,
                                        java.sql.Connection conn)
                                 throws JRException
Creates the data source from a connection.

Parameters:
parameterValues - the parameterValues
conn - the connection
Returns:
the data source to be used
Throws:
JRException

setDatasource

protected void setDatasource(java.util.Map parameterValues,
                             JRDataSource ds)
                      throws JRException
Sets the data source to be used.

Parameters:
parameterValues - the parameter values
ds - the data source
Throws:
JRException

closeStatement

protected void closeStatement()
Closes the statement used to fire the query.


start

protected void start()
Starts the iteration on the data source.


next

protected boolean next()
                throws JRException
Moves to the next record in the data source.

Returns:
true if the data source was not exhausted
Throws:
JRException

setParameter

protected 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

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

getParameterValue

public java.lang.Object getParameterValue(java.lang.String parameterName)
Returns the value of a parameter.

Parameters:
parameterName - the parameter name
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

addVariableCalculationReq

protected void addVariableCalculationReq(java.lang.String variableName,
                                         byte 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

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

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

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

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 iff 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

getWhenResourceMissingType

public byte getWhenResourceMissingType()
Description copied from interface: JRDataset
Returns the resource missing handling type.

Specified by:
getWhenResourceMissingType in interface JRDataset
Returns:
the resource missing handling type

setWhenResourceMissingType

public void setWhenResourceMissingType(byte whenResourceMissingType)
Description copied from interface: JRDataset
Sets the resource missing handling type.

Specified by:
setWhenResourceMissingType in interface JRDataset
Parameters:
whenResourceMissingType - the resource missing handling type


© 2001-2005 JasperSoft Corporation www.jaspersoft.com