JProjects.eab.data
Class PersistentObject

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

public abstract class PersistentObject
extends java.lang.Object
implements java.lang.Cloneable, java.io.Serializable, JProjects.eab.data.OnThreadActionExecutor, DataAccessObject

This abstract class defines the standard interface for data access classes. It provides interfaces for adding, deleting, retrieving, and updating a row from a table. The Data Access Builder generates classes that implement this class.

Author:
Alexander Jaremenko
< jarem@altavista.net >
See Also:
Serialized Form

Field Summary
protected  DAPropertySupport _changes
           
protected  POCompleteSupport _poSupport
           
protected  boolean _sendingAttributeEvents
           
protected  java.sql.PreparedStatement _stmt
           
 
Constructor Summary
PersistentObject()
          Default constructor.
PersistentObject(DatastoreJDBC ods)
          This constructor creates a persistent object with an associated datastore.
 
Method Summary
abstract  void _executeAction(java.lang.String action, java.lang.Object[] params)
           
 void _handleException(java.lang.Exception ex)
           
protected  boolean _isSendingAttributeEvents()
           
protected  boolean _onBackground()
           
protected  void _putOnBackgroundThread(java.lang.String acnN, java.lang.Object[] params)
           
protected  void _setBusy(boolean b)
           
protected  void _setSendingAttributeEvents(boolean flag)
           
 void addPOCompleteListener(POCompleteListener l)
          Use this method to register a listener for method complete events.
 void addPropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void cancel()
          This method cancels the SQL statement currently running on a background thread.
abstract  java.lang.Object clone()
          This method allows a class that implements PersistentObject to use the clone method.
protected  void firePropertyChange(java.lang.String propName, java.lang.Object oldV, java.lang.Object newV)
           
abstract  java.lang.Object[] getAttributes()
           
abstract  java.lang.String[] getAttributeStrings()
           
abstract  DatastoreJDBC getCurrentDatastore()
          Implemented in subclass wich is generated by Data Access Builder.
 PODataId getObjectDataId()
          This method, will be overridden in a subclass (such as <class> , which is generated by Data Access Builder) to return the DataId if the current object has a DataId.
 DatastoreJDBC getObjectsDatastore()
          This method returns the datastore object associated with the current object, or null if one has not been associated with the object.
 boolean hasDataId()
          This method will be overridden in a subclass (such as <class> , which is generated by Data Access Builder) if the current object has a DataID (and is therefore retrievable).
 boolean isAsynchronous()
          This method tells you whether methods are set to run on a background thread or not.
 boolean isBusy()
          This method tells you whether the object is running a method in the background.
 boolean isModified()
          Use this method to determine whether any of the current PersistentObject's properties has been changed.
abstract  boolean isReadOnly()
          This method, when implemented in a subclass (such as <class> , which is generated by Data Access Builder), will tell you whether the current object's class is read-only or not.
 void removePOCompleteListener(POCompleteListener l)
          Use this method to remove the method complete listener on the PersistentObject.
 void removePropertyChangeListener(java.beans.PropertyChangeListener l)
           
 void setAsynchronous(boolean af)
          This method lets you set whether the database methods are run on a background thread.
 void setModified(boolean mf)
          Use this method to change the isModified setting.
 void setObjectDataId(PODataId di)
          This method will be overridden in a subclass (such as <class>, which generated by Data Access Builder) to set the DataId if the current object has a DataId.
 void setObjectsDatastore(DatastoreJDBC obDs)
          This method lets you associate a datastore object with the current persistent object.
 java.lang.String toString()
          This method returns a string made up of the object's attributes.
abstract  java.lang.String toString(java.lang.String delim)
          This method, when implemented in a subclass (such as <class>, which is generated by Data Access Builder), returns a string made up of the object's attributes.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_stmt

protected transient java.sql.PreparedStatement _stmt

_changes

protected DAPropertySupport _changes

_poSupport

protected transient POCompleteSupport _poSupport

_sendingAttributeEvents

protected transient boolean _sendingAttributeEvents
Constructor Detail

PersistentObject

public PersistentObject()
Default constructor.

PersistentObject

public PersistentObject(DatastoreJDBC ods)
This constructor creates a persistent object with an associated datastore.
Parameters:
ods - - a datastore object.
Method Detail

_executeAction

public abstract void _executeAction(java.lang.String action,
                                    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

addPOCompleteListener

public void addPOCompleteListener(POCompleteListener l)
Use this method to register a listener for method complete events.
Parameters:
l - - a POCompleteListener to listen for method complete events.

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener l)
Specified by:
addPropertyChangeListener in interface DataAccessObject

cancel

public void cancel()
            throws DAException
This method cancels the SQL statement currently running on a background thread.
Throws:
DAException - with message ID CANCEL_FAILED if it is unable to cancel the statement.

