edu.umd.cs.piccolox.event
Class PNotification

java.lang.Object
  extended by edu.umd.cs.piccolox.event.PNotification

public class PNotification
extends Object

PNotification objects encapsulate information so that it can be broadcast to other objects by a PNotificationCenter. A PNotification contains a name, an object, and an optional properties map. The name is a tag identifying the notification. The object is any object that the poster of the notification wants to send to observers of that notification (typically, it is the object that posted the notification). The properties map stores other related objects, if any.

You don't usually create your own notifications directly. The PNotificationCenter method postNotification() allow you to conveniently post a notification without creating it first.

Author:
Jesse Grosjean

Field Summary
protected  String name
          Name of the notification.
protected  Map properties
          A free form map of properties to attach to this notification.
protected  Object source
          The Object associated with this notification.
 
Constructor Summary
PNotification(String name, Object source, Map properties)
          Creates a notification.
 
Method Summary
 String getName()
          Return the name of the notification.
 Object getObject()
          Return the object associated with this notification.
 Object getProperty(Object key)
          Return a property associated with the notification, or null if not found.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected String name
Name of the notification.


source

protected Object source
The Object associated with this notification.


properties

protected Map properties
A free form map of properties to attach to this notification.

Constructor Detail

PNotification

public PNotification(String name,
                     Object source,
                     Map properties)
Creates a notification.

Parameters:
name - Arbitrary name of the notification
source - object associated with this notification
properties - free form map of information about the notification
Method Detail

getName

public String getName()
Return the name of the notification. This is the same as the name used to register with the notification center.

Returns:
name of notification

getObject

public Object getObject()
Return the object associated with this notification. This is most often the same object that posted the notification. It may be null.

Returns:
object associated with this notification

getProperty

public Object getProperty(Object key)
Return a property associated with the notification, or null if not found.

Parameters:
key - key used for looking up the property
Returns:
value associated with the key or null if not found


Copyright © 1995-2010 Piccolo2D. All Rights Reserved.