Package net.sf.basedb.util.bfs
Class MultiEventHandler
- java.lang.Object
-
- net.sf.basedb.util.bfs.MultiEventHandler
-
- All Implemented Interfaces:
EventHandler
public class MultiEventHandler extends Object implements EventHandler
Event handler implementation that forwards a single event to multiple event handlers. This is useful since a parser only sends the event to a single handler. The event is forwarded to all registered event handlers in the order they have been registered.- Version:
- 2.15
- Author:
- Nicklas
- Last modified
- $Date: 2010-01-27 14:03:33 +0100 (on, 27 jan 2010) $
-
-
Field Summary
Fields Modifier and Type Field Description private List<EventHandler>
handlers
-
Constructor Summary
Constructors Constructor Description MultiEventHandler()
Create a new event handler.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEventHandler(EventHandler e)
Adds an event handler.<T> void
handleEvent(EventType<T> eventType, T eventData, BfsParser parser)
Resends the incoming event to all registered event handlers.void
removeEventHandler(EventHandler e)
Removes an event handler.
-
-
-
Field Detail
-
handlers
private List<EventHandler> handlers
-
-
Constructor Detail
-
MultiEventHandler
public MultiEventHandler()
Create a new event handler. UseaddEventHandler(EventHandler)
to add the event handlers that the events should be forwarded to.
-
-
Method Detail
-
addEventHandler
public void addEventHandler(EventHandler e)
Adds an event handler.
-
removeEventHandler
public void removeEventHandler(EventHandler e)
Removes an event handler.
-
handleEvent
public <T> void handleEvent(EventType<T> eventType, T eventData, BfsParser parser)
Resends the incoming event to all registered event handlers.- Specified by:
handleEvent
in interfaceEventHandler
- Parameters:
eventType
- The type of event. See the parser documentation for more information about the event types it generateseventData
- The data that is associated with the eventparser
- The parser that is resposible for parsing the file
-
-