JProjects.eab.data
Class DAManager

java.lang.Object
  |
  +--JProjects.eab.data.DAManager

public abstract class DAManager
extends java.lang.Object
implements JProjects.eab.data.OnThreadActionExecutor

This abstract class defines the standard interface for a data access class. It provides access to a collection of rows from a table, and facilitates manipulation of rows by using a database cursor.

Author:
Alexander Jaremenko
< jarem@altavista.net >

Field Summary
protected  DataAccessObject _cachedObject
           
protected  DAPropertySupport _changes
           
protected  java.util.Vector _internalSequence
           
protected  ManagerCompleteSupport _managerSupport
           
protected  DAMap _map
           
protected  java.sql.ResultSet _rs
           
protected  java.sql.PreparedStatement _stmt
           
 
Constructor Summary
protected DAManager()
           
protected DAManager(DatastoreJDBC objD)
           
protected DAManager(int iCap, int iIncr)
           
 
Method Summary
protected  void _dbclose()
           
protected  int _dbfill(java.util.Vector res, int rowCnt)
           
 void _executeAction(java.lang.String acnN, java.lang.Object[] params)
           
protected  void _fillInternalSequence()
           
 void _handleException(java.lang.Exception ex)
           
protected  DataAccessObject _newElement()
           
protected  boolean _onBackground()
           
protected  void _putOnBackgroundThread(java.lang.String acnN, java.lang.Object[] params)
           
protected  void _setAfterLastRow(boolean isAfterLast)
           
protected  void _setBusy(boolean isBusy)
           
protected  void _setFetched(boolean isFetched)
           
protected  void _setOpen(boolean isOpen)
           
protected  void _setStmtOptions()
           
 void addManagerCompleteListener(ManagerCompleteListener l)
          Use this method to register a listener for method complete events.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
          Use this method to register a listener for property changes.
 int append(int rowC)
          Use this method to append the specified number of rows from the datastore to the current internal sequence that you have created by calling the fill method.
 int append(java.util.Vector v, int rowC)
          Use this method to append the specified number of rows from the datastore to the passed-in Vector object.
 void cancel()
          This method cancels the SQL statement that is currently running.
 void close()
          This method closes the cursor if one is open.
 void deleteFetched()
          This method, when implemented in a subclass (such as <class> Manager, which is generated by Data Access Builder), deletes the row corresponding to the fetched object, if there is one.
 DataAccessObject elementAsDataAccessObject()
           
 boolean fetchNext()
          This method fetches the attributes from the next row into the cached object (a default object is provided).
 boolean fetchNextInto(DataAccessObject o)
          This method fetches the attributes from the next row into a PersistentObject object.
 int fill(int rowC)
          This method fetches the specified number of rows into the cached vector, starting at the row after the last-fetched row.
 int fill(java.util.Vector v, int rowC)
          This method fetches the specified number of rows into the passed-in Vector object, starting at the row after the last-fetched row.
protected  void firePropertyChange(java.lang.String prN, java.lang.Object oldV, java.lang.Object newV)
           
abstract  DatastoreJDBC getCurrentDatastore()
          This method is to be implemented in a subclass.
 int getMaxRows()
           
 DatastoreJDBC getObjectsDatastore()
           
 int getQueryTimeout()
           
 boolean isAfterLastRow()
          This method tells you whether last row was already fetched.
 boolean isAsynchronous()
           
 boolean isBusy()
           
 boolean isFetched()
          This method tells you whether the current row has been fetched into the cached object.
 boolean isOpen()
          This method tells you whether a cursor is open and usable.
 java.util.Vector items()
           
protected abstract  DataAccessObject newElement()
           
abstract  void open(java.lang.String whereSfx)
          This abstract method can be implemented in a extending class, as it is in the classes generated by the Data Access Builder, to open a cursor for the rows specified in the passed-in SQL suffix.
 void prepareOpen(java.lang.String sqlSuffix, java.lang.Object[] vals, int[] types)
          Use this method when You want prepare and execute parametrized statement.
 void removeManagerCompleteListener(ManagerCompleteListener l)
          Use this method to remove the method complete listener on the manager object.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
          Use this method to remove the property change listener on the manager object.
