Class EventDispatcher
java.lang.Object
com.aquima.interactions.foundation.events.EventDispatcher
- All Implemented Interfaces:
IEventChannel
,IEventDispatcher
,Serializable
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
ConstructorsConstructorDescriptionEventDispatcher
(int mask) Constructs the dispatcher with the event mask of supported events. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addEventListener
(IEventListener listener) This method will add the passed event listener to the list of listeners.void
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
removeEventListener
(IEventListener listener) This method will remove the specified event listener from the list of listeners.void
setParent
(IEventDispatcher parent) This method may be used to specify the parent event dispatcher.
-
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
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 interfaceIEventDispatcher
- 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 interfaceIEventChannel
- Returns:
- Bit-mask containing the event types that are supported by this event channel.
-
addEventListener
Description copied from interface:IEventChannel
This method will add the passed event listener to the list of listeners.- Specified by:
addEventListener
in interfaceIEventChannel
- Parameters:
listener
- The event listener that should be added.- Returns:
- boolean indicating is the listener was actually added.
-
removeEventListener
Description copied from interface:IEventChannel
This method will remove the specified event listener from the list of listeners.- Specified by:
removeEventListener
in interfaceIEventChannel
- Parameters:
listener
- The event listener that should be removed.- Returns:
- boolean indicating if the listener was actually removed.
-
fireEvent
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 interfaceIEventDispatcher
- Parameters:
eventObj
- Implementation of the IEvent class.
-