Class EventDispatcher

java.lang.Object
com.aquima.interactions.foundation.events.EventDispatcher
All Implemented Interfaces:
IEventChannel, IEventDispatcher, Serializable

public class EventDispatcher extends Object implements IEventDispatcher
The event dispatcher class is used to forward an event to it's listeners and parent dispatcher.
Since:
5.0
Author:
O. Kerpershoek
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    EventDispatcher(int mask)
    Constructs the dispatcher with the event mask of supported events.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    This method will add the passed event listener to the list of listeners.
    void
    fireEvent(IEvent eventObj)
    This method will forward the specified event to all listeners registered to the dispatcher, and optionally forward the event to the parent dispatcher when available.
    int
    This method returns a bit-mask containing all event types that are supported by this event channel.
    boolean
    This method will remove the specified event listener from the list of listeners.
    void
    This method may be used to specify the parent event dispatcher.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • EventDispatcher

      public EventDispatcher(int mask)
      Constructs the dispatcher with the event mask of supported events.
      Parameters:
      mask - Integer mask defining the event types that are supported by the dispatcher.
  • Method Details

    • setParent

      public void setParent(IEventDispatcher parent)
      Description copied from interface: IEventDispatcher
      This method may be used to specify the parent event dispatcher. The parent dispatcher is invoked after the listeners of this dispatcher have been notified of the event.
      Specified by:
      setParent in interface IEventDispatcher
      Parameters:
      parent - The parent event dispatcher.
    • getSupportedEvents

      public int getSupportedEvents()
      Description copied from interface: IEventChannel
      This method returns a bit-mask containing all event types that are supported by this event channel. The bit-mask is a bitwise OR of the diverse event types. To check whether a specific event-listener is supported, you can do the following:
       // This checks if a VALUE listener is supported
       if ((channel.getSupportedEvents() & IEvent.Mask.VALUE) != 0) {
         // VALUE event listeners that are supported
       }
       
      Specified by:
      getSupportedEvents in interface IEventChannel
      Returns:
      Bit-mask containing the event types that are supported by this event channel.
    • addEventListener

      public boolean addEventListener(IEventListener listener)
      Description copied from interface: IEventChannel
      This method will add the passed event listener to the list of listeners.
      Specified by:
      addEventListener in interface IEventChannel
      Parameters:
      listener - The event listener that should be added.
      Returns:
      boolean indicating is the listener was actually added.
    • removeEventListener

      public boolean removeEventListener(IEventListener listener)
      Description copied from interface: IEventChannel
      This method will remove the specified event listener from the list of listeners.
      Specified by:
      removeEventListener in interface IEventChannel
      Parameters:
      listener - The event listener that should be removed.
      Returns:
      boolean indicating if the listener was actually removed.
    • fireEvent

      public void fireEvent(IEvent eventObj)
      Description copied from interface: IEventDispatcher
      This method will forward the specified event to all listeners registered to the dispatcher, and optionally forward the event to the parent dispatcher when available.
      Specified by:
      fireEvent in interface IEventDispatcher
      Parameters:
      eventObj - Implementation of the IEvent class.