org.dbforms.event.datalist.dao
Class DataSourceFactory

java.lang.Object
  extended by org.dbforms.event.datalist.dao.DataSourceFactory

public class DataSourceFactory
extends Object

Factory class to generate different DataSources. datasource is attribute of table class and can be changed in dbforms-config. Default class is

Author:
hkk

Constructor Summary
DataSourceFactory(String dbConnectionName, Connection connection, Table table)
          Creates a new DataSourceFactory object.
 
Method Summary
 void close()
          Close the underlying dataHandler.
 int doDelete(DbEventInterceptorData interceptorData, String keyValuesStr)
          Perform a delete operation into the underlying dataSource.
 int doInsert(DbEventInterceptorData interceptorData, FieldValues fieldValues)
          Perform an insert operation into the underlying dataSource.
 int doUpdate(DbEventInterceptorData interceptorData, FieldValues fieldValues, String keyValuesStr)
          Perform an update operation into the underlying dataSource.
 ResultSetVector getCurrent(DbEventInterceptorData interceptorData, String position, int count)
          Return a resultSetVector object containing count records starting from the input position
 AbstractDataSource getDataHandler()
          returns the internal DataSource element
 ResultSetVector getFirst(DbEventInterceptorData interceptorData, int count)
          Return a resultSetVector object containing the first count records.
 ResultSetVector getLast(DbEventInterceptorData interceptorData, int count)
          Return a resultSetVector object containing the last count records.
 ResultSetVector getNext(DbEventInterceptorData interceptorData, String position, int count)
          Return a resultSetVector object containing the next count records starting from the input position + count records.
 ResultSetVector getPrev(DbEventInterceptorData interceptorData, String position, int count)
          Return a resultSetVector object containing the previous count records starting from the input position + count records.
 void setSelect(FieldValue[] filterConstraint, FieldValue[] orderConstraint, String sqlFilter, FieldValue[] sqlFilterParams)
          Sets the select data for this dataSource
 void setSelect(String tableList, String whereClause)
          Sets the select data for this dataSource for free form selects. default methods just raises an exception
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataSourceFactory

public DataSourceFactory(String dbConnectionName,
                         Connection connection,
                         Table table)
                  throws SQLException
Creates a new DataSourceFactory object.

Parameters:
dbConnectionName - name of the used db connection. Can be used to get an own db connection, e.g. to hold it during the session (see DataSourceJDBC for example!)
con - the JDBC Connection object
table - the input table
Throws:
SQLException - if any error occurs
Method Detail

getCurrent

public ResultSetVector getCurrent(DbEventInterceptorData interceptorData,
                                  String position,
                                  int count)
                           throws SQLException
Return a resultSetVector object containing count records starting from the input position

Parameters:
position - the current table position
count - number of records to fetch
Returns:
a resultSetVector object containing the current count records starting from the input position
Throws:
SQLException - if any error occurs

getDataHandler

public AbstractDataSource getDataHandler()
returns the internal DataSource element

Returns:
the DataSource element

getFirst

public ResultSetVector getFirst(DbEventInterceptorData interceptorData,
                                int count)
                         throws SQLException
Return a resultSetVector object containing the first count records.

Parameters:
count - number of records to fetch
Returns:
a resultSetVector object containing the first count records
Throws:
SQLException - if any error occurs

getLast

public ResultSetVector getLast(DbEventInterceptorData interceptorData,
                               int count)
                        throws SQLException
Return a resultSetVector object containing the last count records.

Parameters:
count - number of records to fetch
Returns:
a resultSetVector object containing the last count records
Throws:
SQLException - if any error occurs

getNext

public ResultSetVector getNext(DbEventInterceptorData interceptorData,
                               String position,
                               int count)
                        throws SQLException
Return a resultSetVector object containing the next count records starting from the input position + count records.

Parameters:
position - the current table position
count - number of records to fetch
Returns:
a resultSetVector object containing the next count records starting from the input position
Throws:
SQLException - if any error occurs

getPrev

public ResultSetVector getPrev(DbEventInterceptorData interceptorData,
                               String position,
                               int count)
                        throws SQLException
Return a resultSetVector object containing the previous count records starting from the input position + count records.

Parameters:
position - the current table position
count - number of records to fetch
Returns:
a resultSetVector object containing the previous count records starting from the input position
Throws:
SQLException - if any error occurs

setSelect

public void setSelect(FieldValue[] filterConstraint,
                      FieldValue[] orderConstraint,
                      String sqlFilter,
                      FieldValue[] sqlFilterParams)
Sets the select data for this dataSource

Parameters:
filterConstraint - FieldValue array used to restrict a set in a resultset
orderConstraint - FieldValue array used to build a cumulation of rules for ordering (sorting)
sqlFilter - sql condition to add to where clause
sqlFilterParams - DOCUMENT ME!

setSelect

public void setSelect(String tableList,
                      String whereClause)
               throws SQLException
Sets the select data for this dataSource for free form selects. default methods just raises an exception

Parameters:
tableList - the list of tables involved into the query
whereClause - free-form whereClause to be appended to query
Throws:
SQLException

close

public void close()
Close the underlying dataHandler.


doDelete

public int doDelete(DbEventInterceptorData interceptorData,
                    String keyValuesStr)
             throws SQLException
Perform a delete operation into the underlying dataSource.

Parameters:
con - DOCUMENT ME!
keyValuesStr - the key value identifying the record to delete
Throws:
SQLException - if any error occurs

doInsert

public int doInsert(DbEventInterceptorData interceptorData,
                    FieldValues fieldValues)
             throws SQLException
Perform an insert operation into the underlying dataSource.

Parameters:
con - DOCUMENT ME!
fieldValues - the field values to insert
Throws:
SQLException - if any error occurs

doUpdate

public int doUpdate(DbEventInterceptorData interceptorData,
                    FieldValues fieldValues,
                    String keyValuesStr)
             throws SQLException
Perform an update operation into the underlying dataSource.

Parameters:
con - DOCUMENT ME!
fieldValues - the field values to update
keyValuesStr - the key value identifying the record to update
Throws:
SQLException - if any error occurs


Copyright © 2002-2006 DbForms. All Rights Reserved.