org.pentaho.reporting.engine.classic.core
Class TableDataFactory

java.lang.Object
  extended by org.pentaho.reporting.engine.classic.core.TableDataFactory
All Implemented Interfaces:
Serializable, Cloneable, DataFactory

public class TableDataFactory
extends Object
implements DataFactory, Cloneable

The TableDataFactory provides keyed access to predefined tablemodels. The factory does not accept parameters and therefore cannot be used for parametrized queries. The queryname is used to lookup the table by its previously registered name.

Author:
Thomas Morgner
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.pentaho.reporting.engine.classic.core.DataFactory
QUERY_LIMIT, QUERY_TIMEOUT
 
Constructor Summary
TableDataFactory()
          Default Constructor.
TableDataFactory(String name, TableModel tableModel)
          Creates a new TableDataFactory and registers the tablemodel with the given name.
 
Method Summary
 void addTable(String name, TableModel tableModel)
          Registers a tablemodel with the given name.
 void cancelRunningQuery()
          Attempts to cancel the query process that is generating the data for this data factory.
 Object clone()
          Creates a copy of this data-factory.
 void close()
          Closes the data factory.
 DataFactory derive()
          Derives a freshly initialized report data factory, which is independend of the original data factory.
 String[] getQueryNames()
          Returns all known query-names.
 TableModel getTable(String name)
           
 void initialize(org.pentaho.reporting.libraries.base.config.Configuration configuration, org.pentaho.reporting.libraries.resourceloader.ResourceManager resourceManager, org.pentaho.reporting.libraries.resourceloader.ResourceKey contextKey, ResourceBundleFactory resourceBundleFactory)
          Initializes the data factory and provides new context information.
 boolean isQueryExecutable(String query, DataRow parameters)
          Checks whether the query would be executable by this datafactory.
 void open()
          This does nothing.
 TableModel queryData(String query, DataRow parameters)
          Queries a datasource.
 void removeTable(String name)
          Removes the table that has been registered by the given name.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableDataFactory

public TableDataFactory()
Default Constructor.


TableDataFactory

public TableDataFactory(String name,
                        TableModel tableModel)
Creates a new TableDataFactory and registers the tablemodel with the given name.

Parameters:
name - the name of the table.
tableModel - the tablemodel.
Method Detail

isQueryExecutable

public boolean isQueryExecutable(String query,
                                 DataRow parameters)
Checks whether the query would be executable by this datafactory. This performs a rough check, not a full query.

Specified by:
isQueryExecutable in interface DataFactory
Parameters:
query -
parameters -
Returns:

addTable

public void addTable(String name,
                     TableModel tableModel)
Registers a tablemodel with the given name. If a different tablemodel has been previously registered with the same name, this table will replace the existing one.

Parameters:
name - the name of the table.
tableModel - the tablemodel that should be registered.

removeTable

public void removeTable(String name)
Removes the table that has been registered by the given name.

Parameters:
name - the name of the table to be removed.

getTable

public TableModel getTable(String name)

queryData

public TableModel queryData(String query,
                            DataRow parameters)
                     throws ReportDataFactoryException
Queries a datasource. The string 'query' defines the name of the query. The Parameterset given here may contain more data than actually needed.

The dataset may change between two calls, do not assume anything!

Specified by:
queryData in interface DataFactory
Parameters:
query - the name of the table.
parameters - are ignored for this factory.
Returns:
the report data or null.
Throws:
ReportDataFactoryException - if an error occured while performing the query.

initialize

public void initialize(org.pentaho.reporting.libraries.base.config.Configuration configuration,
                       org.pentaho.reporting.libraries.resourceloader.ResourceManager resourceManager,
                       org.pentaho.reporting.libraries.resourceloader.ResourceKey contextKey,
                       ResourceBundleFactory resourceBundleFactory)
Description copied from interface: DataFactory
Initializes the data factory and provides new context information. Initialize is always called before the datafactory has been opened by calling DataFactory#open.

Specified by:
initialize in interface DataFactory
Parameters:
configuration - the current report configuration.
resourceManager - the report's resource manager.
contextKey - the report's context key to access resources relative to the report location.
resourceBundleFactory - the report's resource-bundle factory to access localization information.

open

public void open()
This does nothing.

Specified by:
open in interface DataFactory

close

public void close()
Closes the data factory. Actually, this one does nothing at all.

Specified by:
close in interface DataFactory

derive

public DataFactory derive()
Derives a freshly initialized report data factory, which is independend of the original data factory. Opening or Closing one data factory must not affect the other factories.

Specified by:
derive in interface DataFactory
Returns:
a copy of this factory.

clone

public Object clone()
Creates a copy of this data-factory.

Specified by:
clone in interface DataFactory
Overrides:
clone in class Object
Returns:
the copy of the data-factory, never null.

getQueryNames

public String[] getQueryNames()
Description copied from interface: DataFactory
Returns all known query-names. A data-factory may accept more than the query-names returned here.

Specified by:
getQueryNames in interface DataFactory
Returns:
the known query names.

cancelRunningQuery

public void cancelRunningQuery()
Description copied from interface: DataFactory
Attempts to cancel the query process that is generating the data for this data factory. If it is not possible to cancel the query, this call should be ignored.

Specified by:
cancelRunningQuery in interface DataFactory