KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > dd > impl > transform > Transform


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 2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 /**
20  * This generated bean class Transform matches the schema element 'transform'.
21  *
22  * Generated on Sat Aug 13 01:27:36 GMT-08:00 2005
23  *
24  * This class matches the root element of the DTD,
25  * and is the root of the following bean graph:
26  *
27  * transform <transform> : Transform
28  * (
29  * xmltype <xmltype> : Xmltype
30  * name <name> : String
31  * modElement <mod-element> : ModElement[0,n]
32  * name <name> : String
33  * modAttribute <mod-attribute> : ModAttribute[0,n]
34  * name <name> : String
35  * subElement <sub-element> : SubElement[0,n]
36  * name <name> : String
37  * )[0,n]
38  *
39  * @Generated
40  */

41
42 package org.netbeans.modules.j2ee.sun.dd.impl.transform;
43
44 import org.w3c.dom.*;
45 import org.netbeans.modules.schema2beans.*;
46 import java.beans.*;
47 import java.util.*;
48 import java.io.*;
49
50 // BEGIN_NOI18N
51

52 public class Transform extends org.netbeans.modules.schema2beans.BaseBean
53 {
54
55     static Vector comparators = new Vector();
56     private static final org.netbeans.modules.schema2beans.Version runtimeVersion = new org.netbeans.modules.schema2beans.Version(4, 2, 0);
57
58     static public final String JavaDoc XMLTYPE = "Xmltype"; // NOI18N
59

60     public Transform() throws org.netbeans.modules.schema2beans.Schema2BeansException {
61         this(null, Common.USE_DEFAULT_VALUES);
62     }
63
64     public Transform(org.w3c.dom.Node JavaDoc doc, int options) throws org.netbeans.modules.schema2beans.Schema2BeansException {
65         this(Common.NO_DEFAULT_VALUES);
66         initFromNode(doc, options);
67     }
68     protected void initFromNode(org.w3c.dom.Node JavaDoc doc, int options) throws Schema2BeansException
69     {
70         if (doc == null)
71         {
72             doc = GraphManager.createRootElementNode("transform"); // NOI18N
73
if (doc == null)
74                 throw new Schema2BeansException(Common.getMessage(
75                     "CantCreateDOMRoot_msg", "transform"));
76         }
77         Node n = GraphManager.getElementNode("transform", doc); // NOI18N
78
if (n == null)
79             throw new Schema2BeansException(Common.getMessage(
80                 "DocRootNotInDOMGraph_msg", "transform", doc.getFirstChild().getNodeName()));
81
82         this.graphManager.setXmlDocument(doc);
83
84         // Entry point of the createBeans() recursive calls
85
this.createBean(n, this.graphManager());
86         this.initialize(options);
87     }
88     public Transform(int options)
89     {
90         super(comparators, runtimeVersion);
91         initOptions(options);
92     }
93     protected void initOptions(int options)
94     {
95         // The graph manager is allocated in the bean root
96
this.graphManager = new GraphManager(this);
97         this.createRoot("transform", "Transform", // NOI18N
98
Common.TYPE_1 | Common.TYPE_BEAN, Transform.class);
99
100         // Properties (see root bean comments for the bean graph)
101
initPropertyTables(1);
102         this.createProperty("xmltype", // NOI18N
103
XMLTYPE,
104             Common.TYPE_0_N | Common.TYPE_BEAN | Common.TYPE_KEY,
105             Xmltype.class);
106         this.initialize(options);
107     }
108
109     // Setting the default values of the properties
110
void initialize(int options) {
111
112     }
113
114     // This attribute is an array, possibly empty
115
public void setXmltype(int index, Xmltype value) {
116         this.setValue(XMLTYPE, index, value);
117     }
118
119     //
120
public Xmltype getXmltype(int index) {
121         return (Xmltype)this.getValue(XMLTYPE, index);
122     }
123
124     // Return the number of properties
125
public int sizeXmltype() {
126         return this.size(XMLTYPE);
127     }
128
129     // This attribute is an array, possibly empty
130
public void setXmltype(Xmltype[] value) {
131         this.setValue(XMLTYPE, value);
132     }
133
134     //
135
public Xmltype[] getXmltype() {
136         return (Xmltype[])this.getValues(XMLTYPE);
137     }
138
139     // Add a new element returning its index in the list
140
public int addXmltype(Xmltype value) {
141         int positionOfNewItem = this.addValue(XMLTYPE, value);
142         return positionOfNewItem;
143     }
144
145     //
146
// Remove an element using its reference
147
// Returns the index the element had in the list
148
//
149
public int removeXmltype(Xmltype value) {
150         return this.removeValue(XMLTYPE, value);
151     }
152
153     /**
154      * Create a new bean using it's default constructor.
155      * This does not add it to any bean graph.
156      */

157     public Xmltype newXmltype() {
158         return new Xmltype();
159     }
160
161     //
162
public static void addComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
163         comparators.add(c);
164     }
165
166     //
167
public static void removeComparator(org.netbeans.modules.schema2beans.BeanComparator c) {
168         comparators.remove(c);
169     }
170     //
171
// This method returns the root of the bean graph
172
// Each call creates a new bean graph from the specified DOM graph
173
//
174
public static Transform createGraph(org.w3c.dom.Node JavaDoc doc) throws org.netbeans.modules.schema2beans.Schema2BeansException {
175         return new Transform(doc, Common.NO_DEFAULT_VALUES);
176     }
177
178     public static Transform createGraph(java.io.File JavaDoc f) throws org.netbeans.modules.schema2beans.Schema2BeansException, java.io.IOException JavaDoc {
179         java.io.InputStream JavaDoc in = new java.io.FileInputStream JavaDoc(f);
180         try {
181             return createGraph(in, false);
182         } finally {
183             in.close();
184         }
185     }
186
187     public static Transform createGraph(java.io.InputStream JavaDoc in) throws org.netbeans.modules.schema2beans.Schema2BeansException {
188         return createGraph(in, false);
189     }
190
191     public static Transform createGraph(java.io.InputStream JavaDoc in, boolean validate) throws org.netbeans.modules.schema2beans.Schema2BeansException {
192         Document doc = GraphManager.createXmlDocument(in, validate);
193         return createGraph(doc);
194     }
195
196     //
197
// This method returns the root for a new empty bean graph
198
//
199
public static Transform createGraph() {
200         try {
201             return new Transform();
202         }
203         catch (Schema2BeansException e) {
204             throw new RuntimeException JavaDoc(e);
205         }
206     }
207
208     public void validate() throws org.netbeans.modules.schema2beans.ValidateException {
209         boolean restrictionFailure = false;
210         boolean restrictionPassed = false;
211         // Validating property xmltype
212
for (int _index = 0; _index < sizeXmltype(); ++_index) {
213             Xmltype element = getXmltype(_index);
214             if (element != null) {
215                 element.validate();
216             }
217         }
218     }
219
220     // Special serializer: output XML as serialization
221
private void writeObject(java.io.ObjectOutputStream JavaDoc out) throws java.io.IOException JavaDoc{
222         ByteArrayOutputStream baos = new ByteArrayOutputStream();
223         write(baos);
224         String JavaDoc str = baos.toString();;
225         // System.out.println("str='"+str+"'");
226
out.writeUTF(str);
227     }
228     // Special deserializer: read XML as deserialization
229
private void readObject(java.io.ObjectInputStream JavaDoc in) throws java.io.IOException JavaDoc, ClassNotFoundException JavaDoc{
230         try{
231             init(comparators, runtimeVersion);
232             String JavaDoc strDocument = in.readUTF();
233             // System.out.println("strDocument='"+strDocument+"'");
234
ByteArrayInputStream bais = new ByteArrayInputStream(strDocument.getBytes());
235             Document doc = GraphManager.createXmlDocument(bais, false);
236             initOptions(Common.NO_DEFAULT_VALUES);
237             initFromNode(doc, Common.NO_DEFAULT_VALUES);
238         }
239         catch (Schema2BeansException e) {
240             throw new RuntimeException JavaDoc(e);
241         }
242     }
243
244     public void _setSchemaLocation(String JavaDoc location) {
245         if (beanProp().getAttrProp("xsi:schemaLocation", true) == null) {
246             createAttribute("xmlns:xsi", "xmlns:xsi", AttrProp.CDATA | AttrProp.IMPLIED, null, "http://www.w3.org/2001/XMLSchema-instance");
247             setAttributeValue("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
248             createAttribute("xsi:schemaLocation", "xsi:schemaLocation", AttrProp.CDATA | AttrProp.IMPLIED, null, location);
249         }
250         setAttributeValue("xsi:schemaLocation", location);
251     }
252
253     public String JavaDoc _getSchemaLocation() {
254         if (beanProp().getAttrProp("xsi:schemaLocation", true) == null) {
255             createAttribute("xmlns:xsi", "xmlns:xsi", AttrProp.CDATA | AttrProp.IMPLIED, null, "http://www.w3.org/2001/XMLSchema-instance");
256             setAttributeValue("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
257             createAttribute("xsi:schemaLocation", "xsi:schemaLocation", AttrProp.CDATA | AttrProp.IMPLIED, null, null);
258         }
259         return getAttributeValue("xsi:schemaLocation");
260     }
261
262     // Dump the content of this bean returning it as a String
263
public void dump(StringBuffer JavaDoc str, String JavaDoc indent){
264         String JavaDoc s;
265         Object JavaDoc o;
266         org.netbeans.modules.schema2beans.BaseBean n;
267         str.append(indent);
268         str.append("Xmltype["+this.sizeXmltype()+"]"); // NOI18N
269
for(int i=0; i<this.sizeXmltype(); i++)
270         {
271             str.append(indent+"\t");
272             str.append("#"+i+":");
273             n = (org.netbeans.modules.schema2beans.BaseBean) this.getXmltype(i);
274             if (n != null)
275                 n.dump(str, indent + "\t"); // NOI18N
276
else
277                 str.append(indent+"\tnull"); // NOI18N
278
this.dumpAttributes(XMLTYPE, i, str, indent);
279         }
280
281     }
282     public String JavaDoc dumpBeanNode(){
283         StringBuffer JavaDoc str = new StringBuffer JavaDoc();
284         str.append("Transform\n"); // NOI18N
285
this.dump(str, "\n "); // NOI18N
286
return str.toString();
287     }}
288
289 // END_NOI18N
290

291
292 /*
293         The following schema file has been used for generation:
294
295
296 <!--- Put your DTDDoc comment here. -->
297 <!ELEMENT transform (xmltype)*>
298
299 <!--- xmltype : target version of the server xml -->
300 <!ELEMENT xmltype (name, mod-element*)>
301
302 <!--- Put your DTDDoc comment here. -->
303 <!ELEMENT name (#PCDATA)>
304
305 <!--- mod-element : element that contains sub-elements and attributes that need to be removed
306       ie. sub-elements and attributes that were added in a later version of server xml -->
307 <!ELEMENT mod-element (name, mod-attribute*, sub-element*)>
308
309 <!--- sub-element : sub-elements that need to be removed -->
310 <!ELEMENT sub-element (name)>
311
312 <!--- new-attribute : attribute that need to be removed -->
313 <!ELEMENT mod-attribute (name)>
314
315
316 */

317
Popular Tags