com.jstatcom.model
Class JSCDataEventSupport

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

public final class JSCDataEventSupport
extends java.lang.Object

A support class for JSCData objects that manages adding, removing and notification of the different JSCDataListener.

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

Author:
Markus Kraetzig

Constructor Summary
JSCDataEventSupport()
          JSCDataEventSupport constructor.
 
Method Summary
 void addListener(JSCDataListener evtListener, JSCDataEventTypes evtType)
          Adds evtListener to the list of listeners for events of type evtType.
 void dispatchEvent(JSCDataEvent evt)
          Dispatches evt by calling valueChanged of all registered listeners to events of type evt.getType.
 java.util.List<JSCDataListener> getListenersForType(JSCDataEventTypes evtType)
          Gets a list with all registered listeners for evtType.
 void removeListener(JSCDataListener 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

JSCDataEventSupport

public JSCDataEventSupport()
JSCDataEventSupport constructor.

Method Detail

addListener

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

Parameters:
evtListener - the JSCDataListener 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(JSCDataEvent evt)
Dispatches evt by calling valueChanged of all registered listeners to events of type evt.getType.

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

getListenersForType

public java.util.List<JSCDataListener> getListenersForType(JSCDataEventTypes 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(JSCDataListener evtListener)
Removes evtListener from all listener lists. Nothing happens if evtListener is currently not a listener.

Parameters:
evtListener - the JSCDataListener 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