com.neeve.event
Class EventDispatcher

java.lang.Object
  extended by com.neeve.root.RootObject
      extended by com.neeve.event.EventObject
          extended by com.neeve.event.EventDispatcher
All Implemented Interfaces:
IEventDispatcher, IEventHandler

public abstract class EventDispatcher
extends EventObject
implements IEventDispatcher

Base class for all event dispatchers.

This class serves as the base class for all dispatchers. It implements dispatch by event type. When an event is received for dispatch, the class first delegates the dispatch to the derived class. If the derived class does not dispatch the event, then the event is dispatched to the handler registered for the event type. If no handler is registsred, then the event is dropped.

Threading:
This class is not safe for concurrent access by multiple threads.

Method Summary
 void addEventHandler(Class<? extends Event> type, IEventHandler handler)
          Add an event type handler.
 void onEvent(Event event)
          Implementation of IEventHandler.onEvent(com.neeve.event.Event)
 void removeEventHandler(Class<? extends Event> type, IEventHandler handler)
          Remove an event type handler.
 
Methods inherited from class com.neeve.root.RootObject
getChecked, getThreaded, getTracer, setChecked, setTracer
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

addEventHandler

public final void addEventHandler(Class<? extends Event> type,
                                  IEventHandler handler)
Add an event type handler.

Specified by:
addEventHandler in interface IEventDispatcher
Parameters:
type - The event type for which the handler is being installed.
handler - The handler being added.
Threading:
The thread safety of this method is determined by the dispatcher implementation. Refer to the implementation documentation for thread safety information pertaining to this method.

removeEventHandler

public final void removeEventHandler(Class<? extends Event> type,
                                     IEventHandler handler)
Remove an event type handler.

Specified by:
removeEventHandler in interface IEventDispatcher
Parameters:
type - The event type for which the handler is being removed.
handler - The handler being removed.
Threading:
The thread safety of this method is determined by the dispatcher implementation. Refer to the implementation documentation for thread safety information pertaining to this method.

onEvent

public void onEvent(Event event)
Implementation of IEventHandler.onEvent(com.neeve.event.Event)

Specified by:
onEvent in interface IEventHandler
Parameters:
event - The event to be handled.


Copyright © 2016 Neeve Research, LLC. All Rights Reserved.