com.jstatcom.model
Class SymbolEventSupport

java.lang.Object
  extended by com.jstatcom.model.SymbolEventSupport

public final class SymbolEventSupport
extends java.lang.Object

A support class for Symbol objects that manages adding, removing and notification of the different SymbolListener. The events fired in dispatch are fired within the AWT event dispatching thread.

This class is not thread-save but clients must handle synchronization.

Author:
Markus Kraetzig

Constructor Summary
SymbolEventSupport()
          SymbolEventSupport constructor.
 
Method Summary
 void addListener(SymbolListener evtListener, SymbolEventTypes evtType)
          Adds evtListener to the list of listeners for events of type evtType.
 void dispatchEvent(SymbolEvent evt)
          Dispatches evt by calling valueChanged of all registered listeners to events of type evt.getType.
 java.util.List<SymbolListener> getListenersForType(SymbolEventTypes evtType)
          Gets a list with all registered listeners for evtType.
 void removeListener(SymbolListener evtListener)
          Removes evtListener from all listener lists.
 java.lang.String toString()
          Gets a string representation of this.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SymbolEventSupport

public SymbolEventSupport()
SymbolEventSupport constructor.

Method Detail

addListener

public void addListener(SymbolListener evtListener,
                        SymbolEventTypes evtType)
Adds evtListener to the list of listeners for events of type evtType.

Parameters:
evtListener - the SymbolListener that gets notified whenever an event of evtType occurs
evtType - the event type
Throws:
java.lang.IllegalArgumentException - if (evtListener == null || evtType == null)

dispatchEvent

public void dispatchEvent(SymbolEvent evt)
Dispatches evt by calling valueChanged of all registered listeners to events of type evt.getType. The valueChanged methods are called within the event dispatching thread.

Parameters:
evt - the event to be dispatched
Throws:
java.lang.IllegalArgumentException - if (evt == null)

getListenersForType

public java.util.List<SymbolListener> getListenersForType(SymbolEventTypes evtType)
Gets a list with all registered listeners for evtType.

Parameters:
evtType - the event type
Returns:
a copy of the respective list or an initialized list instance with size == 0 if no listeners are registered for evtType

removeListener

public void removeListener(SymbolListener evtListener)
Removes evtListener from all listener lists. Nothing happens if evtListener is currently not a listener.

Parameters:
evtListener - the SymbolListener to be removed
Throws:
java.lang.IllegalArgumentException - if (evtListener == null)

toString

public java.lang.String toString()
Gets a string representation of this.

Overrides:
toString in class java.lang.Object
Returns:
informative string representation