com.taursys.xml.event
Class Dispatcher

java.lang.Object
  extended bycom.taursys.xml.event.Dispatcher
Direct Known Subclasses:
CloseFormDispatcher, InitContextDispatcher, InitFormDispatcher, InputDispatcher, OpenFormDispatcher, ParameterDispatcher, RecycleDispatcher, RenderDispatcher, TriggerDispatcher

public abstract class Dispatcher
extends java.lang.Object

Component responsible for receiving and dispatching Events. Components should register with this component to be notified whenever their events occur.


Field Summary
protected  java.util.ArrayList components
           
protected  java.util.Map map
           
 
Constructor Summary
Dispatcher()
           
 
Method Summary
 void addNotify(Component c)
          Adds a component to the notification list unless it is already registered
 void dispatch()
          Dispatches an Event to each registered component with an empty key/value map.
 void dispatch(java.util.EventObject e)
          Dispatches the given Event to each registered component with an empty key/value Map.
 void dispatch(java.util.Map map)
          Dispatches an Event to each registered component with the given key/value Map.
abstract  void dispatchToComponent(Component c)
          Dispatches an Event to the given component.
protected  int getIndex()
          Get this Dispatcher's index.
protected  java.lang.String getParameter(java.lang.String key, java.lang.String defaultValue)
          Get the parameter value at the current index for the given key.
 Dispatcher getParentDispatcher()
          Get the parent Dispatcher for this Dispatcher.
protected  int getParentIndex()
          Get the parent index value, else this Dispatcher's index value if no parent.
protected  void incrementIndex()
          Increments the parameter array index by one.
 void removeNotify(Component c)
          Removes a component from the notification list if it is registered
protected  void resetIndex()
          Resets the parameter array index to zero.
 void setParentDispatcher(Dispatcher dispatcher)
          Set the parent Dispatcher for this Dispatcher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

components

protected java.util.ArrayList components

map

protected java.util.Map map
Constructor Detail

Dispatcher

public Dispatcher()
Method Detail

dispatchToComponent

public abstract void dispatchToComponent(Component c)
                                  throws java.lang.Exception
Dispatches an Event to the given component. Concrete Dispatchers must override this method to provide appropriate behavior.

Parameters:
c - the Component to dispatch the event to.
Throws:
java.lang.Exception - from the components dispatchEvent method if occurs.

dispatch

public void dispatch(java.util.Map map)
              throws java.lang.Exception
Dispatches an Event to each registered component with the given key/value Map. This method invokes the dispatchToComponent for each registered component.

Parameters:
map - a Map containing message key/values for dispatching
Throws:
java.lang.Exception

dispatch

public void dispatch()
              throws java.lang.Exception
Dispatches an Event to each registered component with an empty key/value map. This method invokes the dispatchToComponent for each registered component.

Throws:
java.lang.Exception

dispatch

public void dispatch(java.util.EventObject e)
              throws java.lang.Exception
Dispatches the given Event to each registered component with an empty key/value Map.

Parameters:
e - the Event to dispatch
Throws:
java.lang.Exception

getParameter

protected java.lang.String getParameter(java.lang.String key,
                                        java.lang.String defaultValue)
Get the parameter value at the current index for the given key. If the key is found then element at the current index in the String[] value is returned, otherwise the given defaultValue is returned. Normally the index will be zero unless the dispatcher is a multi-value type dispatcher.

Parameters:
key - the String key for the parameter value
defaultValue - the String to return if key is not present
Returns:
the the first parameter value for the given key

getParentIndex

protected int getParentIndex()
Get the parent index value, else this Dispatcher's index value if no parent.

Returns:
the parent index value, else this Dispatcher's index value if no parent.

getIndex

protected int getIndex()
Get this Dispatcher's index.

Returns:
this Dispatcher's index.

addNotify

public void addNotify(Component c)
Adds a component to the notification list unless it is already registered


removeNotify

public void removeNotify(Component c)
Removes a component from the notification list if it is registered


resetIndex

protected void resetIndex()
Resets the parameter array index to zero. The index is used by the getParameter method to determine which value from the map String array will be retrieved.


incrementIndex

protected void incrementIndex()
Increments the parameter array index by one. The index is used by the getParameter method to determine which value from the map String array will be retrieved.


getParentDispatcher

public Dispatcher getParentDispatcher()
Get the parent Dispatcher for this Dispatcher. The parent dispatch primary use is to control the index for the key/value map used by input type events.

Returns:
The parent Dispatcher for this Dispatcher

setParentDispatcher

public void setParentDispatcher(Dispatcher dispatcher)
Set the parent Dispatcher for this Dispatcher. The parent dispatch primary use is to control the index for the key/value map used by input type events.

Parameters:
dispatcher - The parent Dispatcher for this Dispatcher


Copyright © 2007 Martin T Phelan. All Rights Reserved.