com.primix.tapestry.record
Class SimplePageRecorder

java.lang.Object
  |
  +--com.primix.tapestry.record.PageRecorder
        |
        +--com.primix.tapestry.record.SimplePageRecorder
All Implemented Interfaces:
ChangeObserver, java.io.Externalizable, IPageRecorder, java.io.Serializable

public class SimplePageRecorder
extends PageRecorder
implements java.io.Externalizable

Simple implementation of IPageRecorder that stores page changes in-memory using collections.

The recorder must be made session persistant, either by being stored directly in the session, or being referenced from a session-persistant object. SimpleEngine simply stores a Map of these page recorders.

Version:
$Id: SimplePageRecorder.java,v 1.13 2001/06/20 18:43:10 hship Exp $
Author:
Howard Ship
See Also:
Serialized Form

Fields inherited from class com.primix.tapestry.record.PageRecorder
dirty, locked
 
Constructor Summary
SimplePageRecorder()
           
 
Method Summary
 void commit()
          Simply clears the dirty flag, because there is no external place to store changed page properties.
 java.util.Collection getChanges()
          Returns a Collection of IPageChange objects identifying changes to the page and its components.
 boolean getHasChanges()
          Returns true if the recorder has any changes recorded.
 void readExternal(java.io.ObjectInput in)
          Reads the state stored by writeExternal(ObjectOutput).
protected  void recordChange(java.lang.String componentPath, java.lang.String propertyName, java.lang.Object newValue)
          Records a change to a particular component.
 void writeExternal(java.io.ObjectOutput out)
          Writes the changes.
 
Methods inherited from class com.primix.tapestry.record.PageRecorder
isDirty, isLocked, observeChange, persistValue, restoreValue, rollback, setLocked
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimplePageRecorder

public SimplePageRecorder()
Method Detail

commit

public void commit()
            throws PageRecorderCommitException
Simply clears the dirty flag, because there is no external place to store changed page properties. Sets the locked flag to prevent subsequent changes from occuring now.
Overrides:
commit in class PageRecorder

getHasChanges

public boolean getHasChanges()
Returns true if the recorder has any changes recorded.

getChanges

public java.util.Collection getChanges()
Description copied from class: PageRecorder
Returns a Collection of IPageChange objects identifying changes to the page and its components.
Overrides:
getChanges in class PageRecorder

recordChange

protected void recordChange(java.lang.String componentPath,
                            java.lang.String propertyName,
                            java.lang.Object newValue)
Description copied from class: PageRecorder
Records a change to a particular component. Subclasses may cache these in memory, or record them externally at this time.

This method is responsible for setting the dirty flag if the described change is real.

Overrides:
recordChange in class PageRecorder
Following copied from class: com.primix.tapestry.record.PageRecorder
Parameters:
componentPath - the name of the component relative to the page which contains it. May be null if the change was to a property of the page itself.
propertyName - the name of the property which changed.
newValue - the new value for the property, which may also be null.
See Also:
IComponent.getIdPath()

readExternal

public void readExternal(java.io.ObjectInput in)
                  throws java.io.IOException,
                         java.lang.ClassNotFoundException
Reads the state stored by writeExternal(ObjectOutput).
Specified by:
readExternal in interface java.io.Externalizable

writeExternal

public void writeExternal(java.io.ObjectOutput out)
                   throws java.io.IOException
Writes the changes. Writes the number of changes as an int, which may be zero.

For each change, writes:

Specified by:
writeExternal in interface java.io.Externalizable