KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > tools > generator > SAXGeneratorModel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.xml.tools.generator;
20
21 import java.util.*;
22
23 /**
24  * Holder of generator settings.
25  *
26  * @author Petr Kuzel
27  * @version 1.0
28  */

29 public class SAXGeneratorModel implements java.io.Serializable JavaDoc {
30
31     /** Serial Version UID */
32     private static final long serialVersionUID =-3982410888926831459L;
33
34     public static final int JAXP_1_0 = 1;
35
36     public static final int JAXP_1_1 = 2;
37
38     public static final int SAX_1_0 = 1;
39
40     public static final int SAX_2_0 = 2;
41
42     /** Holds value of property handler. */
43     private String JavaDoc handler;
44     
45     /** Holds value of property stub. */
46     private String JavaDoc stub;
47     
48     /** Holds value of property parslet. */
49     private String JavaDoc parslet;
50     
51     /** Holds value of property version. */
52     private int SAXversion;
53     
54     /** Holds value of property JAXPversion. */
55     private int JAXPversion;
56     
57     /** Holds value of property parsletImpl. */
58     private String JavaDoc parsletImpl;
59     
60     /** Holds value of property handlerImpl. */
61     private String JavaDoc handlerImpl;
62     
63     /** Holds value of property elementBindings. */
64     private ElementBindings elementBindings;
65     
66     /** Holds value of property parsletBindings. */
67     private ParsletBindings parsletBindings;
68     
69     /** Holds value of property elementDeclarations. */
70     private ElementDeclarations elementDeclarations;
71     
72     /** Holds value of property propagateSAX. */
73     private boolean propagateSAX;
74     
75     private String JavaDoc bindings;
76    
77     public SAXGeneratorModel() {
78         this(""); // NOI18N
79
}
80    
81     public String JavaDoc toString() {
82         StringBuffer JavaDoc sb = new StringBuffer JavaDoc();
83         sb.append("<SAXGeneratorModel propagateSax=" + propagateSAX + "sax/jaxp=" + SAXversion + "/" + JAXPversion + "\n"); // NOI18N
84
sb.append(elementBindings.toString());
85         sb.append(" --"); // NOI18N
86
sb.append(parsletBindings.toString());
87         sb.append("/>\n"); // NOI18N
88
return sb.toString();
89     }
90  
91     /** Creates new SAXGeneratorModel */
92     public SAXGeneratorModel(String JavaDoc prefix) {
93         this(prefix, new ElementDeclarations(null), new ElementBindings(), new ParsletBindings());
94     }
95
96     public SAXGeneratorModel(String JavaDoc prefix, ElementDeclarations eld, ElementBindings elb, ParsletBindings pab) {
97         handler = prefix + "Handler"; // NOI18N
98
stub = prefix + "Parser"; // NOI18N
99
parslet = prefix + "Parslet"; // NOI18N
100
parsletImpl = prefix + "ParsletImpl"; // NOI18N
101
handlerImpl = prefix + "HandlerImpl"; // NOI18N
102
SAXversion = SAX_1_0;
103         JAXPversion = JAXP_1_1;
104         elementBindings = elb;
105         parsletBindings = pab;
106         elementDeclarations = eld;
107         bindings = prefix + "SAXBindings"; // NOI18N
108
}
109     
110     /** Getter for property handler.
111      * @return Value of property handler.
112      */

113     public String JavaDoc getHandler() {
114         return handler;
115     }
116     
117     /** Setter for property handler.
118      * @param handler New value of property handler.
119      */

120     public void setHandler(String JavaDoc handler) {
121         this.handler = handler;
122     }
123     
124     /** Getter for property stub.
125      * @return Value of property stub.
126      */

127     public String JavaDoc getStub() {
128         return stub;
129     }
130     
131     /** Setter for property stub.
132      * @param stub New value of property stub.
133      */

134     public void setStub(String JavaDoc stub) {
135         this.stub = stub;
136     }
137     
138     /** Getter for property parslet.
139      * @return Value of property parslet.
140      */

141     public String JavaDoc getParslet() {
142         return parslet;
143     }
144     
145     /** Setter for property parslet.
146      * @param parslet New value of property parslet.
147      */

148     public void setParslet(String JavaDoc parslet) {
149         this.parslet = parslet;
150     }
151     
152     /** Getter for property version.
153      * @return Value of property version.
154      */

155     public int getSAXversion() {
156         return SAXversion;
157     }
158     
159     /** Setter for property version.
160      * @param version New value of property version.
161      */

162     public void setSAXversion(int version) {
163         this.SAXversion = version;
164     }
165     
166     /** Getter for property JAXPversion.
167      * @return Value of property JAXPversion (1 for JaXP !.0; 2 for JaXP 1.1).
168      */

169     public int getJAXPversion() {
170         return JAXPversion;
171     }
172     
173     /** Setter for property JAXPversion.
174      * @param JAXPversion New value of property JAXPversion.
175      */

176     public void setJAXPversion(int JAXPversion) {
177         this.JAXPversion = JAXPversion;
178     }
179     
180     /** Getter for property parsletImpl.
181      * @return Value of property parsletImpl.
182      */

183     public String JavaDoc getParsletImpl() {
184         return parsletImpl;
185     }
186     
187     /** Setter for property parsletImpl.
188      * @param parsletImpl New value of property parsletImpl.
189      */

190     public void setParsletImpl(String JavaDoc parsletImpl) {
191         this.parsletImpl = parsletImpl;
192     }
193     
194     /** Getter for property handlerImpl.
195      * @return Value of property handlerImpl.
196      */

197     public String JavaDoc getHandlerImpl() {
198         return handlerImpl;
199     }
200     
201     /** Setter for property handlerImpl.
202      * @param handlerImpl New value of property handlerImpl.
203      */

204     public void setHandlerImpl(String JavaDoc handlerImpl) {
205         this.handlerImpl = handlerImpl;
206     }
207     
208     /** Getter for property elementBindings.
209      * @return Value of property elementBindings.
210      */

211     public ElementBindings getElementBindings() {
212         return elementBindings;
213     }
214     
215     /** Setter for property elementBindings.
216      * @param elementBindings New value of property elementBindings.
217      */

218     public void setElementBindings(ElementBindings elementBindings) {
219         this.elementBindings = elementBindings;
220     }
221     
222     /** Getter for property parsletBindings.
223      * @return Value of property parsletBindings.
224      */

225     public ParsletBindings getParsletBindings() {
226         return parsletBindings;
227     }
228     
229     /** Setter for property parsletBindings.
230      * @param parsletBindings New value of property parsletBindings.
231      */

232     public void setParsletBindings(ParsletBindings parsletBindings) {
233         this.parsletBindings = parsletBindings;
234     }
235     
236     /** Getter for property elementDeclarations.
237      * @return Value of property elementDeclarations.
238      */

239     public ElementDeclarations getElementDeclarations() {
240         return elementDeclarations;
241     }
242     
243     /** Setter for property elementDeclarations.
244      * @param elementDeclarations New value of property elementDeclarations.
245      */

246     public void setElementDeclarations(ElementDeclarations elementDeclarations) {
247         this.elementDeclarations = elementDeclarations;
248     }
249     
250     /** Getter for property propagateSAX.
251      * @return Value of property propagateSAX.
252      */

253     public boolean isPropagateSAX() {
254         return propagateSAX;
255     }
256     
257     /** Setter for property propagateSAX.
258      * @param propagateSAX New value of property propagateSAX.
259      */

260     public void setPropagateSAX(boolean propagateSAX) {
261         this.propagateSAX = propagateSAX;
262     }
263
264     
265     public String JavaDoc getBindings() {
266         return bindings;
267     }
268     
269     public void setBindnings(String JavaDoc val) {
270         bindings = val;
271     }
272     
273     /**
274      * @return true is some parslet mapping exists
275      */

276     public boolean hasParslets() {
277         return parsletBindings.keySet().isEmpty() == false;
278     }
279     
280     /*
281      * Load passed bindings into this model for all declared elements.
282      */

283     public void loadElementBindings(ElementBindings bindings) {
284         if (bindings == null) return;
285         
286         Iterator it = bindings.values().iterator();
287         while (it.hasNext()) {
288             ElementBindings.Entry next = (ElementBindings.Entry) it.next();
289             
290             if (elementDeclarations.getEntry(next.getElement()) != null) {
291                 elementBindings.put(next.getElement(), next);
292             }
293         }
294     }
295     
296     /*
297      * Load passed parslets into this model if a parslet is used.
298      * Should be called after loadElementBindings().
299      */

300     public void loadParsletBindings(ParsletBindings parslets) {
301         //TODO: Retouche
302
// if (parslets == null) return;
303
//
304
// Iterator it = parslets.values().iterator();
305
// while (it.hasNext()) {
306
// ParsletBindings.Entry next = (ParsletBindings.Entry) it.next();
307
//
308
// if (elementBindings.containsParslet(next.getId())) {
309
// parsletBindings.put(next.getId(), next);
310
// }
311
// }
312
}
313 }
314
Popular Tags