View Javadoc

1   /**
2    * Copyright 2005-2015 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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.kuali.rice.krad.messages;
17  
18  import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
19  
20  /**
21   * Holds the text and metadata for a message that will be given by the system, including validation
22   * messages, UI text (labels, instructions), and other text that has been externalized from the
23   * system
24   *
25   * @author Kuali Rice Team (rice.collab@kuali.org)
26   */
27  public class Message extends PersistableBusinessObjectBase {
28  
29      private String namespaceCode;
30      private String componentCode;
31      private String key;
32      private String locale;
33      private String description;
34      private String text;
35  
36      public Message() {
37          super();
38      }
39  
40      /**
41       * Namespace code (often an application or module code) that message is associated with, used for
42       * grouping messages
43       *
44       * @return String namespace code
45       */
46      public String getNamespaceCode() {
47          return namespaceCode;
48      }
49  
50      /**
51       * Setter for the namespace code the message should be associated with
52       *
53       * @param namespaceCode
54       */
55      public void setNamespaceCode(String namespaceCode) {
56          this.namespaceCode = namespaceCode;
57      }
58  
59      /**
60       * A code within the namespace that identifies a component or group, used for further grouping
61       * of messages within the namespace
62       *
63       * <p>
64       * Examples here could be a bean id, the class name of an object, or any application/module defined code
65       * </p>
66       *
67       * @return String representing a component code
68       */
69      public String getComponentCode() {
70          return componentCode;
71      }
72  
73      /**
74       * Setter for the component code the message should be associated with
75       *
76       * @param componentCode
77       */
78      public void setComponentCode(String componentCode) {
79          this.componentCode = componentCode;
80      }
81  
82      /**
83       * A key that uniquely identifies the message within the namespace and component
84       *
85       * <p>
86       * Within the UIF, this is generally used to indicate the property path the message is associated with
87       * (for example: "control.label"). For validation messages this is generally a combination that identifies
88       * the type of validation message and the validation performed (for example: "error.account.missing")
89       * </p>
90       *
91       * @return String message key
92       */
93      public String getKey() {
94          return key;
95      }
96  
97      /**
98       * Setter for the message key
99       *
100      * @param key
101      */
102     public void setKey(String key) {
103         this.key = key;
104     }
105 
106     /**
107      * Locale code the message is represented for, used for supporting messages in different
108      * languages
109      *
110      * @return message locale code
111      */
112     public String getLocale() {
113         return locale;
114     }
115 
116     /**
117      * Setter for the message locale code
118      *
119      * @param locale
120      */
121     public void setLocale(String locale) {
122         this.locale = locale;
123     }
124 
125     /**
126      * A description for the message
127      *
128      * <p>
129      * Not used by the framework, here for purposes of editing of messages and providing a description
130      * of the message to users
131      * </p>
132      *
133      * @return String message description
134      */
135     public String getDescription() {
136         return description;
137     }
138 
139     /**
140      * Setter for the message description
141      *
142      * @param description
143      */
144     public void setDescription(String description) {
145         this.description = description;
146     }
147 
148     /**
149      * Text value for the message
150      *
151      * <p>
152      * This holds the actual text for the message which is what will be displayed. Depending on how
153      * the message is being used it might contain parameters or other special syntax
154      * </p>
155      *
156      * @return String text for the message
157      */
158     public String getText() {
159         return text;
160     }
161 
162     /**
163      * Setter for the message text
164      *
165      * @param text
166      */
167     public void setText(String text) {
168         this.text = text;
169     }
170 
171     /**
172      * Generate toString using message key fields
173      *
174      * @return String representing the message object
175      */
176     @Override
177     public final String toString() {
178         StringBuffer buffer = new StringBuffer();
179 
180         buffer.append("namespaceCode=" + this.namespaceCode);
181         buffer.append(",componentCode=" + this.componentCode);
182         buffer.append(",key=" + this.key);
183         buffer.append(",locale=" + this.locale);
184 
185         return buffer.toString();
186     }
187 }