org.hydrateframework
Class AbstractHydrateObject

java.lang.Object
  extended by org.hydrateframework.AbstractHydrateObject
All Implemented Interfaces:
java.io.Serializable, HydrateObject

public abstract class AbstractHydrateObject
extends java.lang.Object
implements HydrateObject, java.io.Serializable

This class implements the HydrateObject interface and provides a base class for generated object implementations. This implements code to keep track of the ownership of the object and the object's state.

Version:
@(#)$Revision: 1.5 $
Author:
David Chamberlin
See Also:
Serialized Form

Field Summary
 
Fields inherited from interface org.hydrateframework.HydrateObject
ATTR_MANDATORY, ATTR_MULTIPLE, ATTR_MULTIPLEOPTIONAL, ATTR_NONE, ATTR_OPTIONAL, saveALL, savePOST, savePRE, STATECHANGED, STATEPOSTSAVE, STATEPRESAVE, STATEUNCHANGED, STATEUPDATING
 
Constructor Summary
AbstractHydrateObject(ObjectContext ctx)
          Each object is created belonging to an ObjectContext
 
Method Summary
abstract  java.io.PrintStream dump(java.io.PrintStream out, boolean title, int depth, int indent)
           
 boolean equals(java.lang.Object o)
           
 ObjectContext getContext()
           
abstract  java.lang.Class getImplementedIfc()
          Each business object concrete class implements a particular business object interface.
 boolean isChanged()
           
 boolean isPersisted()
          Determine if the object is persisted in the database.
 boolean isPreSaving()
           
 boolean isRemoved()
          Determine if a request has been made to remove the object from the database
 boolean isUpdating()
           
static java.lang.String makeIndent(int i)
          Helper method to be used by implementations of dump to indent the output to an appropriate level.
 void save(SaveContext ctx)
          This method is called by users of this business object to persist it in a persistent store.
 void setClean()
          Set the object to a 'clean' state.
 void setContext(ObjectContext ctx)
          Set the object context associated with the object
 void setDirty()
          Set the object to a 'dirty' state.
 void setNotPersisted()
          Call this method to indicate that the object has not been persisted in a database.
 void setPersisted()
          Call this method to indicate that the object has been persisted in a database.
 void setPostSaving()
          Set the object to a state indicating that it is finishing the update process on an object
 void setPreSaving()
          Set the object to a state indicating that it has been partially updated
 void setRemoved(boolean remove)
          Mark this object as having been deleted from the database.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.hydrateframework.HydrateObject
attributeType, forget, getDiscriminator, getFamily, getKey, isFieldPopulated, mergeDown, save, setAttrFromString, writeAttributesXML
 

Constructor Detail

AbstractHydrateObject

public AbstractHydrateObject(ObjectContext ctx)
Each object is created belonging to an ObjectContext

Parameters:
ctx - the context within which the object is being created. It is legal for this parameter to be null, but much of the infrastructure will not work if it is.
Method Detail

makeIndent

public static java.lang.String makeIndent(int i)
Helper method to be used by implementations of dump to indent the output to an appropriate level.


isChanged

public boolean isChanged()
Specified by:
isChanged in interface HydrateObject
Returns:
true if the object has changed (or has not yet been added to the database).

isUpdating

public boolean isUpdating()
Specified by:
isUpdating in interface HydrateObject
Returns:
true if the object is currently updating

isPreSaving

public boolean isPreSaving()
Specified by:
isPreSaving in interface HydrateObject
Returns:
true if the object has been partially updated. This will occur when an object is updated by virtue of a dependency on another object.

setPreSaving

public void setPreSaving()
Description copied from interface: HydrateObject
Set the object to a state indicating that it has been partially updated

Specified by:
setPreSaving in interface HydrateObject

setPostSaving

public void setPostSaving()
Description copied from interface: HydrateObject
Set the object to a state indicating that it is finishing the update process on an object

Specified by:
setPostSaving in interface HydrateObject

setClean

public void setClean()
Description copied from interface: HydrateObject
Set the object to a 'clean' state. isChanged will subsequently return false unless the object is not in the database. isUpdating will subsequently return false.

Specified by:
setClean in interface HydrateObject

setDirty

public void setDirty()
Description copied from interface: HydrateObject
Set the object to a 'dirty' state. isChanged will subsequently return true.

Specified by:
setDirty in interface HydrateObject

save

public final void save(SaveContext ctx)
                throws SaveException
Description copied from interface: HydrateObject
This method is called by users of this business object to persist it in a persistent store. The call will also save any dependent objects (ie. any that are navigable from this object) that have changed.

Specified by:
save in interface HydrateObject
Throws:
SaveException

setPersisted

public void setPersisted()
Description copied from interface: HydrateObject
Call this method to indicate that the object has been persisted in a database.

Specified by:
setPersisted in interface HydrateObject

setNotPersisted

public void setNotPersisted()
Description copied from interface: HydrateObject
Call this method to indicate that the object has not been persisted in a database.

Specified by:
setNotPersisted in interface HydrateObject

setRemoved

public void setRemoved(boolean remove)
Description copied from interface: HydrateObject
Mark this object as having been deleted from the database. When it is saved down to the database, the data corresponding to it will be removed there.

Specified by:
setRemoved in interface HydrateObject

isRemoved

public boolean isRemoved()
Description copied from interface: HydrateObject
Determine if a request has been made to remove the object from the database

Specified by:
isRemoved in interface HydrateObject

isPersisted

public boolean isPersisted()
Description copied from interface: HydrateObject
Determine if the object is persisted in the database.

Specified by:
isPersisted in interface HydrateObject
Returns:
true if the object is persisted.

getContext

public ObjectContext getContext()
Specified by:
getContext in interface HydrateObject
Returns:
the business object context associated with this object

setContext

public void setContext(ObjectContext ctx)
Description copied from interface: HydrateObject
Set the object context associated with the object

Specified by:
setContext in interface HydrateObject
Parameters:
ctx - the new context

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

getImplementedIfc

public abstract java.lang.Class getImplementedIfc()
Description copied from interface: HydrateObject
Each business object concrete class implements a particular business object interface. This function must return that interface. Note that this is not necessarily the same as the object's key's key class this.getKey().getKeyClass() since the key class is always the base business class and this method returns the actual interface that is being implemented.

Specified by:
getImplementedIfc in interface HydrateObject
Returns:
the implemented interface

dump

public abstract java.io.PrintStream dump(java.io.PrintStream out,
                                         boolean title,
                                         int depth,
                                         int indent)


Copyright © 2000 The Hydrate Project. All Rights Reserved.