at.spardat.xma.mdl.util
Class TransString

java.lang.Object
  extended byat.spardat.xma.mdl.util.TransString
All Implemented Interfaces:
Descriptive, Synchronization, Transactional

public final class TransString
extends java.lang.Object
implements Transactional, Synchronization, Descriptive

Encapsulates a String and adds Transactional behaviour to it. The value of the String may be retrieved using get. Upon default construction, an instance contains a null String.


Constructor Summary
TransString()
          Default constructor.
TransString(java.lang.String s)
          Constructs with a provided string.
 
Method Summary
 boolean changed()
          Yields true if this WidgetModel has changed since the last syncpoint.
 void commit()
          This method clears the change history.
 void describe(DNode n)
          describe puts all relevant information about this into the provided node.
 boolean equals(java.lang.Object obj)
           
 int estimateMemory()
          Estimates the number of bytes this object consumes in memory.
 void externalize(XmaOutput xo, boolean forceFull)
          Externalizing either saves the actual state or deltas (changes) in a provided XMAObjectOutput.
 java.lang.String get()
          Returns the value of this
 void internalize(XmaInput in)
          Updates the state of this with information of the given XMAObjectInput.
 void rollback()
          This method restores this Widget Model to its last syncpoint (which also becomes the new syncpoint).
 void set(java.lang.String s)
          This method sets a new value.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransString

public TransString()
Default constructor. The contained value is null.


TransString

public TransString(java.lang.String s)
Constructs with a provided string. The effect of calling this constructor is the same as using the default constructor and calling set(s) afterwards. This implies that changed() may be true after this constructor finishes.

Parameters:
s - the String to set
Method Detail

set

public void set(java.lang.String s)
This method sets a new value.

Parameters:
s - the String to set; may be null

get

public java.lang.String get()
Returns the value of this

Returns:
a String that may be null

changed

public boolean changed()
Description copied from interface: Transactional
Yields true if this WidgetModel has changed since the last syncpoint. Some models have a more complex state, e.g., a table has a domain and a selection, where either may change. In this case, subclasses will provide more detailed information on what aspect of the model really has changed.

Specified by:
changed in interface Transactional
Returns:
true if changed, false otherwise
See Also:
Transactional.changed()

rollback

public void rollback()
Description copied from interface: Transactional
This method restores this Widget Model to its last syncpoint (which also becomes the new syncpoint).

Specified by:
rollback in interface Transactional
See Also:
Transactional.rollback()

commit

public void commit()
Description copied from interface: Transactional
This method clears the change history. Calling rollback afterwards won't have any effect. This method defines a new syncpoint.

Specified by:
commit in interface Transactional
See Also:
Transactional.commit()

externalize

public void externalize(XmaOutput xo,
                        boolean forceFull)
                 throws java.io.IOException
Description copied from interface: Synchronization
Externalizing either saves the actual state or deltas (changes) in a provided XMAObjectOutput. The default behaviour is to serialize the changes if changes are beeing tracked. This behaviour may be overwritten by forceFull. If true, the complete state information is written.

If forceFull is false, the object implementing this interface must also implement Transactional. If the object implementing this is able to track changes, these are the changes since the last syncpoint.

Specified by:
externalize in interface Synchronization
Parameters:
xo - the serialization destination
forceFull - if true, the complete state is written and deltas are ignored.
Throws:
java.io.IOException - on serialization errors
See Also:
Synchronization.externalize(at.spardat.xma.serializer.XmaOutput, boolean)

internalize

public void internalize(XmaInput in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Description copied from interface: Synchronization
Updates the state of this with information of the given XMAObjectInput. in either contains changes or the complete new state information. If in contains changes the implementing class also must implement Transactional and the state after calling internalize is !Transactional.changed(), e.g., a syncpoint is defined.

This method is not allowed to throw Exceptions because that would leave models in an inconsistent state. Thrown exceptions are considered to be programming errors. Internalize must not throw technical exceptions which indicate system or ressource failures. That implies that the person implementing internalize is not allowed to access ressources outside the JVM, either directly or via calls to other methods. Examples of ressource access which must not be triggered are calls to communication of file system services.

Specified by:
internalize in interface Synchronization
Parameters:
in - the XMAObjectInput. If a XMAObjectInputChangeListener is set in the object in, it will be notified after applying changes read from in.
Throws:
java.lang.ClassNotFoundException - on serialization errors
java.io.IOException - on serialization errors
See Also:
Synchronization.internalize(at.spardat.xma.serializer.XmaInput)

equals

public boolean equals(java.lang.Object obj)
See Also:
Object.equals(java.lang.Object)

describe

public void describe(DNode n)
Description copied from interface: Descriptive
describe puts all relevant information about this into the provided node. The implementing method may construct subnodes of node.

Specified by:
describe in interface Descriptive
Parameters:
n - the node going to hold information about this.
See Also:
Descriptive.describe(at.spardat.xma.mdl.util.DNode)

estimateMemory

public int estimateMemory()
Estimates the number of bytes this object consumes in memory.