|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.umd.cs.piccolox.event.PNotificationCenter
public class PNotificationCenter
PNotificationCenter provides a way for objects that don't know about each other to communicate. It receives PNotification objects and broadcasts them to all interested listeners. Unlike standard Java events, the event listeners don't need to know about the event source, and the event source doesn't need to maintain the list of listeners.
Listeners of the notfications center are held by weak references. So the notfication center will not create garbage collection problems as standard java event listeners do.
Nested Class Summary | |
---|---|
protected static class |
PNotificationCenter.CompoundKey
|
protected static class |
PNotificationCenter.CompoundValue
|
Field Summary | |
---|---|
protected static PNotificationCenter |
DEFAULT_CENTER
|
protected java.lang.ref.ReferenceQueue |
keyQueue
|
protected java.util.HashMap |
listenersMap
|
static java.lang.Object |
NULL_MARKER
|
Method Summary | |
---|---|
void |
addListener(java.lang.Object listener,
java.lang.String callbackMethodName,
java.lang.String notificationName,
java.lang.Object object)
Registers the 'listener' to receive notifications with the name 'notificationName' and/or containing 'object'. |
static PNotificationCenter |
defaultCenter()
|
protected java.util.List |
matchingKeys(java.lang.String name,
java.lang.Object object)
|
void |
postNotification(PNotification aNotification)
Post the notification to this notification center. |
void |
postNotification(java.lang.String notificationName,
java.lang.Object object)
Post a new notfication with notificationName and object. |
void |
postNotification(java.lang.String notificationName,
java.lang.Object object,
java.util.Map userInfo)
Creates a notification with the name notificationName, associates it with the object, and posts it to this notification center. |
protected void |
processKeyQueue()
|
void |
removeListener(java.lang.Object listener)
Removes the listener so that it no longer recives notfications from this notfication center. |
protected void |
removeListener(java.lang.Object listener,
java.lang.Object key)
|
void |
removeListener(java.lang.Object listener,
java.lang.String notificationName,
java.lang.Object object)
Removes the listeners as the listener of notifications matching notificationName and object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.Object NULL_MARKER
protected static PNotificationCenter DEFAULT_CENTER
protected java.util.HashMap listenersMap
protected java.lang.ref.ReferenceQueue keyQueue
Method Detail |
---|
public static PNotificationCenter defaultCenter()
public void addListener(java.lang.Object listener, java.lang.String callbackMethodName, java.lang.String notificationName, java.lang.Object object)
public void removeListener(java.lang.Object listener)
public void removeListener(java.lang.Object listener, java.lang.String notificationName, java.lang.Object object)
public void postNotification(java.lang.String notificationName, java.lang.Object object)
public void postNotification(java.lang.String notificationName, java.lang.Object object, java.util.Map userInfo)
public void postNotification(PNotification aNotification)
protected java.util.List matchingKeys(java.lang.String name, java.lang.Object object)
protected void removeListener(java.lang.Object listener, java.lang.Object key)
protected void processKeyQueue()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |