You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



All Packages  This Package  Class Hierarchy  Class Search  Index

Class calypso.util.ListenerList

java.lang.Object
   |
   +----calypso.util.ListenerList

ListenersList is a thread-safe, reentrant class which contains a list of EventListeners and enforce some policy on event dispatching.

This class guarantees that events delivering is correctly accomplished even if listeners are removed from or added to the list during event dispatching. Added listeners, though, will not receive the current event.

Event listeners are returned LIFO.

User of this class must enclose event dispatching between startDelivering()/stopDelivering() calls and pass the state object to the nextListener call.

    ListenerListState state = eventListeners.startDelivering();

    SomeEventListener el = (SomeEventListener)eventListeners.nextListener(state);
    while (null != el) {
      el.someEvent();
      el = (SomeEventListener)eventListeners.nextListener(state);
    }

    eventListeners.stopDelivering(state);
 


public class  ListenerList
     extends java.lang.Object
{
          // Fields 2
     private Vector fEnumerators;
     private Vector fListeners;

          // Constructors 2
     public ListenerList();
     public ListenerList(int);

          // Methods 5
     public void addListener(EventListener);
     public EventListener nextListener(ListenerListState);
     public void removeListener(EventListener);
     public ListenerListState startDelivering();
     public void stopDelivering(ListenerListState);
}



Fields


fListeners

   private Vector fListeners


fEnumerators

   private Vector fEnumerators



Constructors


ListenerList

   public ListenerList(int aSize) 

Construct an array of listeners with the specifed size.

The array size is doubled every time an element is added to a full array.

Parameter Description
aSize the required size



ListenerList

   public ListenerList() 

Construct an array of listeners with the specifed size.

The array size is doubled every time an element is added to a full array.




Methods


addListener

   public void addListener(EventListener aListener) 

Set a new event listener for the class of events this ListenersList is mantaining.

Parameter Description
aListener a listener for the specific set of events



removeListener

   public void removeListener(EventListener aListener) 

Remove a listener from the list of listeners this ListenersList is mantaining.

Existing and valid state object are updated to reflect this change.

Parameter Description
aListener a listener for the specific set of events



startDelivering

   public ListenerListState startDelivering() 

A user of this class is starting event delivery.

The state object represents the state of the list for that user and has to be passed in every nextListener call.

Parameter Description
aListener a listener for the specific set of events

Returns:
ListenerListState the state of the list for the caller


stopDelivering

   public void stopDelivering(ListenerListState aState) 

A user completed or aborted event delivering.

Returns:
aState the state of the list for the caller


nextListener

   public EventListener nextListener(ListenerListState aState) 

Return the next EventListener in the array.

Listeners are returned with a last-in/first-out (LIFO) policy.

Returns:
aState the state of the list for the caller


All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.4