1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.dbforms.config;
25
26 import org.apache.commons.logging.Log;
27 import org.apache.commons.logging.LogFactory;
28
29 import java.util.Hashtable;
30
31
32
33 /***
34 * This class represents an error tag in dbforms-errors.xml
35 *
36 * @author unknown
37 */
38 public class Error {
39 private static Log logCat = LogFactory.getLog(Error.class.getName());
40 private Hashtable messages;
41
42
43
44 private String id;
45 private String type;
46
47 /***
48 * Creates a new Error object.
49 */
50 public Error() {
51 messages = new Hashtable();
52 }
53
54 /***
55 * DOCUMENT ME!
56 *
57 * @param id DOCUMENT ME!
58 */
59 public void setId(String id) {
60 this.id = id;
61 }
62
63
64 /***
65 * DOCUMENT ME!
66 *
67 * @return DOCUMENT ME!
68 */
69 public String getId() {
70 return id;
71 }
72
73
74 /***
75 * DOCUMENT ME!
76 *
77 * @param language DOCUMENT ME!
78 * @param message DOCUMENT ME!
79 */
80 public void setMessage(String language,
81 String message) {
82 this.messages.put(language, message);
83 }
84
85
86 /***
87 * DOCUMENT ME!
88 *
89 * @param language DOCUMENT ME!
90 *
91 * @return DOCUMENT ME!
92 */
93 public String getMessage(String language) {
94 return (String) messages.get(language);
95 }
96
97
98 /***
99 * DOCUMENT ME!
100 *
101 * @param msgs DOCUMENT ME!
102 */
103 public void setMessages(Hashtable msgs) {
104 this.messages = msgs;
105 }
106
107
108 /***
109 * DOCUMENT ME!
110 *
111 * @return DOCUMENT ME!
112 */
113 public Hashtable getMessages() {
114 return messages;
115 }
116
117
118 /***
119 * DOCUMENT ME!
120 *
121 * @param t DOCUMENT ME!
122 */
123 public void setType(String t) {
124 this.type = t;
125 }
126
127
128 /***
129 * DOCUMENT ME!
130 *
131 * @return DOCUMENT ME!
132 */
133 public String getType() {
134 return type;
135 }
136
137
138 /***
139 * adds a Message-Object to this error and puts it into the datastructure
140 * for further references (this method gets called from DbFormsError)
141 *
142 * @param message message to add
143 */
144 public void addMessage(Message message) {
145 messages.put(message.getLanguage(), message.getMessage());
146 logCat.info("Language " + message.getLanguage() + " Message "
147 + message.getMessage());
148 }
149
150
151 /***
152 * DOCUMENT ME!
153 *
154 * @return DOCUMENT ME!
155 */
156 public String toString() {
157 StringBuffer buf = new StringBuffer();
158 buf.append("id=");
159 buf.append(this.getId());
160 buf.append(" type=");
161 buf.append(this.getType());
162
163 return buf.toString();
164 }
165 }