diff options
Diffstat (limited to 'projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNotification.java')
| -rw-r--r-- | projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNotification.java | 233 |
1 files changed, 107 insertions, 126 deletions
diff --git a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNotification.java b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNotification.java index f288d3f..6b091e2 100644 --- a/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNotification.java +++ b/projects/net.wotonomy.foundation/src/main/java/net/wotonomy/foundation/NSNotification.java @@ -21,144 +21,125 @@ package net.wotonomy.foundation; import java.util.Map; /** -* An NSNotification is a generic message that can be -* dispatched by the NSNotificationCenter. -* -* @author michael@mpowers.net -* @author $Author: cgruber $ -* @version $Revision: 893 $ -*/ -public class NSNotification -{ - public static boolean showStack = false; - - protected String name; - protected Object object; - protected Map userInfo; - - // for debugging only - private Throwable stackTrace; - - /** - * Default constructor creates a new notification - * with no name, object, or info dictionary. - */ - public NSNotification () - { - this( null, null, null ); - } - - /** - * Constructor specifying name and object. - */ - public NSNotification ( String aName, Object anObject ) - { - this( aName, anObject, null ); - } - - /** - * Constructor specifying name, object, and a Map - * containing application specific information. - */ - public NSNotification ( - String aName, Object anObject, Map aUserInfo ) - { - name = aName; - object = anObject; - if ( showStack ) stackTrace = new RuntimeException(); - userInfo = aUserInfo; - } - - /** - * Returns the name of this notification. - */ - public String name () - { - return name; - } - - /** - * Returns the object of this notification. - */ - public Object object () - { - return object; - } - - /** - * Returns an NSDictionary that is a copy of - * the map containing application specific - * information relating to this notification, - * or null if no such data exists. - */ - public NSDictionary userInfo () - { - if ( userInfo == null ) return null; - return new NSDictionary( userInfo ); - } - - /** - * Returns a Map containing application specific - * information relating to this notification, - * or null if no such data exists. - * Note: this method is not in the spec. - */ - public Map userInfoMap () - { - return userInfo; - } - - /** - * Returns the stack trace when this notification was generated, - * or null if showStack is false, which is the default. - * NOTE: This method is not part of the specification. - */ - public Throwable stackTrace() - { - return stackTrace; - } - - /** - * Returns a human-readable string representation. - */ - public String toString() - { - return "[ " + name() + " : " + object() + " : " + userInfo() + " ]"; - } + * An NSNotification is a generic message that can be dispatched by the + * NSNotificationCenter. + * + * @author michael@mpowers.net + * @author $Author: cgruber $ + * @version $Revision: 893 $ + */ +public class NSNotification { + public static boolean showStack = false; + + protected String name; + protected Object object; + protected Map userInfo; + + // for debugging only + private Throwable stackTrace; + + /** + * Default constructor creates a new notification with no name, object, or info + * dictionary. + */ + public NSNotification() { + this(null, null, null); + } + + /** + * Constructor specifying name and object. + */ + public NSNotification(String aName, Object anObject) { + this(aName, anObject, null); + } + + /** + * Constructor specifying name, object, and a Map containing application + * specific information. + */ + public NSNotification(String aName, Object anObject, Map aUserInfo) { + name = aName; + object = anObject; + if (showStack) + stackTrace = new RuntimeException(); + userInfo = aUserInfo; + } + + /** + * Returns the name of this notification. + */ + public String name() { + return name; + } + + /** + * Returns the object of this notification. + */ + public Object object() { + return object; + } + + /** + * Returns an NSDictionary that is a copy of the map containing application + * specific information relating to this notification, or null if no such data + * exists. + */ + public NSDictionary userInfo() { + if (userInfo == null) + return null; + return new NSDictionary(userInfo); + } + + /** + * Returns a Map containing application specific information relating to this + * notification, or null if no such data exists. Note: this method is not in the + * spec. + */ + public Map userInfoMap() { + return userInfo; + } + + /** + * Returns the stack trace when this notification was generated, or null if + * showStack is false, which is the default. NOTE: This method is not part of + * the specification. + */ + public Throwable stackTrace() { + return stackTrace; + } + + /** + * Returns a human-readable string representation. + */ + public String toString() { + return "[ " + name() + " : " + object() + " : " + userInfo() + " ]"; + } } /* - * $Log$ - * Revision 1.2 2006/02/16 13:15:00 cgruber - * Check in all sources in eclipse-friendly maven-enabled packages. + * $Log$ Revision 1.2 2006/02/16 13:15:00 cgruber Check in all sources in + * eclipse-friendly maven-enabled packages. * - * Revision 1.7 2002/10/24 18:16:04 mpowers - * No longer generating stack trace by default. + * Revision 1.7 2002/10/24 18:16:04 mpowers No longer generating stack trace by + * default. * - * Revision 1.6 2002/06/21 22:02:47 mpowers - * Oops: Fixed NPE. + * Revision 1.6 2002/06/21 22:02:47 mpowers Oops: Fixed NPE. * - * Revision 1.5 2002/06/21 21:50:41 mpowers - * Added a method to get the map directly from the notification. - * Changed the internal representation to a map not a dictionary. - * We had been creating a new dictionary with each creation. + * Revision 1.5 2002/06/21 21:50:41 mpowers Added a method to get the map + * directly from the notification. Changed the internal representation to a map + * not a dictionary. We had been creating a new dictionary with each creation. * This also allows people to modify the contents of the userInfo. * - * Revision 1.4 2001/04/09 21:41:49 mpowers - * Better debugging. + * Revision 1.4 2001/04/09 21:41:49 mpowers Better debugging. * - * Revision 1.3 2001/02/21 18:31:07 mpowers - * Finished and tested implementation of NSNotificationCenter. + * Revision 1.3 2001/02/21 18:31:07 mpowers Finished and tested implementation + * of NSNotificationCenter. * - * Revision 1.2 2001/02/20 23:57:03 mpowers - * Implemented NSNotificationCenter. + * Revision 1.2 2001/02/20 23:57:03 mpowers Implemented NSNotificationCenter. * - * Revision 1.1.1.1 2000/12/21 15:47:36 mpowers - * Contributing wotonomy. + * Revision 1.1.1.1 2000/12/21 15:47:36 mpowers Contributing wotonomy. * - * Revision 1.3 2000/12/20 16:25:38 michael - * Added log to all files. + * Revision 1.3 2000/12/20 16:25:38 michael Added log to all files. * * */ - |