clone

public abstract java.lang.Object clone()
This method allows a class that implements PersistentObject to use the clone method.
Overrides:
clone in class java.lang.Object
Returns:
an Object with the same attibute values as the current PersistentObject.

getCurrentDatastore

public abstract DatastoreJDBC getCurrentDatastore()
Implemented in subclass wich is generated by Data Access Builder. Returns the datastore object associated with the current object, unless it is null. If the object's datastore is null, it returns the class datastore, unless that is also null, in which case it returns the application datastore (which may be null).
Returns:
DatastoreJDBC object associated with the current object.

getObjectDataId

public PODataId getObjectDataId()
This method, will be overridden in a subclass (such as <class> , which is generated by Data Access Builder) to return the DataId if the current object has a DataId.
Returns:
the objects PODataId if it has an associated DataId, or null if it does not.

getObjectsDatastore

public DatastoreJDBC getObjectsDatastore()
This method returns the datastore object associated with the current object, or null if one has not been associated with the object.
Specified by:
getObjectsDatastore in interface DataAccessObject
Returns:
DatastoreJDBC object associated with the current object.

hasDataId

public boolean hasDataId()
This method will be overridden in a subclass (such as <class> , which is generated by Data Access Builder) if the current object has a DataID (and is therefore retrievable).
Returns:
a boolean value of true if the current object has an associated DataId, or false if it does not.

isAsynchronous

public boolean isAsynchronous()
This method tells you whether methods are set to run on a background thread or not. By default, this setting is off.
Returns:
boolean value of true if background thread support is turned on, or false if it is not.

isBusy

public boolean isBusy()
This method tells you whether the object is running a method in the background.
Returns:
boolean value of true if the object is currently running a method on a background thread, or false if it is not.

isModified

public boolean isModified()
Use this method to determine whether any of the current PersistentObject's properties has been changed.
Specified by:
isModified in interface DataAccessObject
Returns:
boolean value of true if at least one of the properties has changed, or false if none has changed.

isReadOnly

public abstract boolean isReadOnly()
This method, when implemented in a subclass (such as <class> , which is generated by Data Access Builder), will tell you whether the current object's class is read-only or not.
Returns:
a boolean value of true if the current object is read-only, or false if it is not.

removePOCompleteListener

public void removePOCompleteListener(POCompleteListener l)
Use this method to remove the method complete listener on the PersistentObject.
Parameters:
l - - the POCompleteListener you wish to remove.

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener l)
Specified by:
removePropertyChangeListener in interface DataAccessObject

setAsynchronous

public void setAsynchronous(boolean af)
This method lets you set whether the database methods are run on a background thread. By default, this background thread support is turned off.
Parameters:
af - - a boolean value of true to run methods on background thread, or false to turn background thread off.

setModified

public void setModified(boolean mf)
Use this method to change the isModified setting.
Specified by:
setModified in interface DataAccessObject
Parameters:
mf - - a boolean value indicating whether an attribute from the current PersistentObject has been modified: true if at least one has been modified, or false if none has.

setObjectDataId

public void setObjectDataId(PODataId di)
                     throws DAException
This method will be overridden in a subclass (such as <class>, which generated by Data Access Builder) to set the DataId if the current object has a DataId.
Parameters:
di - - new PODataId object for this one.

setObjectsDatastore

public void setObjectsDatastore(DatastoreJDBC obDs)
This method lets you associate a datastore object with the current persistent object. If you want the object to be associated with no datastore, pass in null.
Specified by:
setObjectsDatastore in interface DataAccessObject
Parameters:
obDs - - - the DatastoreJDBC object you want to associate with the current object.

toString

public java.lang.String toString()
This method returns a string made up of the object's attributes. Simply calls toString(".").
Overrides:
toString in class java.lang.Object
Returns:
a String containing the attributes.

toString

public abstract java.lang.String toString(java.lang.String delim)
This method, when implemented in a subclass (such as <class>, which is generated by Data Access Builder), returns a string made up of the object's attributes.
Parameters:
delim - - a string used to separate the toString representation of each attribute.
Returns:
a String containing the attributes.

getAttributes

public abstract java.lang.Object[] getAttributes()
Specified by:
getAttributes in interface DataAccessObject

getAttributeStrings

public abstract java.lang.String[] getAttributeStrings()
Specified by:
getAttributeStrings in interface DataAccessObject

_isSendingAttributeEvents

protected boolean _isSendingAttributeEvents()

_setSendingAttributeEvents

protected void _setSendingAttributeEvents(boolean flag)

_onBackground

protected boolean _onBackground()

_putOnBackgroundThread

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

_setBusy

protected void _setBusy(boolean b)

firePropertyChange

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