KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > util > NotificationEvent


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23  package com.sun.enterprise.util;
24
25 import java.util.EventObject JavaDoc;
26 import java.util.Hashtable JavaDoc;
27
28     /** Generic event for notifications.
29     * @author Danny Coward
30     */

31
32 public class NotificationEvent extends EventObject JavaDoc {
33
34     public static String JavaDoc OBJECT_THAT_CHANGED = "ObjectThatChanged";
35     public static String JavaDoc ATTRIBUTE_THAT_CHANGED = "AttributeThatChanged";
36
37     private String JavaDoc type = null;
38     protected Hashtable JavaDoc properties = new Hashtable JavaDoc();
39     
40     public NotificationEvent(Object JavaDoc source, String JavaDoc type) {
41     super(source);
42     this.type = type;
43     }
44     
45     public NotificationEvent(Object JavaDoc source, String JavaDoc type, String JavaDoc name, Object JavaDoc value) {
46     super(source);
47     this.type = type;
48     this.properties.put(name, value);
49     }
50     
51     public NotificationEvent(Object JavaDoc source, String JavaDoc type, Object JavaDoc objectThatChanged) {
52     super(source);
53     this.type = type;
54     this.properties.put(OBJECT_THAT_CHANGED, objectThatChanged);
55     }
56         
57     public NotificationEvent(Object JavaDoc source, String JavaDoc type, Object JavaDoc objectThatChanged, Object JavaDoc attribThatChanged) {
58     this(source, type, objectThatChanged);
59     if (attribThatChanged != null) {
60         this.properties.put(ATTRIBUTE_THAT_CHANGED, attribThatChanged);
61     }
62     }
63
64     public String JavaDoc getType() {
65     return this.type;
66     }
67     
68     public Object JavaDoc getValue(String JavaDoc name) {
69     return this.properties.get(name);
70     }
71     
72     public Object JavaDoc getObjectThatChanged() {
73     return this.properties.get(OBJECT_THAT_CHANGED);
74     }
75         
76     public Object JavaDoc getAttributeThatChanged() {
77     return this.properties.get(ATTRIBUTE_THAT_CHANGED);
78     }
79
80 }
81
Popular Tags