org.dbforms.event.datalist.dao
Class AbstractDataSource

java.lang.Object
  extended by org.dbforms.event.datalist.dao.AbstractDataSource
Direct Known Subclasses:
DataSourceJDBC, DataSourceXML

public abstract class AbstractDataSource
extends Object

Abstract base class for DataSource.

Author:
hkk

Constructor Summary
AbstractDataSource()
          Creates a new DataSource object.
 
Method Summary
protected abstract  void close()
          should close all open datasets
protected  void deleteBlobFilesFromDisk(FieldValues fieldValues)
          deletes the blob files on disk
 int doDelete(DbEventInterceptorData interceptorData, String keyValuesStr)
          performs an delete in the DataSource
 int doInsert(DbEventInterceptorData interceptorData, FieldValues fieldValues)
          performs an insert into the DataSource
 int doUpdate(DbEventInterceptorData interceptorData, FieldValues fieldValues, String keyValuesStr)
          performs an update into the DataSource
protected abstract  int findStartRow(String startRow)
          maps the startRow to the internal index
 ResultSetVector getCurrent(DbEventInterceptorData interceptorData, String position, int count)
          get count rows from position
 ResultSetVector getFirst(DbEventInterceptorData interceptorData, int count)
          get count rows from first row
 ResultSetVector getLast(DbEventInterceptorData interceptorData, int count)
          get count rows from last row
 ResultSetVector getNext(DbEventInterceptorData interceptorData, String position, int count)
          get count next rows from position
 ResultSetVector getPrev(DbEventInterceptorData interceptorData, String position, int count)
          get count rows backwards from position
protected  ResultSetVector getResultSetVector(DbEventInterceptorData interceptorData, int startRow, int count)
          DOCUMENT ME!
protected abstract  Object[] getRow(int i)
          should retrieve the row at an special index as an Object[]
 Table getTable()
          gets the Table for the DataSource
protected abstract  boolean hasMore(int i)
          return true if there are more records to fetch then the given record number
protected abstract  void open()
          Will be called to open all datasets
protected  void saveBlobFilesToDisk(FieldValues fieldValues)
          save the blob files to disk
protected  void setConnection(Connection con, String dbConnectionName)
          set the connection parameter for the DataSouce. virtual method, if you need the connection data you must override this method
abstract  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
protected  void setTable(Table table)
           
protected abstract  int size()
          Must return the size of the whole resultset with all data fetch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDataSource

public AbstractDataSource()
Creates a new DataSource object.

Method Detail

setSelect

public abstract 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 - list of FieldValues to fill the sqlFilter with

getCurrent

public ResultSetVector getCurrent(DbEventInterceptorData interceptorData,
                                  String position,
                                  int count)
                           throws SQLException
get count rows from position

Parameters:
position - keyValueStr to the row
key format: FieldID ":" Length ":" Value
example: if key id = 121 and field id=2 then keyValueStr contains "2:3:121"
If the key consists of more than one fields, the key values are seperated through "-"
example: value of field 1=12, value of field 3=1992, then we'll get "1:2:12-3:4:1992"
count - count of rows to fetch
Returns:
the fetched ResultSetVector
Throws:
SQLException

getFirst

public ResultSetVector getFirst(DbEventInterceptorData interceptorData,
                                int count)
                         throws SQLException
get count rows from first row

Parameters:
count - count of rows to fetch
Returns:
the fetched ResultSetVector
Throws:
SQLException

getLast

public ResultSetVector getLast(DbEventInterceptorData interceptorData,
                               int count)
                        throws SQLException
get count rows from last row

Parameters:
count - count of rows to fetch
Returns:
the fetched ResultSetVector
Throws:
SQLException

getNext

public ResultSetVector getNext(DbEventInterceptorData interceptorData,
                               String position,
                               int count)
                        throws SQLException
get count next rows from position

Parameters:
position - keyValueStr to the row
key format: FieldID ":" Length ":" Value
example: if key id = 121 and field id=2 then keyValueStr contains "2:3:121"
If the key consists of more than one fields, the key values are seperated through "-"
example: value of field 1=12, value of field 3=1992, then we'll get "1:2:12-3:4:1992"
count - count of rows to fetch
Returns:
the fetched ResultSetVector
Throws:
SQLException

getPrev

public ResultSetVector getPrev(DbEventInterceptorData interceptorData,
                               String position,
                               int count)
                        throws SQLException
get count rows backwards from position

