com.sas.collection
Class PropertyBagChangedListenerList

com.sas.collection.PropertyBagChangedListenerList
All Implemented Interfaces:
PropertyBagChangedListener, java.io.Serializable, java.util.EventListener

public final class PropertyBagChangedListenerList
implements java.io.Serializable, PropertyBagChangedListener

Manage a list of listeners for the com.sas.collection.PropertyBagChangedEvent event. This class is normally used in classes which implement the

See Also:
PropertyBagChangedEvent, PropertyBagChangedListener, com.sas.tools.GenerateEventListenerList, Serialized Form

Constructor Summary
PropertyBagChangedListenerList()
          Construct a default PropertyBagChangedListenerList
PropertyBagChangedListenerList(int initialIncrement)
          Construct a default PropertyBagChangedListenerList with a specific initialIncrement.
PropertyBagChangedListenerList(int initialIncrement, boolean logExceptions, boolean reThrowExceptions)
          Construct a PropertyBagChangedListenerList
 
Method Summary
 void add(PropertyBagChangedListener listener)
          Add a listener to the list of listeners.
 int count()
          return the number of listeners.
 PropertyBagChangedListener[] getListeners()
          Return a safe copy of the list of listeners for this event.
protected  void handleException(java.lang.RuntimeException exception)
          Handle an exception caught while delivering an event to a listener in the list.
 boolean isExceptionLoggingEnabled()
          Return true if this listener list is currently logging exceptions that are caught when delivering events to listeners in the list.
 boolean isExceptionReThrown()
          Return the setting indicating whether the event delivery loops re-throw any caught exceptions.
 void propertyBagChanged(PropertyBagChangedEvent event)
          Send a PropertyBagChangedEvent event to all the PropertyBagChangedListener objects in the listener list by invoking PropertyBagChangedListener.propertyBagChanged(com.sas.collection.PropertyBagChangedEvent event).
 void remove(PropertyBagChangedListener listener)
          Remove a listener from the list of listeners.
 void setExceptionLoggingEnabled(boolean logExceptions)
          Set whether this listener list logs exceptions caught when delivering an event to a listener.
 void setExceptionReThrown(boolean reThrow)
          Specify whether this listener list should rethrow exceptions caught when delivering an event to a listener.
 

Constructor Detail

PropertyBagChangedListenerList

public PropertyBagChangedListenerList()
Construct a default PropertyBagChangedListenerList


PropertyBagChangedListenerList

public PropertyBagChangedListenerList(int initialIncrement,
                                      boolean logExceptions,
                                      boolean reThrowExceptions)
Construct a PropertyBagChangedListenerList


PropertyBagChangedListenerList

public PropertyBagChangedListenerList(int initialIncrement)
Construct a default PropertyBagChangedListenerList with a specific initialIncrement.

Parameters:
initialIncrement - how much to grow the internal array of listeners when it fills up and must be extended to allow adding new listeners.
Method Detail

count

public int count()
return the number of listeners.

Returns:
the number of listeners.

setExceptionLoggingEnabled

public void setExceptionLoggingEnabled(boolean logExceptions)
Set whether this listener list logs exceptions caught when delivering an event to a listener.

Parameters:
logExceptions - if true, exceptions are logged to System.err
See Also:
setExceptionReThrown(boolean)

isExceptionLoggingEnabled

public boolean isExceptionLoggingEnabled()
Return true if this listener list is currently logging exceptions that are caught when delivering events to listeners in the list.

Returns:
true if caught exceptiosn will be logged.

handleException

protected void handleException(java.lang.RuntimeException exception)
Handle an exception caught while delivering an event to a listener in the list. If exception logging is enabled, print the exception and traceback to System.err. If exception rethrow is enabled, rethtrow the exception.

See Also:
setExceptionLoggingEnabled(boolean), setExceptionReThrown(boolean)

setExceptionReThrown

public void setExceptionReThrown(boolean reThrow)
Specify whether this listener list should rethrow exceptions caught when delivering an event to a listener. If true, then the event is not delivered to any other listeners in this listener class. It is expected that the class that owns this listener list will handle the exception in some way.

Parameters:
reThrow - if true, an exception caught when delivering an event to a listener is rethrown and the event is not delivered to any remaining listeners. Use extreme caution when setting this to true. If false, exceptions are ignored (although they may be logged).
See Also:
setExceptionLoggingEnabled(boolean)

isExceptionReThrown

public boolean isExceptionReThrown()
Return the setting indicating whether the event delivery loops re-throw any caught exceptions.

Returns:
true if caught exceptions are rethrown.

add

public void add(PropertyBagChangedListener listener)
Add a listener to the list of listeners.

Parameters:
listener - a new listener for the PropertyBagChangedEvent event

getListeners

public PropertyBagChangedListener[] getListeners()
Return a safe copy of the list of listeners for this event. The client may iterate over this list and send events to the clients in a thread safe manner; calls to addPropertyBagChangedListener or removePropertyBagChangedListener may take place but do not affect this copied listener list.

Returns:
a safe arry copy of the listener list. The array contains no null items.

remove

public void remove(PropertyBagChangedListener listener)
Remove a listener from the list of listeners.

Parameters:
listener - the listener to remove from the list.

propertyBagChanged

public void propertyBagChanged(PropertyBagChangedEvent event)
Send a PropertyBagChangedEvent event to all the PropertyBagChangedListener objects in the listener list by invoking PropertyBagChangedListener.propertyBagChanged(com.sas.collection.PropertyBagChangedEvent event). If necessary, the listener list is copied first, so the event is sent only to each item which is in the list at the time this method is called, even if adds or removes are performed after the event send has started.

Specified by:
propertyBagChanged in interface PropertyBagChangedListener
Parameters:
event - the event to send



Copyright © 2009 SAS Institute Inc. All Rights Reserved.