KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbforms > config > Error


1 /*
2  * $Header: /cvsroot/jdbforms/dbforms/src/org/dbforms/config/Error.java,v 1.5 2004/08/18 12:25:55 hkollmann Exp $
3  * $Revision: 1.5 $
4  * $Date: 2004/08/18 12:25:55 $
5  *
6  * DbForms - a Rapid Application Development Framework
7  * Copyright (C) 2001 Joachim Peer <joepeer@excite.com>
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with this library; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
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 JavaDoc;
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 JavaDoc.class.getName());
40    private Hashtable JavaDoc messages;
41
42    // logging category for this class
43
//------------------------ Properties ---------------------------------------------------------
44
private String JavaDoc id; // the id of this error
45
private String JavaDoc type; // the type of error
46

47    /**
48     * Creates a new Error object.
49     */

50    public Error() {
51       messages = new Hashtable JavaDoc();
52    }
53
54    /**
55     * DOCUMENT ME!
56     *
57     * @param id DOCUMENT ME!
58     */

59    public void setId(String JavaDoc id) {
60       this.id = id;
61    }
62
63
64    /**
65     * DOCUMENT ME!
66     *
67     * @return DOCUMENT ME!
68     */

69    public String JavaDoc 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 JavaDoc language,
81                           String JavaDoc 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 JavaDoc getMessage(String JavaDoc language) {
94       return (String JavaDoc) messages.get(language);
95    }
96
97
98    /**
99     * DOCUMENT ME!
100     *
101     * @param msgs DOCUMENT ME!
102     */

103    public void setMessages(Hashtable JavaDoc msgs) {
104       this.messages = msgs;
105    }
106
107
108    /**
109     * DOCUMENT ME!
110     *
111     * @return DOCUMENT ME!
112     */

113    public Hashtable JavaDoc getMessages() {
114       return messages;
115    }
116
117
118    /**
119     * DOCUMENT ME!
120     *
121     * @param t DOCUMENT ME!
122     */

123    public void setType(String JavaDoc t) {
124       this.type = t;
125    }
126
127
128    /**
129     * DOCUMENT ME!
130     *
131     * @return DOCUMENT ME!
132     */

133    public String JavaDoc 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 JavaDoc toString() {
157       StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
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 }
166
Popular Tags