abstract  void select(java.lang.String whereSfx)
          This abstract method can be implemented in an extending class so that it opens a cursor, retrieves rows as specified in the passed-in SQL predicate into a collection, and closes the cursor.
 void setAsynchronous(boolean isAs)
          This method lets you set whether the database methods are run on a background thread.
 void setMaxRows(int rc)
          Use this method to set the maximum number of rows that a result set can contain.
 void setObjectsDatastore(DatastoreJDBC oDs)
          This method sets the datastore associated with the current manager object to the DatastoreJDBC object passed in.
 void setQueryTimeout(int ti)
          Use this method to set the maximum time (in seconds) that the database driver will wait for a query to be run.
 void updateFetched()
          This method, when implemented in a subclass (such as <class> Manager, which is generated by Data Access Builder), updates the row corresponding to the fetched object, if there is one, with the cached object's attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_stmt

protected transient java.sql.PreparedStatement _stmt

_rs

protected transient java.sql.ResultSet _rs

_map

protected transient DAMap _map

_cachedObject

protected transient DataAccessObject _cachedObject

_internalSequence

protected transient java.util.Vector _internalSequence

_changes

protected transient DAPropertySupport _changes

_managerSupport

protected transient ManagerCompleteSupport _managerSupport
Constructor Detail

DAManager

protected DAManager()

DAManager

protected DAManager(int iCap,
                    int iIncr)

DAManager

protected DAManager(DatastoreJDBC objD)
Method Detail

_executeAction

public void _executeAction(java.lang.String acnN,
                           java.lang.Object[] params)
                    throws java.lang.Exception
Specified by:
_executeAction in interface JProjects.eab.data.OnThreadActionExecutor

_handleException

public void _handleException(java.lang.Exception ex)
Specified by:
_handleException in interface JProjects.eab.data.OnThreadActionExecutor

addManagerCompleteListener

public void addManagerCompleteListener(ManagerCompleteListener l)
Use this method to register a listener for method complete events.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Use this method to register a listener for property changes.

append

public int append(int rowC)
           throws DAException
Use this method to append the specified number of rows from the datastore to the current internal sequence that you have created by calling the fill method.
Parameters:
rowC - - number of rows to retrieve from DB.
Returns:
- number of rows retrieved.
Throws:
DAException - - when data access error occurs.

append

public int append(java.util.Vector v,
                  int rowC)
           throws DAException
Use this method to append the specified number of rows from the datastore to the passed-in Vector object.
Parameters:
v - - vector for storing of retrieved rows.
rowC - - number of rows to retrieve from DB.
Returns:
- number of rows retrieved.
Throws:
DAException - - when data access error occurs.

cancel

public void cancel()
            throws DAException
This method cancels the SQL statement that is currently running.
Throws:
DAException - - when data access error occurs.

close

public void close()
           throws DAException
This method closes the cursor if one is open.
Throws:
DAException - - when data access error occurs.

deleteFetched

public void deleteFetched()
                   throws DAException
This method, when implemented in a subclass (such as <class> Manager, which is generated by Data Access Builder), deletes the row corresponding to the fetched object, if there is one.
Throws:
DAException - - when data access error occurs.

prepareOpen

public void prepareOpen(java.lang.String sqlSuffix,
                        java.lang.Object[] vals,
                        int[] types)
                 throws DAException
Use this method when You want prepare and execute parametrized statement.
Parameters:
sqlSuffix - - where clause of the statement.
vals - - array of values of the parameters. Length of the array must correspond to the number of '?' placeholders in the statement.
types - - array of type codes for the parameters of the statement. Length of the array must be equal to the vals. Code values are defined in the java.sql.Types.
Throws:
DAException - - when data access error occurs.
See Also:
Types

elementAsDataAccessObject

public DataAccessObject elementAsDataAccessObject()
Returns:
- the current cached object (that is, the currently-fetched row).

fetchNext

public boolean fetchNext()
                  throws DAException
This method fetches the attributes from the next row into the cached object (a default object is provided).
Returns:
- true if fetch was OK, false - if the last row had been fetched.
Throws:
DAException - - when data access error occurs.

fetchNextInto

public boolean fetchNextInto(DataAccessObject o)
                      throws DAException
This method fetches the attributes from the next row into a PersistentObject object.
Parameters:
o - - PersistentObject where to fetch current row.
Returns:
- true if fetch was OK, false - if the last row had been fetched.
Throws:
DAException - - when data access error occurs.

fill

public int fill(int rowC)
         throws DAException
This method fetches the specified number of rows into the cached vector, starting at the row after the last-fetched row.
Parameters:
rowC - - number of rows to fetch.
Returns:
- number of rows fetched.
Throws:
DAException - - when data access error occurs.

