com.ohrasys.app
Class AbstractAppModel

java.lang.Object
  extended by com.ohrasys.app.AbstractAppModel
All Implemented Interfaces:
AppControllerEventListener, java.awt.event.ActionListener, java.util.EventListener

public abstract class AbstractAppModel
extends java.lang.Object
implements AppControllerEventListener

A basic application model which should be subclassed and specialized by specific application implementations by implementing the processEvent method.


Field Summary
protected  AppModelEventListener controller
          The controller listening to this application model
 
Constructor Summary
AbstractAppModel()
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent evt)
          A method to perform an processing of actions received by the application controller.
protected  void notifyController(java.awt.event.ActionEvent event)
          Issues events from this application model to the application controller.
protected abstract  java.awt.event.ActionEvent processEvent(java.awt.event.ActionEvent evt)
          The method that processes incoming events.
 void setController(AppModelEventListener controller)
          Adds the controller as a listener of this model.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

controller

protected transient AppModelEventListener controller
The controller listening to this application model

Constructor Detail

AbstractAppModel

public AbstractAppModel()
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent evt)
A method to perform an processing of actions received by the application controller.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
evt - The event to process.

setController

public void setController(AppModelEventListener controller)
                   throws java.util.TooManyListenersException
Adds the controller as a listener of this model.

Parameters:
controller - The controller that will listen to this model
Throws:
java.util.TooManyListenersException - If more than one controller is being registered.

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object
Returns:
The physical address of this instance.

processEvent

protected abstract java.awt.event.ActionEvent processEvent(java.awt.event.ActionEvent evt)
The method that processes incoming events.

Parameters:
evt - The incoming event from the controller
Returns:
The outgoing response event to the controller. This method should return null if no response is required. For instance if a the controller sends a request to change a model member variable but the new value is the same as the existing value, then no action need be taken, therefore no response should be generated.

notifyController

protected void notifyController(java.awt.event.ActionEvent event)
Issues events from this application model to the application controller.

Parameters:
event - The event to issue.