facets.util
Class StatefulCore

java.lang.Object
  extended by facets.util.Tracer
      extended by facets.util.StatefulCore
All Implemented Interfaces:
Stateful, Titled, java.io.Serializable
Direct Known Subclasses:
HtmlContent, SelectionView, TypedNode

public class StatefulCore
extends Tracer
implements Stateful, Titled

Basic Stateful which stamps each state change.

Stamping is useful when

Non-transient member variables in subclasses must be Serializable; transient members may not be final. Latency due to serialization can be minimised by defining a small group of persistent members and recreating transient members during setState.

See Also:
Serialized Form

Constructor Summary
StatefulCore(java.lang.String title)
          Unique constructor.
 
Method Summary
 Stateful copyState()
          Implements interface method.
 void setState(java.lang.Object src)
          Implements interface method.
 void setTitle(java.lang.String title)
          Sets the text to be returned by title()
 boolean stateEquals(Stateful s)
          Invalid stub implementation.
 java.lang.Object stateStamp()
          Implements interface method.
 java.lang.String title()
          Implements interface method.
 java.lang.String toString()
          Re-implementation wrapping Debug.info(Object).
 java.lang.Object updateStateStamp()
          Implements interface method.
 
Methods inherited from class facets.util.Tracer
trace, trace, trace, trace, trace, traceDebug, traceDebug, traceObjectText, traceOutput, traceOutputWithClass
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StatefulCore

public StatefulCore(java.lang.String title)
Unique constructor.

Also calls updateStateStamp().

Parameters:
title - passed to setTitle(String)
Method Detail

copyState

public Stateful copyState()
Implements interface method.

Wrapper for Util.deserializedCopy(Serializable)

Specified by:
copyState in interface Stateful

setState

public void setState(java.lang.Object src)
Implements interface method.

Does not actually set any state, but does change the value returned by stateStamp(): if updating itself by calling updateStateStamp(), otherwise by casting src to a Stateful and copying its stateStamp()

Specified by:
setState in interface Stateful
Parameters:
src - must be non-null and interpretable by the implementation as state information; it will usually be another instance of the Stateful's class.

stateEquals

public boolean stateEquals(Stateful s)
Invalid stub implementation.

Specified by:
stateEquals in interface Stateful
Parameters:
s - to compare

stateStamp

public final java.lang.Object stateStamp()
Implements interface method.

Specified by:
stateStamp in interface Stateful
Returns:
an Integer unique amongst all states of all Statefuls

updateStateStamp

public final java.lang.Object updateStateStamp()
Implements interface method.

Increments the value to be returned by stateStamp().

Specified by:
updateStateStamp in interface Stateful
Returns:
the new value

title

public final java.lang.String title()
Implements interface method.

Specified by:
title in interface Titled
Returns:
the text passed successfully to setTitle(String)

setTitle

public final void setTitle(java.lang.String title)
Sets the text to be returned by title()


toString

public java.lang.String toString()
Re-implementation wrapping Debug.info(Object).

Overrides:
toString in class java.lang.Object