Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.voytechs.html.event
Class Dispatcher  view Dispatcher download Dispatcher.java

java.lang.Object
  extended bycom.voytechs.html.event.Dispatcher
Direct Known Subclasses:
HtmlDispatcher

public abstract class Dispatcher
extends java.lang.Object

An event dispatcher object. A user action triggers an event to be generated. Events are dispatched to event listeners. This is an abstract class and an appropriate implementation of it should be created, such as ServletDispatcher or CGI Dispatcher with appropriate hooks for processing the event conditions in whatever form they may be (ie. http forms).


Field Summary
private  int eventMask
           
private  java.util.Hashtable eventTypes
           
private  java.util.Hashtable listenerHash
           
private  int nextId
           
private  int registeredEventTypes
           
 
Constructor Summary
Dispatcher()
           
 
Method Summary
 void addListener(int eventType, int target, ListenerIf listener, java.lang.Object listenerData, java.lang.Object eventSource)
          Add a new listener onto the Vector list of a particular Observed target.
 void addListener(int eventType, int target, ListenerRequest request)
          Add a new listener onto the Vector list of a particular Observed target.
protected abstract  void dispatchEvent(ListenerIf listener, Event event, java.lang.Object data)
          Abstract method that is implementation depenedent.
 void enableEvents(int mask)
          Define which events to handle.
 int generateUniqId()
          Let the dispatcher generated uniq Id.
protected  void handleEvent(Event event)
          Find if there is a listener for this event.
protected  boolean isEventEnabled(int eventTypeId)
          Check to see if event of this type has been enabled If yes, return true
protected  void registerEventType(int eventType)
          Register a new Event Type with dispatcher.
 void removeListener(int target, ListenerIf listener)
          Remove a listener of a particual event.
 void removeSource(int eventType, int source)
           
protected abstract  void scanEvent(java.lang.Object source)
          Abstract method that is implementation dependent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

eventMask

private int eventMask

registeredEventTypes

private int registeredEventTypes

eventTypes

private java.util.Hashtable eventTypes

listenerHash

private java.util.Hashtable listenerHash

nextId

private int nextId
Constructor Detail

Dispatcher

public Dispatcher()
Method Detail

handleEvent

protected void handleEvent(Event event)
                    throws EventException
Find if there is a listener for this event. If yes, find the listener and its custom assigned data, then allow subclassed dispatcher to do the dispatching.


registerEventType

protected void registerEventType(int eventType)
Register a new Event Type with dispatcher. After registration, dispatcher will be able to handle these event types and dispatch them as they occure.


removeSource

public void removeSource(int eventType,
                         int source)
                  throws EventException

addListener

public void addListener(int eventType,
                        int target,
                        ListenerRequest request)
                 throws EventException
Add a new listener onto the Vector list of a particular Observed target. Basically a Hash table of Vectors. This is a convenience function.


addListener

public void addListener(int eventType,
                        int target,
                        ListenerIf listener,
                        java.lang.Object listenerData,
                        java.lang.Object eventSource)
                 throws EventException
Add a new listener onto the Vector list of a particular Observed target. Basically a Hash table of Vectors. This is a convenience function.


removeListener

public void removeListener(int target,
                           ListenerIf listener)
                    throws EventException
Remove a listener of a particual event.


enableEvents

public void enableEvents(int mask)
                  throws EventException
Define which events to handle.


isEventEnabled

protected boolean isEventEnabled(int eventTypeId)
Check to see if event of this type has been enabled If yes, return true


generateUniqId

public int generateUniqId()
Let the dispatcher generated uniq Id. This ID is uniq in the dispatcher scope. If multiple dispatchers are running the IDs of each of the dispatchers will overlap, but uniq in their own contexes.


scanEvent

protected abstract void scanEvent(java.lang.Object source)
                           throws EventException
Abstract method that is implementation dependent. It scans for conditions which would need to generate an event. All events are mapped and registered with the dispatcher via event type IDs.


dispatchEvent

protected abstract void dispatchEvent(ListenerIf listener,
                                      Event event,
                                      java.lang.Object data)
                               throws EventException
Abstract method that is implementation depenedent. It dispatches events to listners using their listener subclassed specific processEvent methods.