Parameters:
position - keyValueStr to the row
key format: FieldID ":" Length ":" Value
example: if key id = 121 and field id=2 then keyValueStr contains "2:3:121"
If the key consists of more than one fields, the key values are seperated through "-"
example: value of field 1=12, value of field 3=1992, then we'll get "1:2:12-3:4:1992"
count - count of rows to fetch
Returns:
the fetched ResultSetVector
Throws:
SQLException

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

getTable

public Table getTable()
gets the Table for the DataSource

Returns:
Table

doDelete

public int doDelete(DbEventInterceptorData interceptorData,
                    String keyValuesStr)
             throws SQLException
performs an delete in the DataSource

Parameters:
con - DOCUMENT ME!
keyValuesStr - keyValueStr to the row to update
key format: FieldID ":" Length ":" Value
example: if key id = 121 and field id=2 then keyValueStr contains "2:3:121"
If the key consists of more than one fields, the key values are seperated through "-"
example: value of field 1=12, value of field 3=1992, then we'll get "1:2:12-3:4:1992"
Throws:
SQLException - if any error occurs

doInsert

public int doInsert(DbEventInterceptorData interceptorData,
                    FieldValues fieldValues)
             throws SQLException
performs an insert into the DataSource

Parameters:
con - DOCUMENT ME!
fieldValues - FieldValues to insert
Throws:
SQLException

doUpdate

public int doUpdate(DbEventInterceptorData interceptorData,
                    FieldValues fieldValues,
                    String keyValuesStr)
             throws SQLException
performs an update into the DataSource

Parameters:
con - DOCUMENT ME!
fieldValues - FieldValues to update
keyValuesStr - keyValueStr to the row to update
key format: FieldID ":" Length ":" Value
example: if key id = 121 and field id=2 then keyValueStr contains "2:3:121"
If the key consists of more than one fields, the key values are seperated through "-"
example: value of field 1=12, value of field 3=1992, then we'll get "1:2:12-3:4:1992"
Throws:
SQLException - if any error occurs

setConnection

protected void setConnection(Connection con,
                             String dbConnectionName)
set the connection parameter for the DataSouce. virtual method, if you need the connection data you must override this method

Parameters:
con - the JDBC Connection object
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!)

getRow

protected abstract Object[] getRow(int i)
                            throws SQLException
should retrieve the row at an special index as an Object[]

Parameters:
i - index of row to fetch
Returns:
Object[] of the fetched row
Throws:
SQLException

close

protected abstract void close()
should close all open datasets


findStartRow

protected abstract int findStartRow(String startRow)
                             throws SQLException
maps the startRow to the internal index

Parameters:
startRow - keyValueStr to the row
key format: FieldID ":" Length ":" Value
example: if key id = 121 and field id=2 then keyValueStr contains "2:3:121"
If the key consists of more than one fields, the key values are seperated through "-"
example: value of field 1=12, value of field 3=1992, then we'll get "1:2:12-3:4:1992"
Returns:
the index of the row, 0 as first row if not found
Throws:
SQLException

hasMore

protected abstract boolean hasMore(int i)
                            throws SQLException
return true if there are more records to fetch then the given record number

Parameters:
i - index of last fetched row.
Returns:
true if there are more records to fetch then the given record number
Throws:
SQLException

open

protected abstract void open()
                      throws SQLException
Will be called to open all datasets

Throws:
SQLException

size

protected abstract int size()
                     throws SQLException
Must return the size of the whole resultset with all data fetch

Returns:
size of whole resultset
Throws:
SQLException

setTable

protected void setTable(Table table)
Parameters:
table - The table to set.

deleteBlobFilesFromDisk

protected void deleteBlobFilesFromDisk(FieldValues fieldValues)
                                throws SQLException
deletes the blob files on disk

Parameters:
fieldValues - FieldValues to delete, called by
Throws:
SQLException

saveBlobFilesToDisk

protected void saveBlobFilesToDisk(FieldValues fieldValues)
                            throws SQLException
save the blob files to disk

Parameters:
fieldValues - FieldValues to update
Throws:
SQLException
IllegalArgumentException

getResultSetVector

protected ResultSetVector getResultSetVector(DbEventInterceptorData interceptorData,
                                             int startRow,
                                             int count)
                                      throws SQLException
DOCUMENT ME!

Parameters:
startRow -
count -
Returns:
the resultsetvector
Throws:
SQLException


Copyright © 2002-2006 DbForms. All Rights Reserved.