at.spardat.xma.page
Class Page

java.lang.Object
  extended byat.spardat.xma.page.Page
All Implemented Interfaces:
Descriptive, Synchronization, Transactional
Direct Known Subclasses:
PageClient, PageServer

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

Base class for server and client side PageModels. A Page is a set of WidgetModels.


Constructor Summary
Page(boolean stateless, boolean atServer)
          Constructs a Page.
 
Method Summary
 boolean changed()
          Yields true if any of this PageModels WidgetModels has changed since the last server side event (or since creation if isNew).
 void commit()
          This method discards the change history in every WidgetModel.
 void describe(DNode n)
          describe puts all relevant information about this into the provided node.
 void display()
          Shows structure in a SWT window.
 void equalsCS(Page mServer, int syncPoint)
          This debugging purpose method compares all widget models of a client and server page if their state match at two specified syncpoints.
 void externalize(XmaOutput xo, boolean forceFull)
          This method writes either all widget models if forceFull or just the changed ones.
 short getId()
          Every page model has an integer id which identifies the page model within its component.
 int getNumWModels()
          Returns the number of Widget Models in this Page.
abstract  short getTypeId()
          A subclass is responsible for generating a unique id to identify the type of this Page.
 WModel getWModel(short idWModel)
          Returns a particular WidgetModel.
abstract  WModel[] getWModels()
          Returns an array of all WidgetModels of this page.
 void internalize(XmaInput in)
          Updates the state of this with information of the given XMAObjectInput.
 boolean isAtServer()
          Indicates whether this Page executes at the server side.
 boolean isStateless()
          Indicates whether this Page is stateless.
 void randomlyChange(int n)
          Make n random changes to each widget model of this page
 void rollback()
          Restores all WidgetModels of this PageModels to the state immediately after the last server side event (or at creation time if isNew()).
 void setId(short id)
          Assigns an id to this Page.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Page

public Page(boolean stateless,
            boolean atServer)
Constructs a Page.

Parameters:
stateless - indicates if this is a server stateless Page.
atServer - indicates if the created instance is living at the server side.
Method Detail

isStateless

public boolean isStateless()
Indicates whether this Page is stateless. This property specifies that the state of the page is dropped at the server side after a server side event.

Returns:
true if stateless

changed

public boolean changed()
Yields true if any of this PageModels WidgetModels has changed since the last server side event (or since creation if isNew).

Specified by:
changed in interface Transactional
Returns:
true if changed.

rollback

public void rollback()
Restores all WidgetModels of this PageModels to the state immediately after the last server side event (or at creation time if isNew()).

Specified by:
rollback in interface Transactional

commit

public void commit()
This method discards the change history in every WidgetModel.

Specified by:
commit in interface Transactional

externalize

public void externalize(XmaOutput xo,
                        boolean forceFull)
                 throws java.io.IOException
This method writes either all widget models if forceFull or just the changed ones.

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)

getId

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

Returns:
an id uniquely idenfying the page within its component.

setId

public void setId(short id)
Assigns an id to this Page. This method may only be called by the Component.

Parameters:
id - the assigned id for this Page
Throws:
java.lang.IllegalStateException - if there is allready set an id.

getNumWModels

public int getNumWModels()
Returns the number of Widget Models in this Page. The ids of the WidgetModels range from 0 up to getNumWModels()-1.

Returns:
the number of WidgetModels this Page contains.

getWModel

public WModel getWModel(short idWModel)
Returns a particular WidgetModel.

Parameters:
idWModel - the id of the WidgetModel to return.
Returns:
the requested WidgetModel.
Throws:
java.lang.IllegalArgumentException - if idModel less then zero or greater than getNumWModels()-1.

getWModels

public abstract WModel[] getWModels()
Returns an array of all WidgetModels of this page.

Returns:
array of WidgetModels. The returned array is not a copy, therefore it must not be modified.

getTypeId

public abstract short getTypeId()
A subclass is responsible for generating a unique id to identify the type of this Page. With the knowledge of type id and component it is possible to newly contruct a particular instance of a Page.

Returns:
the type id

isAtServer

public boolean isAtServer()
Indicates whether this Page executes at the server side.

Returns:
true, if this executes at the server side.

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()
See Also:
Object.toString()

display

public void display()
Shows structure in a SWT window.


randomlyChange

public void randomlyChange(int n)
Make n random changes to each widget model of this page


equalsCS

public void equalsCS(Page mServer,
                     int syncPoint)
This debugging purpose method compares all widget models of a client and server page if their state match at two specified syncpoints.

Parameters:
syncPoint - 0 after a client to server sync, 1 after a server to client sync.
See Also:
WModel.equalsCS(at.spardat.xma.mdl.WModel, int)