at.spardat.xma.mdl
Class WModel

java.lang.Object
  extended byat.spardat.xma.mdl.WModel
All Implemented Interfaces:
Descriptive, Synchronization, Transactional
Direct Known Subclasses:
ListDomWM, ListWM, SimpleWM, TableBaseWM, TreeWM

public abstract class WModel
extends java.lang.Object
implements Transactional, Synchronization, Descriptive

The base class for all WidgetModels.


Field Summary
static int S_NULL
          Some subclasses require style flags driving their behaviour.
 
Constructor Summary
WModel(short id, Page pm)
          Constructor
 
Method Summary
abstract  boolean changed()
          Yields true if this WidgetModel has changed since the last server side event (or creation).
 void cleanUpAfterServerEvent()
          A server event has been sucessfully executed.
abstract  void clear()
          Resets this WModel to an empty status.
abstract  void commit()
          This method clears the change history.
 void describe(DNode n)
          describe puts all relevant information about this into the provided node.
abstract  void equalsCS(WModel mServer, int syncPoint)
          Compares this widget model (which must be a client side one) with the server buddy mServer and returns true if they are correct with respect to syncPoint.
abstract  int estimateMemory()
          Provides the estimated number of bytes this widget model consumes in memory, asuming that it is in a committed state, i.e, there are no pending changes.
 short getId()
          Every widget model has an integer id which identifies the model within the scope of its page.
abstract  boolean handle(ModelChangeEvent event)
          All events that might change a WidgetModel are executed via this method.
abstract  void randomlyChange()
          A implementing subclass must make a random change to its widget model.
abstract  void rollback()
          This method restores this Widget Model to its state immediately after the last server side event (or creation).
 java.lang.String toString()
          The default implementation is to map this on a debug string.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface at.spardat.xma.mdl.Synchronization
externalize, internalize
 

Field Detail

S_NULL

public static final int S_NULL
Some subclasses require style flags driving their behaviour. S_NULL may be used as default.

See Also:
Constant Field Values
Constructor Detail

WModel

public WModel(short id,
              Page pm)
Constructor

Parameters:
id - a unique id identifying this WidgetModel within its page. This constant is known at compile time and produced by the UI generator.
pm - the Page this model belongs to
Method Detail

changed

public abstract boolean changed()
Yields true if this WidgetModel has changed since the last server side event (or creation). 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

rollback

public abstract void rollback()
This method restores this Widget Model to its state immediately after the last server side event (or creation).

Specified by:
rollback in interface Transactional

commit

public abstract void commit()
This method clears the change history. Calling rollback afterwards won't have any effect.

Specified by:
commit in interface Transactional

getId

public short getId()
Every widget model has an integer id which identifies the model within the scope of its page.

Returns:
the id

handle

public abstract boolean handle(ModelChangeEvent event)
All events that might change a WidgetModel are executed via this method.

Parameters:
event - the event carrying the information of a change.
Returns:
true if change has been applied, false if it has been rejected.

clear

public abstract void clear()
Resets this WModel to an empty status. Clearing applies to attributes that have not been set via the constructor of the widget model, rather those that may be changed via methods.


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)

toString

public java.lang.String toString()
The default implementation is to map this on a debug string.


randomlyChange

public abstract void randomlyChange()
A implementing subclass must make a random change to its widget model. This method is used to extensively test the synchronization mechanism.


equalsCS

public abstract void equalsCS(WModel mServer,
                              int syncPoint)
Compares this widget model (which must be a client side one) with the server buddy mServer and returns true if they are correct with respect to syncPoint. If syncPoint is zero, the client model has been externalized and the changes have been applied to the server model. If synPoint is one, the server model has been externalized and the chagnes have been applied to the client model.

This method is for debugging purpose and assumes that client and server models are running within the same VM. It tests if the models the programmer views after a synchronization operation are consistent.

This method requires that this is a client side model.

This method does not throw an exception if models are the same in terms of their contained model data. If it is allowed that models differ (for example some one way tables), this method must take this fact into account. If the models differ, this indicates a programming error and a RuntimeException is thrown.

Parameters:
mServer - the server side model partner for this.
syncPoint - 0 if the point in time is after a client to server sychnronization, 1 if the point is after a server to client synchronization.
Throws:
java.lang.RuntimeException - if models differ

estimateMemory

public abstract int estimateMemory()
Provides the estimated number of bytes this widget model consumes in memory, asuming that it is in a committed state, i.e, there are no pending changes. This is just to get a crude feeling about memory consumption. It needs not to be exact, which is also not possible as long as a JVM does not provide the numbers.

Returns:
estimated number of bytes this model consumes in memory

cleanUpAfterServerEvent

public void cleanUpAfterServerEvent()
A server event has been sucessfully executed. This method releases all memory in models that may be released. This method is only executed at the server side of XMA.