fill

public int fill(java.util.Vector v,
                int rowC)
         throws DAException
This method fetches the specified number of rows into the passed-in Vector object, starting at the row after the last-fetched row.
Parameters:
v - - vector for storing fetched rows.
rowC - - number of rows to fetch.
Returns:
- number of rows fetched.
Throws:
DAException - - when data access error occurs.

getCurrentDatastore

public abstract DatastoreJDBC getCurrentDatastore()
This method is to be implemented in a subclass.
Returns:
- the object's current datastore.

getObjectsDatastore

public DatastoreJDBC getObjectsDatastore()
Returns:
- the datastore object associated with the current object.

getQueryTimeout

public int getQueryTimeout()
Returns:
- the setting for the maximum length of time (in seconds) that the database driver will wait for a query to run.

getMaxRows

public int getMaxRows()
Returns:
- the setting for the maximum number of rows that the result set of a select or open query can contain.

isAsynchronous

public boolean isAsynchronous()
Returns:
true if the current object is in asynchronous mode.

isBusy

public boolean isBusy()
Returns:
true if the current object is in asynchronous mode and interacting with DB server.

isFetched

public boolean isFetched()
This method tells you whether the current row has been fetched into the cached object.

isOpen

public boolean isOpen()
This method tells you whether a cursor is open and usable.

isAfterLastRow

public boolean isAfterLastRow()
This method tells you whether last row was already fetched.

items

public java.util.Vector items()
Returns:
- a vector containing references to all the row objects in the current cached sequence, thus providing you with access to the sequence.

open

public abstract void open(java.lang.String whereSfx)
                   throws DAException
This abstract method can be implemented in a extending class, as it is in the classes generated by the Data Access Builder, to open a cursor for the rows specified in the passed-in SQL suffix.
Parameters:
whereSfx - - where clause
Throws:
DAException - - when data access error occurs.

removeManagerCompleteListener

public void removeManagerCompleteListener(ManagerCompleteListener l)
Use this method to remove the method complete listener on the manager object.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Use this method to remove the property change listener on the manager object.

select

public abstract void select(java.lang.String whereSfx)
                     throws DAException
This abstract method can be implemented in an extending class so that it opens a cursor, retrieves rows as specified in the passed-in SQL predicate into a collection, and closes the cursor.
Parameters:
whereSfx - - where clause
Throws:
DAException - - when data access error occurs.

setAsynchronous

public void setAsynchronous(boolean isAs)
This method lets you set whether the database methods are run on a background thread.

setObjectsDatastore

public void setObjectsDatastore(DatastoreJDBC oDs)
This method sets the datastore associated with the current manager object to the DatastoreJDBC object passed in.

setQueryTimeout

public void setQueryTimeout(int ti)
Use this method to set the maximum time (in seconds) that the database driver will wait for a query to be run.

setMaxRows

public void setMaxRows(int rc)
Use this method to set the maximum number of rows that a result set can contain.

updateFetched

public void updateFetched()
                   throws DAException
This method, when implemented in a subclass (such as <class> Manager, which is generated by Data Access Builder), updates the row corresponding to the fetched object, if there is one, with the cached object's attributes.
Throws:
DAException - - when data access error occurs.

_dbclose

protected void _dbclose()
                 throws java.sql.SQLException

_dbfill

protected int _dbfill(java.util.Vector res,
                      int rowCnt)
               throws java.sql.SQLException,
                      DAException

_fillInternalSequence

protected void _fillInternalSequence()
                              throws java.sql.SQLException,
                                     DAException

newElement

protected abstract DataAccessObject newElement()

_newElement

protected DataAccessObject _newElement()

_onBackground

protected boolean _onBackground()

_putOnBackgroundThread

protected void _putOnBackgroundThread(java.lang.String acnN,
                                      java.lang.Object[] params)

_setBusy

protected void _setBusy(boolean isBusy)

_setFetched

protected void _setFetched(boolean isFetched)

_setOpen

protected void _setOpen(boolean isOpen)

_setAfterLastRow

protected void _setAfterLastRow(boolean isAfterLast)

_setStmtOptions

protected void _setStmtOptions()
                        throws java.sql.SQLException

firePropertyChange

protected void firePropertyChange(java.lang.String prN,
                                  java.lang.Object oldV,
                                  java.lang.Object newV)