ca.grimoire.events
Class Dispatcher<L>

java.lang.Object
  extended by ca.grimoire.events.Dispatcher<L>
Type Parameters:
L - the event listener interface.

public class Dispatcher<L>
extends Object

Dispatches events for a given listener type. When events are fired, the known listeners are fired from the most-recently-added backwards (to allow for listeners that intercept events).


Constructor Summary
Dispatcher()
           
 
Method Summary
 void addListener(L listener)
          Adds a listener to the head of the listener queue.
 void fire(Firer<L> firer)
          Dispatches an event.
 void removeListener(L listener)
          Removes a listener from the dispatcher.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Dispatcher

public Dispatcher()
Method Detail

addListener

public void addListener(L listener)
Adds a listener to the head of the listener queue. Subsequent event firings will include the passed listener.

Parameters:
listener - the listener to add.

fire

public void fire(Firer<L> firer)
Dispatches an event. The firer's Firer.fire(Object) method will be applied to every listener in the dispatcher, from the most recently added to the oldest.

Parameters:
firer - the event firer implementation.

removeListener

public void removeListener(L listener)
Removes a listener from the dispatcher. If the same listener has been added more than once, this removes only the most recently added occurrence.

Parameters:
listener - the listener to remove.


Copyright © 2009 Grimoire Alchymia. All Rights Reserved.