/** * Add EventHandler to handlers list & search through the EventHandlers EventTypes, placing it in * the correct lists, so Events can be filtered correctly. */ public final void addEventHandler(final EventHandler _handler) { if (exists(_handler) == true) { Logger.println(_handler.getName() + "already exists within " + name, Logger.Verbosity.MAJOR); return; } handlers.add(_handler); final ArrayList<EventType> types = _handler.getWantedEventTypes(); if (types.isEmpty() == true || types.contains(Event.ALL_EVENT_TYPES) == true) { // Due to legacy we must assumme that a types size of 0, // represents a developer wishing to recieve all Events. // If the types contains ALL_EVENT_TYPES then only add it // to the ALL_EVENT_TYPES EventQueue. eventQueues.get(Event.ALL_EVENT_TYPES).addEventHandler(_handler); return; } for (final EventType type : types) { if (eventQueues.containsKey(type) == false) { addEventQueue(type, new EventQueue(type)); } eventQueues.get(type).addEventHandler(_handler); } }
public String toString() { final StringBuffer buffer = new StringBuffer(); buffer.append("[ Event Queue: " + name + ", "); for (final EventHandler handler : handlers) { buffer.append(handler.getName() + ", "); } buffer.append("]"); return buffer.toString(); }