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

java.lang.Object
  extended by 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 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.

Specified by:
addCollectionListener in interface CollectionEventSource
Parameters:
listener - Collection event listener to add to this manager's list.
Throws:
IllegalArgumentException - if listener is not an instance of CollectionListener

removeCollectionListener

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

Specified by:
removeCollectionListener in interface CollectionEventSource
Parameters:
listener - Collection event listener to remove from this manager's list.

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.
Since:
BlackBerry API 4.0.2

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.
Since:
BlackBerry API 4.0.2

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.
Since:
BlackBerry API 4.0.2

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.
Since:
BlackBerry API 4.0.2

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.
Since:
BlackBerry API 4.0.2

clearOut

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

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


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.





Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal