Source code: openfuture/editxml/form/XmlForm.java
1 package openfuture.editxml.form;
2 /*
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2 of the License, or (at your option) any later version.<p>
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.<p>
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA<br>
16 * http://www.gnu.org/copyleft/lesser.html
17 */
18
19 import java.io.Serializable;
20 import java.util.Hashtable;
21 import java.util.LinkedList;
22 import org.w3c.dom.DocumentType;
23 import org.w3c.dom.Node;
24
25 // Configuration Management Information:
26 // -------------------------------------
27 // $Id: XmlForm.java,v 1.1.1.1 2001/07/08 18:29:29 wreissen Exp $
28 //
29 // Version History:
30 // ----------------
31 // $Log: XmlForm.java,v $
32 // Revision 1.1.1.1 2001/07/08 18:29:29 wreissen
33 // initial version registered ad SourceForge
34 //
35 // Revision 1.1 2001/05/09 20:07:27 wreissen
36 // initial version.
37 //
38 //
39 // ***********************************************************************************
40 /**
41 * Form bean holding entries into an XML file and the XML meta data.<p>
42 *
43 *
44 * Created: Sun Apr 15 11:32:14 2001
45 *
46 * @author <a href="mailto:wolfgang@openfuture.de">Wolfgang Reissenberger</a>
47 * @version $Revision: 1.1.1.1 $
48 */
49
50 public class XmlForm implements Serializable {
51
52
53 /**
54 * XML domain name.
55 *
56 */
57 private String domain;
58 /**
59 * file name.
60 *
61 */
62 private String filename;
63 /**
64 * list of {@link openfuture.editxml.model.XmlEntry XML entries}.
65 *
66 */
67 private Hashtable entries;
68 /**
69 * Document type of the underlying XML structure.
70 *
71 */
72
73 private DocumentType documentType;
74
75 /**
76 * hashtable with XML entry name as key and the error message
77 * as value.
78 *
79 */
80 private Hashtable parseErrors;
81
82 /**
83 * top level processing instructions of the underlying
84 * XML structure.
85 *
86 */
87 private LinkedList processingInstructions;
88
89
90 /**
91 * Creates a new <code>XmlForm</code> instance.
92 *
93 * @param domain name of the XML domain
94 * @param filename file name
95 * @param entries list of
96 * {@link openfuture.editxml.model.XmlEntry XML entries}.
97 */
98 public XmlForm(String domain, String filename, Hashtable entries) {
99 setDomain(domain);
100 setFilename(filename);
101 setEntries(entries);
102 setProcessingInstructions(new LinkedList());
103 }
104
105
106 /**
107 * Get the value of domain.
108 * @return value of domain.
109 */
110 public String getDomain() {
111 return domain;
112 }
113
114 /**
115 * Set the value of domain.
116 * @param v Value to assign to domain.
117 */
118 public void setDomain(String v) {
119 this.domain = v;
120 }
121
122
123
124 /**
125 * Get the value of filename.
126 * @return value of filename.
127 */
128 public String getFilename() {
129 return filename;
130 }
131
132 /**
133 * Set the value of filename.
134 * @param v Value to assign to filename.
135 */
136 public void setFilename(String v) {
137 this.filename = v;
138 }
139
140 /**
141 * Get the value of entries.
142 * @return value of entries.
143 */
144 public Hashtable getEntries() {
145 return entries;
146 }
147
148 /**
149 * Set the value of entries.
150 * @param v Value to assign to entries.
151 */
152 public void setEntries(Hashtable v) {
153 this.entries = v;
154 }
155
156
157 /**
158 * Describe <code>addEntry</code> method here.
159 *
160 * @param key a <code>String</code> value
161 * @param value a <code>String</code> value
162 */
163 public void addEntry(String key, String value) {
164 if (getEntries() == null) setEntries(new Hashtable());
165
166 getEntries().put(key, value);
167 }
168
169
170 /**
171 * Get the value of documentType.
172 * @return value of documentType.
173 */
174 public DocumentType getDoctype() {
175 return documentType;
176 }
177
178 /**
179 * Set the value of documentType.
180 * @param v Value to assign to documentType.
181 */
182 public void setDoctype(DocumentType v) {
183 this.documentType = v;
184 }
185
186
187
188 /**
189 * Add a {@link org.w3c.dom.Node processing instruction}.
190 *
191 * @param node {@link org.w3c.dom.Node processing instruction}.
192 */
193 public void addProcessingInstruction(Node node) {
194 getProcessingInstructions().add(node);
195 }
196
197
198 /**
199 * Get the value of processingInstructions.
200 * @return value of processingInstructions.
201 */
202 public LinkedList getProcessingInstructions() {
203 return processingInstructions;
204 }
205
206 /**
207 * Set the value of processingInstructions.
208 * @param v Value to assign to processingInstructions.
209 */
210 public void setProcessingInstructions(LinkedList v) {
211 this.processingInstructions = v;
212 }
213
214 /**
215 * Get the value of parseErrors.
216 * @return value of parseErrors.
217 */
218 public Hashtable getParseErrors() {
219 if (parseErrors == null) setParseErrors(new Hashtable());
220
221 return parseErrors;
222 }
223
224 /**
225 * Set the value of parseErrors.
226 * @param v Value to assign to parseErrors.
227 */
228 public void setParseErrors(Hashtable v) {
229 this.parseErrors = v;
230 }
231
232
233 /**
234 * Add a single parse error to the hashtable
235 *
236 * @param key XML structure key
237 * @param message error message
238 * @see #getParseErrors()
239 */
240 public void addParseError(String key, String message) {
241 if (getParseErrors() == null) setParseErrors(new Hashtable());
242
243 getParseErrors().put(key, message);
244 }
245 } // XmlForm