ilog.views.util.event
Interface IlvEventListenerCollection

All Known Implementing Classes:
IlvAbstractEventListenerCollection, IlvEventListenerList, IlvEventListenerSet

public interface IlvEventListenerCollection

IlvEventListenerCollection defines the behavior of a thread-safe collection of event listeners. A class that fires events to a specific listener interface can use an IlvEventListenerCollection for registering event listeners and dispatching events to them:


   public class MyClass {
       IlvEventListenerCollection xyzListeners = new IlvEventListenerSet();

       public void addXYZListener (XYZListener aListener) {
           xyzListeners.addListener(aListener);
       }

       public void removeXYZListener (XYZListener aListener) {
           xyzListeners.removeListener(aListener);
       }

       public void notifyXYZListeners () {
           XYZEvent event = new XYZEvent(this);
           for (Iterator i = xyzListeners.getListeners(); i.hasNext(); ) {
               XYZListener xyzListener = (XYZListener) i.next();
               xyzListener.xyzHappened(event);
           }
       }
   }
 

Since:
JViews 5.5

Method Summary
 void addListener(EventListener listener)
          Adds the specified listener to this collection.
 boolean contains(EventListener listener)
          Returns whether this collection contains the specified listener.
 Iterator getListeners()
          Returns an iterator over the event listeners.
 void removeListener(EventListener listener)
          Removes the specified listener from this collection.
 void save(ObjectOutputStream s, String k)
          Serializes the collection of event listeners as a series of key-value pairs.
 

Method Detail

addListener

void addListener(EventListener listener)
Adds the specified listener to this collection.

Parameters:
listener - The listener.

removeListener

void removeListener(EventListener listener)
Removes the specified listener from this collection.

Parameters:
listener - The listener.

getListeners

Iterator getListeners()
Returns an iterator over the event listeners. It is safe to add or remove listeners from this collection during the course of the iteration.


contains

boolean contains(EventListener listener)
Returns whether this collection contains the specified listener.

Parameters:
listener - The listener.
Returns:
true if this collection contains listener, otherwise false.

save

void save(ObjectOutputStream s,
          String k)
          throws IOException
Serializes the collection of event listeners as a series of key-value pairs.

Parameters:
s - The object output stream to write the event listeners.
k - A key string that is written in front of each listener to identify its type.
Throws:
IOException


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.