KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > notification > SimpleNotifyingBean


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.cocoon.components.notification;
17
18 import java.util.HashMap JavaDoc;
19 import java.util.Map JavaDoc;
20
21 /**
22  * A simple bean implementation of Notifying.
23  *
24  * @author <a HREF="mailto:barozzi@nicolaken.com">Nicola Ken Barozzi</a>
25  * @version CVS $Id: SimpleNotifyingBean.java 36582 2004-08-18 22:48:28Z vgritsenko $
26  */

27 public class SimpleNotifyingBean implements Notifying {
28
29     /**
30      * The type of the notification. Examples can be "warning" or "error"
31      */

32     private String JavaDoc type = "unknown";
33
34     /**
35      * The title of the notification.
36      */

37     private String JavaDoc title = "Generic notification";
38
39     /**
40      * The source that generates the notification.
41      */

42     private String JavaDoc source = getClass().getName();
43
44     /**
45      * The sender of the notification.
46      */

47     private String JavaDoc sender = "unknown";
48
49     /**
50      * The notification itself.
51      */

52     private String JavaDoc message = "Message not known.";
53
54     /**
55      * A more detailed description of the notification.
56      */

57     private String JavaDoc description = "";
58
59     /**
60      * A HashMap containing extra notifications
61      */

62     private Map JavaDoc extraDescriptions = new HashMap JavaDoc();
63
64
65     public SimpleNotifyingBean() {
66     }
67
68     public SimpleNotifyingBean(Object JavaDoc sender) {
69         this.sender = sender.getClass().getName();
70     }
71
72     /**
73      * Sets the Type of the SimpleNotifyingBean object
74      *
75      * @param type The new Type value
76      */

77     public void setType(String JavaDoc type) {
78         this.type = type;
79     }
80
81     /**
82      * Sets the Title of the SimpleNotifyingBean object
83      *
84      * @param title The new Title value
85      */

86     public void setTitle(String JavaDoc title) {
87         this.title = title;
88     }
89
90     /**
91      * Sets the Source of the SimpleNotifyingBean object
92      *
93      * @param source The new Source value
94      */

95     public void setSource(String JavaDoc source) {
96         this.source = source;
97     }
98
99     /**
100      * Sets the Message of the SimpleNotifyingBean object
101      *
102      * @param message The new Message value
103      */

104     public void setMessage(String JavaDoc message) {
105         this.message = message;
106     }
107
108     /**
109      * Sets the Description of the SimpleNotifyingBean object
110      *
111      * @param description The new Description value
112      */

113     public void setDescription(String JavaDoc description) {
114         this.description = description;
115     }
116
117     /**
118      * Adds the ExtraDescription to the SimpleNotifyingBean object
119      *
120      * @param extraDescriptionDescription The additional ExtraDescription name
121      * @param extraDescription The additional ExtraDescription value
122      */

123     public void addExtraDescription(String JavaDoc extraDescriptionDescription,
124                                     String JavaDoc extraDescription) {
125         this.extraDescriptions.put(extraDescriptionDescription, extraDescription);
126     }
127
128     /**
129      * Replaces the ExtraDescriptions of the SimpleNotifyingBean object
130      */

131     protected void replaceExtraDescriptions(Map JavaDoc extraDescriptions) {
132         this.extraDescriptions = extraDescriptions;
133     }
134
135     /**
136      * Adds the ExtraDescriptions to the SimpleNotifyingBean object
137      */

138     protected void addExtraDescriptions(Map JavaDoc extraDescriptions) {
139         if (this.extraDescriptions == null) {
140             replaceExtraDescriptions(extraDescriptions);
141         } else {
142             this.extraDescriptions.putAll(extraDescriptions);
143         }
144     }
145
146     /**
147      * Gets the Type of the SimpleNotifyingBean object
148      */

149     public String JavaDoc getType() {
150         return type;
151     }
152
153     /**
154      * Gets the Title of the SimpleNotifyingBean object
155      */

156     public String JavaDoc getTitle() {
157         return title;
158     }
159
160     /**
161      * Gets the Source of the SimpleNotifyingBean object
162      */

163     public String JavaDoc getSource() {
164         return source;
165     }
166
167     /**
168      * Gets the Sender of the SimpleNotifyingBean object
169      */

170     public String JavaDoc getSender() {
171         return sender;
172     }
173
174     /**
175      * Gets the Message of the SimpleNotifyingBean object
176      */

177     public String JavaDoc getMessage() {
178         return message;
179     }
180
181     /**
182      * Gets the Description of the SimpleNotifyingBean object
183      */

184     public String JavaDoc getDescription() {
185         return description;
186     }
187
188     /**
189      * Gets the ExtraDescriptions of the SimpleNotifyingBean object
190      */

191     public Map JavaDoc getExtraDescriptions() {
192         return extraDescriptions;
193     }
194 }
195
Popular Tags