001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.components.notification;
018:
019: import java.util.HashMap;
020: import java.util.Map;
021:
022: /**
023: * A simple bean implementation of Notifying.
024: *
025: * @author <a href="mailto:barozzi@nicolaken.com">Nicola Ken Barozzi</a>
026: * @version CVS $Id: SimpleNotifyingBean.java 433543 2006-08-22 06:22:54Z crossley $
027: */
028: public class SimpleNotifyingBean implements Notifying {
029:
030: /**
031: * The type of the notification. Examples can be "warning" or "error"
032: */
033: private String type = "unknown";
034:
035: /**
036: * The title of the notification.
037: */
038: private String title = "Generic notification";
039:
040: /**
041: * The source that generates the notification.
042: */
043: private String source = getClass().getName();
044:
045: /**
046: * The sender of the notification.
047: */
048: private String sender = "unknown";
049:
050: /**
051: * The notification itself.
052: */
053: private String message = "Message not known.";
054:
055: /**
056: * A more detailed description of the notification.
057: */
058: private String description = "";
059:
060: /**
061: * A HashMap containing extra notifications
062: */
063: private Map extraDescriptions = new HashMap();
064:
065: public SimpleNotifyingBean() {
066: }
067:
068: public SimpleNotifyingBean(Object sender) {
069: this .sender = sender.getClass().getName();
070: }
071:
072: /**
073: * Sets the Type of the SimpleNotifyingBean object
074: *
075: * @param type The new Type value
076: */
077: public void setType(String type) {
078: this .type = type;
079: }
080:
081: /**
082: * Sets the Title of the SimpleNotifyingBean object
083: *
084: * @param title The new Title value
085: */
086: public void setTitle(String title) {
087: this .title = title;
088: }
089:
090: /**
091: * Sets the Source of the SimpleNotifyingBean object
092: *
093: * @param source The new Source value
094: */
095: public void setSource(String source) {
096: this .source = source;
097: }
098:
099: /**
100: * Sets the Message of the SimpleNotifyingBean object
101: *
102: * @param message The new Message value
103: */
104: public void setMessage(String 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 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 extraDescriptionDescription,
124: String extraDescription) {
125: this .extraDescriptions.put(extraDescriptionDescription,
126: extraDescription);
127: }
128:
129: /**
130: * Replaces the ExtraDescriptions of the SimpleNotifyingBean object
131: */
132: protected void replaceExtraDescriptions(Map extraDescriptions) {
133: this .extraDescriptions = extraDescriptions;
134: }
135:
136: /**
137: * Adds the ExtraDescriptions to the SimpleNotifyingBean object
138: */
139: protected void addExtraDescriptions(Map extraDescriptions) {
140: if (this .extraDescriptions == null) {
141: replaceExtraDescriptions(extraDescriptions);
142: } else {
143: this .extraDescriptions.putAll(extraDescriptions);
144: }
145: }
146:
147: /**
148: * Gets the Type of the SimpleNotifyingBean object
149: */
150: public String getType() {
151: return type;
152: }
153:
154: /**
155: * Gets the Title of the SimpleNotifyingBean object
156: */
157: public String getTitle() {
158: return title;
159: }
160:
161: /**
162: * Gets the Source of the SimpleNotifyingBean object
163: */
164: public String getSource() {
165: return source;
166: }
167:
168: /**
169: * Gets the Sender of the SimpleNotifyingBean object
170: */
171: public String getSender() {
172: return sender;
173: }
174:
175: /**
176: * Gets the Message of the SimpleNotifyingBean object
177: */
178: public String getMessage() {
179: return message;
180: }
181:
182: /**
183: * Gets the Description of the SimpleNotifyingBean object
184: */
185: public String getDescription() {
186: return description;
187: }
188:
189: /**
190: * Gets the ExtraDescriptions of the SimpleNotifyingBean object
191: */
192: public Map getExtraDescriptions() {
193: return extraDescriptions;
194: }
195: }
|