net.rim.device.api.collection.util
Class CollectionListenerManager

java.lang.Object
  |
  +--net.rim.device.api.collection.util.CollectionListenerManager
All Implemented Interfaces:
CollectionEventSource

public class CollectionListenerManager
extends Object
implements CollectionEventSource

Class that can manage a list of CollectionListener objects that register to receive collection events.


Constructor Summary
CollectionListenerManager()
          Constructs a new CollectionListManager instance.
 
Method Summary
 void addCollectionListener(Object listener)
          Registers a new collection listener.
 void clearOut()
          Flush this manager's listener list.
 void fireElementAdded(Collection collection, Object element)
          Sends add event to the list of listeners.
 void fireElementRemoved(Collection collection, Object element)
          Sends remove event to the list of listeners.
 void fireElementUpdated(Collection collection, Object oldElement, Object newElement)
          Sends update event to the list of listeners.
 void fireReset(Collection collection)
          Sends reset event to the list of listeners.
 void fireReset(Collection collection, Object context)
          Sends reset event to the list of listeners.
 void forEachListener(Collection collection, CollectionListenerAction action)
          Performs a callback for each registered listener.
 boolean isEmpty()
          Determines if this manager's listener list is empty.
 void removeCollectionListener(Object listener)
          Unregisters a collection listener.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CollectionListenerManager

public CollectionListenerManager()
Constructs a new CollectionListManager instance.

Method Detail

addCollectionListener

public void addCollectionListener(Object listener)
Registers a new collection listener.

Parameters:
listener - Collection event listener to add to this manager's list.

clearOut

public void clearOut()
Flush this manager's listener list.

Invoke this method to remove all the current listeners registered with this manager.


fireElementAdded

public void fireElementAdded(Collection collection,
                             Object element)
Sends add event to the list of listeners.

When this manager's associated collection adds a new element, it can send an add message to its listeners managed by this manager.

Parameters:
collection - Changed collection.
element - Element added.

fireElementRemoved

public void fireElementRemoved(Collection collection,
                               Object element)
Sends remove event to the list of listeners.

When this manager's associated collection removes an element, it can send a remove message to its listeners managed by this manager.

Parameters:
collection - Changed collection.
element - Element removed.

fireElementUpdated

public void fireElementUpdated(Collection collection,
                               Object oldElement,
                               Object newElement)
Sends update event to the list of listeners.

When this manager's associated collection updates an element, it can send an update message to its listeners managed by this manager.

Parameters:
collection - Changed collection.
oldElement - Element that was replaced.
newElement - New element that replaced the old element.

fireReset

public void fireReset(Collection collection)
Sends reset event to the list of listeners.

When this manager's associated collection drastically changes, it can send a reset message to its listeners managed by this manager. The listening collections should reset their collections (erase their contents and reload from the notifying source).

Parameters:
collection - Changed collection.

fireReset

public void fireReset(Collection collection,
                      Object context)
Sends reset event to the list of listeners.

When this manager's associated collection drastically changes, it can send a reset message to its listeners managed by this manager. The listening collections should reset their collections (erase their contents and reload from the notifying source).

Parameters:
collection - Changed collection.
context - Context object for reset.
Since:
JDE 4.1.0

forEachListener

public void forEachListener(Collection collection,
                            CollectionListenerAction action)
Performs a callback for each registered listener.

Invoke this method to prompt this manager's associated collection to perform an action for each registered listener.

Parameters:
collection - Collection to perform the action.
action - Action to perform.

isEmpty

public boolean isEmpty()
Determines if this manager's listener list is empty.

Returns:
True if this manager currently has no registered listeners; otherwise, false.

removeCollectionListener

public void removeCollectionListener(Object listener)
Unregisters a collection listener.

Parameters:
listener - Collection event listener to remove from this manager's list.



Copyright 1999-2009 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.