net.spy.db
Class AbstractSavable

java.lang.Object
  extended bynet.spy.SpyObject
      extended bynet.spy.db.AbstractSavable
All Implemented Interfaces:
Savable, SavableNode

public abstract class AbstractSavable
extends SpyObject
implements SavableNode

Abstract implementation of SavableNode.


Constructor Summary
protected AbstractSavable()
          Get an instance of AbstractSavable.
 
Method Summary
protected  void finalize()
          If this object is still dirty during finalization, log it.
 Collection getPostSavables(SaveContext context)
          Get the dependent objects for this Savable.
 Collection getPreSavables(SaveContext context)
          Get the objects that need to be saved before this object.
 Collection getSavables(SaveContext context)
          Get the dependent objects for this Savable.
 boolean isModified()
          Indicate whether this object has been modified.
 boolean isNew()
          Indicate whether this object is new.
 void modify()
          Mark this AbstractSavable as modified.
protected  void setModified(boolean to)
          Set the ``modified'' flag for this object.
protected  void setNew(boolean to)
          Set the ``new'' flag for this object.
protected  void setSaved()
          Unset the flags indicating that this object needs to be saved.
 
Methods inherited from class net.spy.SpyObject
getLogger
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.spy.db.Savable
save
 

Constructor Detail

AbstractSavable

protected AbstractSavable()
Get an instance of AbstractSavable. An object instantiated with this constructor will have the new flag set. If this is not desirable, unset it.

Method Detail

isNew

public boolean isNew()
Indicate whether this object is new.

Specified by:
isNew in interface Savable

isModified

public boolean isModified()
Indicate whether this object has been modified.

Specified by:
isModified in interface Savable

setNew

protected void setNew(boolean to)
Set the ``new'' flag for this object.

Parameters:
to - the new value of the new flag

setModified

protected void setModified(boolean to)
Set the ``modified'' flag for this object.

Parameters:
to - the new value for the modified flag

modify

public void modify()
Mark this AbstractSavable as modified.


getSavables

public Collection getSavables(SaveContext context)
Get the dependent objects for this Savable. The default implementation returns null, indicating that there are no dependent objects.

Specified by:
getSavables in interface SavableNode

getPreSavables

public Collection getPreSavables(SaveContext context)
Get the objects that need to be saved before this object. The default implementation returns null, indicating that there are no prerequisite objects.

Specified by:
getPreSavables in interface SavableNode
Parameters:
context - SaveContext being used in this Saver session
Returns:
a collection of objects this SavableNode depends on

getPostSavables

public Collection getPostSavables(SaveContext context)
Get the dependent objects for this Savable. The default implementation returns null, indicating that there are no dependent objects.

Specified by:
getPostSavables in interface SavableNode
Parameters:
context - SaveContext being used in this Saver session
Returns:
a collection of objects this SavableNode depends on

setSaved

protected void setSaved()
Unset the flags indicating that this object needs to be saved.


finalize

protected void finalize()
                 throws Throwable
If this object is still dirty during finalization, log it.

Throws:
Throwable