KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > schema2beansdev > metadd > MetaDD


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

19 /**
20  * This generated bean class MetaDD
21  * matches the schema element 'metaDD'.
22  *
23  *
24  * This class matches the root element of the DTD,
25  * and is the root of the bean graph.
26  *
27  * metaDD <metaDD> : MetaDD
28  * metaElement <meta-element> : MetaElement[0,n]
29  * dtdName <dtd-name> : String
30  * namespace <namespace> : String[0,1]
31  * beanName <bean-name> : String[0,1]
32  * beanClass <bean-class> : String[0,1]
33  * wrapperClass <wrapper-class> : String[0,1]
34  * defaultValue <default-value> : String[0,n]
35  * knownValue <known-value> : String[0,n]
36  * metaProperty <meta-property> : MetaProperty[0,n]
37  * beanName <bean-name> : String
38  * defaultValue <default-value> : String[0,n]
39  * knownValue <known-value> : String[0,n]
40  * key <key> : boolean[0,1]
41  * EMPTY : String
42  * vetoable <vetoable> : boolean[0,1]
43  * EMPTY : String
44  * comparatorClass <comparator-class> : String[0,n]
45  * implements <implements> : String[0,1]
46  * extends <extends> : String[0,1]
47  * import <import> : String[0,n]
48  * userCode <user-code> : String[0,1]
49  * vetoable <vetoable> : boolean[0,1]
50  * EMPTY : String
51  * skipGeneration <skip-generation> : boolean[0,1]
52  * EMPTY : String
53  * delegatorName <delegator-name> : String[0,1]
54  * delegatorExtends <delegator-extends> : String[0,1]
55  * beanInterfaceExtends <bean-interface-extends> : String[0,1]
56  * canBeEmpty <can-be-empty> : boolean[0,1]
57  * EMPTY : String
58  * implements <implements> : String[0,1]
59  * extends <extends> : String[0,1]
60  * import <import> : String[0,n]
61  * vetoable <vetoable> : boolean[0,1]
62  * EMPTY : String
63  * throwExceptions <throw-exceptions> : boolean[0,1]
64  * EMPTY : String
65  * schemaLocation <schemaLocation> : String[0,1]
66  * finder <finder> : String[0,n]
67  *
68  * @Generated
69  */

70
71 package org.netbeans.modules.schema2beansdev.metadd;
72
73 public class MetaDD implements org.netbeans.modules.schema2beansdev.metadd.CommonBean {
74     public static final String JavaDoc META_ELEMENT = "MetaElement"; // NOI18N
75
public static final String JavaDoc IMPLEMENTS = "Implements"; // NOI18N
76
public static final String JavaDoc EXTENDS = "Extends"; // NOI18N
77
public static final String JavaDoc IMPORT = "Import"; // NOI18N
78
public static final String JavaDoc VETOABLE = "Vetoable"; // NOI18N
79
public static final String JavaDoc THROW_EXCEPTIONS = "ThrowExceptions"; // NOI18N
80
public static final String JavaDoc SCHEMALOCATION = "SchemaLocation"; // NOI18N
81
public static final String JavaDoc FINDER = "Finder"; // NOI18N
82

83     private java.util.List JavaDoc _MetaElement = new java.util.ArrayList JavaDoc(); // List<MetaElement>
84
private String JavaDoc _Implements;
85     private String JavaDoc _Extends;
86     private java.util.List JavaDoc _Import = new java.util.ArrayList JavaDoc(); // List<String>
87
private boolean _Vetoable;
88     private boolean _isSet_Vetoable = false;
89     private boolean _ThrowExceptions;
90     private boolean _isSet_ThrowExceptions = false;
91     private String JavaDoc _SchemaLocation;
92     private java.util.List JavaDoc _Finder = new java.util.ArrayList JavaDoc(); // List<String>
93
private java.lang.String JavaDoc schemaLocation;
94
95     /**
96      * Normal starting point constructor.
97      */

98     public MetaDD() {
99     }
100
101     /**
102      * Deep copy
103      */

104     public MetaDD(org.netbeans.modules.schema2beansdev.metadd.MetaDD source) {
105         this(source, false);
106     }
107
108     /**
109      * Deep copy
110      * @param justData just copy the XML relevant data
111      */

112     public MetaDD(org.netbeans.modules.schema2beansdev.metadd.MetaDD source, boolean justData) {
113         for (java.util.Iterator JavaDoc it = source._MetaElement.iterator();
114             it.hasNext(); ) {
115             org.netbeans.modules.schema2beansdev.metadd.MetaElement srcElement = (org.netbeans.modules.schema2beansdev.metadd.MetaElement)it.next();
116             _MetaElement.add((srcElement == null) ? null : newMetaElement(srcElement, justData));
117         }
118         _Implements = source._Implements;
119         _Extends = source._Extends;
120         for (java.util.Iterator JavaDoc it = source._Import.iterator();
121             it.hasNext(); ) {
122             String JavaDoc srcElement = (String JavaDoc)it.next();
123             _Import.add(srcElement);
124         }
125         _Vetoable = source._Vetoable;
126         _isSet_Vetoable = source._isSet_Vetoable;
127         _ThrowExceptions = source._ThrowExceptions;
128         _isSet_ThrowExceptions = source._isSet_ThrowExceptions;
129         _SchemaLocation = source._SchemaLocation;
130         for (java.util.Iterator JavaDoc it = source._Finder.iterator();
131             it.hasNext(); ) {
132             String JavaDoc srcElement = (String JavaDoc)it.next();
133             _Finder.add(srcElement);
134         }
135         schemaLocation = source.schemaLocation;
136     }
137
138     // This attribute is an array, possibly empty
139
public void setMetaElement(org.netbeans.modules.schema2beansdev.metadd.MetaElement[] value) {
140         if (value == null)
141             value = new MetaElement[0];
142         _MetaElement.clear();
143         ((java.util.ArrayList JavaDoc) _MetaElement).ensureCapacity(value.length);
144         for (int i = 0; i < value.length; ++i) {
145             _MetaElement.add(value[i]);
146         }
147     }
148
149     public void setMetaElement(int index, org.netbeans.modules.schema2beansdev.metadd.MetaElement value) {
150         _MetaElement.set(index, value);
151     }
152
153     public org.netbeans.modules.schema2beansdev.metadd.MetaElement[] getMetaElement() {
154         MetaElement[] arr = new MetaElement[_MetaElement.size()];
155         return (MetaElement[]) _MetaElement.toArray(arr);
156     }
157
158     public java.util.List JavaDoc fetchMetaElementList() {
159         return _MetaElement;
160     }
161
162     public org.netbeans.modules.schema2beansdev.metadd.MetaElement getMetaElement(int index) {
163         return (MetaElement)_MetaElement.get(index);
164     }
165
166     // Return the number of metaElement
167
public int sizeMetaElement() {
168         return _MetaElement.size();
169     }
170
171     public int addMetaElement(org.netbeans.modules.schema2beansdev.metadd.MetaElement value) {
172         _MetaElement.add(value);
173         int positionOfNewItem = _MetaElement.size()-1;
174         return positionOfNewItem;
175     }
176
177     /**
178      * Search from the end looking for @param value, and then remove it.
179      */

180     public int removeMetaElement(org.netbeans.modules.schema2beansdev.metadd.MetaElement value) {
181         int pos = _MetaElement.indexOf(value);
182         if (pos >= 0) {
183             _MetaElement.remove(pos);
184         }
185         return pos;
186     }
187
188     // This attribute is optional
189
public void setImplements(String JavaDoc value) {
190         _Implements = value;
191     }
192
193     public String JavaDoc getImplements() {
194         return _Implements;
195     }
196
197     // This attribute is optional
198
public void setExtends(String JavaDoc value) {
199         _Extends = value;
200     }
201
202     public String JavaDoc getExtends() {
203         return _Extends;
204     }
205
206     // This attribute is an array, possibly empty
207
public void setImport(String JavaDoc[] value) {
208         if (value == null)
209             value = new String JavaDoc[0];
210         _Import.clear();
211         ((java.util.ArrayList JavaDoc) _Import).ensureCapacity(value.length);
212         for (int i = 0; i < value.length; ++i) {
213             _Import.add(value[i]);
214         }
215     }
216
217     public void setImport(int index, String JavaDoc value) {
218         _Import.set(index, value);
219     }
220
221     public String JavaDoc[] getImport() {
222         String JavaDoc[] arr = new String JavaDoc[_Import.size()];
223         return (String JavaDoc[]) _Import.toArray(arr);
224     }
225
226     public java.util.List JavaDoc fetchImportList() {
227         return _Import;
228     }
229
230     public String JavaDoc getImport(int index) {
231         return (String JavaDoc)_Import.get(index);
232     }
233
234     // Return the number of import
235
public int sizeImport() {
236         return _Import.size();
237     }
238
239     public int addImport(String JavaDoc value) {
240         _Import.add(value);
241         int positionOfNewItem = _Import.size()-1;
242         return positionOfNewItem;
243     }
244
245     /**
246      * Search from the end looking for @param value, and then remove it.
247      */

248     public int removeImport(String JavaDoc value) {
249         int pos = _Import.indexOf(value);
250         if (pos >= 0) {
251             _Import.remove(pos);
252         }
253         return pos;
254     }
255
256     // This attribute is optional
257
public void setVetoable(boolean value) {
258         _Vetoable = value;
259         _isSet_Vetoable = true;
260     }
261
262     public boolean isVetoable() {
263         return _Vetoable;
264     }
265
266     // This attribute is optional
267
public void setThrowExceptions(boolean value) {
268         _ThrowExceptions = value;
269         _isSet_ThrowExceptions = true;
270     }
271
272     public boolean isThrowExceptions() {
273         return _ThrowExceptions;
274     }
275
276     // This attribute is optional
277
public void setSchemaLocation(String JavaDoc value) {
278         _SchemaLocation = value;
279     }
280
281     public String JavaDoc getSchemaLocation() {
282         return _SchemaLocation;
283     }
284
285     // This attribute is an array, possibly empty
286
public void setFinder(String JavaDoc[] value) {
287         if (value == null)
288             value = new String JavaDoc[0];
289         _Finder.clear();
290         ((java.util.ArrayList JavaDoc) _Finder).ensureCapacity(value.length);
291         for (int i = 0; i < value.length; ++i) {
292             _Finder.add(value[i]);
293         }
294     }
295
296     public void setFinder(int index, String JavaDoc value) {
297         _Finder.set(index, value);
298     }
299
300     public String JavaDoc[] getFinder() {
301         String JavaDoc[] arr = new String JavaDoc[_Finder.size()];
302         return (String JavaDoc[]) _Finder.toArray(arr);
303     }
304
305     public java.util.List JavaDoc fetchFinderList() {
306         return _Finder;
307     }
308
309     public String JavaDoc getFinder(int index) {
310         return (String JavaDoc)_Finder.get(index);
311     }
312
313     // Return the number of finder
314
public int sizeFinder() {
315         return _Finder.size();
316     }
317
318     public int addFinder(String JavaDoc value) {
319         _Finder.add(value);
320         int positionOfNewItem = _Finder.size()-1;
321         return positionOfNewItem;
322     }
323
324     /**
325      * Search from the end looking for @param value, and then remove it.
326      */

327     public int removeFinder(String JavaDoc value) {
328         int pos = _Finder.indexOf(value);
329         if (pos >= 0) {
330             _Finder.remove(pos);
331         }
332         return pos;
333     }
334
335     public void _setSchemaLocation(String JavaDoc location) {
336         schemaLocation = location;
337     }
338
339     public String JavaDoc _getSchemaLocation() {
340         return schemaLocation;
341     }
342
343     /**
344      * Create a new bean using it's default constructor.
345      * This does not add it to any bean graph.
346      */

347     public org.netbeans.modules.schema2beansdev.metadd.MetaElement newMetaElement() {
348         return new org.netbeans.modules.schema2beansdev.metadd.MetaElement();
349     }
350
351     /**
352      * Create a new bean, copying from another one.
353      * This does not add it to any bean graph.
354      */

355     public org.netbeans.modules.schema2beansdev.metadd.MetaElement newMetaElement(MetaElement source, boolean justData) {
356         return new org.netbeans.modules.schema2beansdev.metadd.MetaElement(source, justData);
357     }
358
359     public void write(java.io.File JavaDoc f) throws java.io.IOException JavaDoc {
360         java.io.OutputStream JavaDoc out = new java.io.FileOutputStream JavaDoc(f);
361         try {
362             write(out);
363         } finally {
364             out.close();
365         }
366     }
367
368     public void write(java.io.OutputStream JavaDoc out) throws java.io.IOException JavaDoc {
369         write(out, null);
370     }
371
372     public void write(java.io.OutputStream JavaDoc out, String JavaDoc encoding) throws java.io.IOException JavaDoc {
373         java.io.Writer JavaDoc w;
374         if (encoding == null) {
375             encoding = "UTF-8"; // NOI18N
376
}
377         w = new java.io.BufferedWriter JavaDoc(new java.io.OutputStreamWriter JavaDoc(out, encoding));
378         write(w, encoding);
379         w.flush();
380     }
381
382     /**
383      * Print this Java Bean to @param out including an XML header.
384      * @param encoding is the encoding style that @param out was opened with.
385      */

386     public void write(java.io.Writer JavaDoc out, String JavaDoc encoding) throws java.io.IOException JavaDoc {
387         out.write("<?xml version='1.0'"); // NOI18N
388
if (encoding != null)
389             out.write(" encoding='"+encoding+"'"); // NOI18N
390
out.write(" ?>\n"); // NOI18N
391
writeNode(out, "metaDD", ""); // NOI18N
392
}
393
394     public void writeNode(java.io.Writer JavaDoc out) throws java.io.IOException JavaDoc {
395         String JavaDoc myName;
396         myName = "metaDD";
397         writeNode(out, myName, ""); // NOI18N
398
}
399
400     public void writeNode(java.io.Writer JavaDoc out, String JavaDoc nodeName, String JavaDoc indent) throws java.io.IOException JavaDoc {
401         writeNode(out, nodeName, null, indent, new java.util.HashMap JavaDoc());
402     }
403
404     /**
405      * It's not recommended to call this method directly.
406      */

407     public void writeNode(java.io.Writer JavaDoc out, String JavaDoc nodeName, String JavaDoc namespace, String JavaDoc indent, java.util.Map JavaDoc namespaceMap) throws java.io.IOException JavaDoc {
408         out.write(indent);
409         out.write("<");
410         if (namespace != null) {
411             out.write((String JavaDoc)namespaceMap.get(namespace));
412             out.write(":");
413         }
414         out.write(nodeName);
415         if (schemaLocation != null) {
416             namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance", "xsi");
417             out.write(" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='");
418             out.write(schemaLocation);
419             out.write("'"); // NOI18N
420
}
421         out.write(">\n");
422         String JavaDoc nextIndent = indent + " ";
423         for (java.util.Iterator JavaDoc it = _MetaElement.iterator();
424             it.hasNext(); ) {
425             org.netbeans.modules.schema2beansdev.metadd.MetaElement element = (org.netbeans.modules.schema2beansdev.metadd.MetaElement)it.next();
426             if (element != null) {
427                 element.writeNode(out, "meta-element", null, nextIndent, namespaceMap);
428             }
429         }
430         if (_Implements != null) {
431             out.write(nextIndent);
432             out.write("<implements"); // NOI18N
433
out.write(">"); // NOI18N
434
org.netbeans.modules.schema2beansdev.metadd.MetaDD.writeXML(out, _Implements, false);
435             out.write("</implements>\n"); // NOI18N
436
}
437         if (_Extends != null) {
438             out.write(nextIndent);
439             out.write("<extends"); // NOI18N
440
out.write(">"); // NOI18N
441
org.netbeans.modules.schema2beansdev.metadd.MetaDD.writeXML(out, _Extends, false);
442             out.write("</extends>\n"); // NOI18N
443
}
444         for (java.util.Iterator JavaDoc it = _Import.iterator(); it.hasNext(); ) {
445             String JavaDoc element = (String JavaDoc)it.next();
446             if (element != null) {
447                 out.write(nextIndent);
448                 out.write("<import"); // NOI18N
449
out.write(">"); // NOI18N
450
org.netbeans.modules.schema2beansdev.metadd.MetaDD.writeXML(out, element, false);
451                 out.write("</import>\n"); // NOI18N
452
}
453         }
454         if (_isSet_Vetoable) {
455             if (_Vetoable) {
456                 out.write(nextIndent);
457                 out.write("<vetoable"); // NOI18N
458
out.write("/>\n"); // NOI18N
459
}
460         }
461         if (_isSet_ThrowExceptions) {
462             if (_ThrowExceptions) {
463                 out.write(nextIndent);
464                 out.write("<throw-exceptions"); // NOI18N
465
out.write("/>\n"); // NOI18N
466
}
467         }
468         if (_SchemaLocation != null) {
469             out.write(nextIndent);
470             out.write("<schemaLocation"); // NOI18N
471
out.write(">"); // NOI18N
472
org.netbeans.modules.schema2beansdev.metadd.MetaDD.writeXML(out, _SchemaLocation, false);
473             out.write("</schemaLocation>\n"); // NOI18N
474
}
475         for (java.util.Iterator JavaDoc it = _Finder.iterator(); it.hasNext(); ) {
476             String JavaDoc element = (String JavaDoc)it.next();
477             if (element != null) {
478                 out.write(nextIndent);
479                 out.write("<finder"); // NOI18N
480
out.write(">"); // NOI18N
481
org.netbeans.modules.schema2beansdev.metadd.MetaDD.writeXML(out, element, false);
482                 out.write("</finder>\n"); // NOI18N
483
}
484         }
485         out.write(indent);
486         out.write("</");
487         if (namespace != null) {
488             out.write((String JavaDoc)namespaceMap.get(namespace));
489             out.write(":");
490         }
491         out.write(nodeName);
492         out.write(">\n");
493     }
494
495     public static MetaDD read(java.io.File JavaDoc f) throws javax.xml.parsers.ParserConfigurationException JavaDoc, org.xml.sax.SAXException JavaDoc, java.io.IOException JavaDoc {
496         java.io.InputStream JavaDoc in = new java.io.FileInputStream JavaDoc(f);
497         try {
498             return read(in);
499         } finally {
500             in.close();
501         }
502     }
503
504     public static MetaDD read(java.io.InputStream JavaDoc in) throws javax.xml.parsers.ParserConfigurationException JavaDoc, org.xml.sax.SAXException JavaDoc, java.io.IOException JavaDoc {
505         return read(new org.xml.sax.InputSource JavaDoc(in), false, null, null);
506     }
507
508     /**
509      * Warning: in readNoEntityResolver character and entity references will
510      * not be read from any DTD in the XML source.
511      * However, this way is faster since no DTDs are looked up
512      * (possibly skipping network access) or parsed.
513      */

514     public static MetaDD readNoEntityResolver(java.io.InputStream JavaDoc in) throws javax.xml.parsers.ParserConfigurationException JavaDoc, org.xml.sax.SAXException JavaDoc, java.io.IOException JavaDoc {
515         return read(new org.xml.sax.InputSource JavaDoc(in), false,
516             new org.xml.sax.EntityResolver JavaDoc() {
517             public org.xml.sax.InputSource JavaDoc resolveEntity(String JavaDoc publicId, String JavaDoc systemId) {
518                 java.io.ByteArrayInputStream JavaDoc bin = new java.io.ByteArrayInputStream JavaDoc(new byte[0]);
519                 return new org.xml.sax.InputSource JavaDoc(bin);
520             }
521         }
522             , null);
523     }
524
525     public static MetaDD read(org.xml.sax.InputSource JavaDoc in, boolean validate, org.xml.sax.EntityResolver JavaDoc er, org.xml.sax.ErrorHandler JavaDoc eh) throws javax.xml.parsers.ParserConfigurationException JavaDoc, org.xml.sax.SAXException JavaDoc, java.io.IOException JavaDoc {
526         javax.xml.parsers.DocumentBuilderFactory JavaDoc dbf = javax.xml.parsers.DocumentBuilderFactory.newInstance();
527         dbf.setValidating(validate);
528         dbf.setNamespaceAware(true);
529         javax.xml.parsers.DocumentBuilder JavaDoc db = dbf.newDocumentBuilder();
530         if (er != null) db.setEntityResolver(er);
531         if (eh != null) db.setErrorHandler(eh);
532         org.w3c.dom.Document JavaDoc doc = db.parse(in);
533         return read(doc);
534     }
535
536     public static MetaDD read(org.w3c.dom.Document JavaDoc document) {
537         MetaDD aMetaDD = new MetaDD();
538         aMetaDD.readFromDocument(document);
539         return aMetaDD;
540     }
541
542     protected void readFromDocument(org.w3c.dom.Document JavaDoc document) {
543         readNode(document.getDocumentElement());
544     }
545
546     public void readNode(org.w3c.dom.Node JavaDoc node) {
547         readNode(node, new java.util.HashMap JavaDoc());
548     }
549
550     public void readNode(org.w3c.dom.Node JavaDoc node, java.util.Map JavaDoc namespacePrefixes) {
551         if (node.hasAttributes()) {
552             org.w3c.dom.NamedNodeMap JavaDoc attrs = node.getAttributes();
553             org.w3c.dom.Attr JavaDoc attr;
554             java.lang.String JavaDoc attrValue;
555             boolean firstNamespaceDef = true;
556             for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) {
557                 attr = (org.w3c.dom.Attr JavaDoc) attrs.item(attrNum);
558                 String JavaDoc attrName = attr.getName();
559                 if (attrName.startsWith("xmlns:")) {
560                     if (firstNamespaceDef) {
561                         firstNamespaceDef = false;
562                         // Dup prefix map, so as to not write over previous values, and to make it easy to clear out our entries.
563
namespacePrefixes = new java.util.HashMap JavaDoc(namespacePrefixes);
564                     }
565                     String JavaDoc attrNSPrefix = attrName.substring(6, attrName.length());
566                     namespacePrefixes.put(attrNSPrefix, attr.getValue());
567                 }
568             }
569             String JavaDoc xsiPrefix = "xsi";
570             for (java.util.Iterator JavaDoc it = namespacePrefixes.keySet().iterator();
571                 it.hasNext(); ) {
572                 String JavaDoc prefix = (String JavaDoc) it.next();
573                 String JavaDoc ns = (String JavaDoc) namespacePrefixes.get(prefix);
574                 if ("http://www.w3.org/2001/XMLSchema-instance".equals(ns)) {
575                     xsiPrefix = prefix;
576                     break;
577                 }
578             }
579             attr = (org.w3c.dom.Attr JavaDoc) attrs.getNamedItem(""+xsiPrefix+":schemaLocation");
580             if (attr != null) {
581                 attrValue = attr.getValue();
582                 schemaLocation = attrValue;
583             }
584         }
585         org.w3c.dom.NodeList JavaDoc children = node.getChildNodes();
586         for (int i = 0, size = children.getLength(); i < size; ++i) {
587             org.w3c.dom.Node JavaDoc childNode = children.item(i);
588             String JavaDoc childNodeName = (childNode.getLocalName() == null ? childNode.getNodeName().intern() : childNode.getLocalName().intern());
589             String JavaDoc childNodeValue = "";
590             if (childNode.getFirstChild() != null) {
591                 childNodeValue = childNode.getFirstChild().getNodeValue();
592             }
593             if (childNodeName == "meta-element") {
594                 MetaElement aMetaElement = newMetaElement();
595                 aMetaElement.readNode(childNode, namespacePrefixes);
596                 _MetaElement.add(aMetaElement);
597             }
598             else if (childNodeName == "implements") {
599                 _Implements = childNodeValue;
600             }
601             else if (childNodeName == "extends") {
602                 _Extends = childNodeValue;
603             }
604             else if (childNodeName == "import") {
605                 String JavaDoc aImport;
606                 aImport = childNodeValue;
607                 _Import.add(aImport);
608             }
609             else if (childNodeName == "vetoable") {
610                 if (childNode.getFirstChild() == null)
611                     _Vetoable = true;
612                 else
613                     _Vetoable = java.lang.Boolean.valueOf(childNodeValue).booleanValue();
614                 _isSet_Vetoable = true;
615             }
616             else if (childNodeName == "throw-exceptions") {
617                 if (childNode.getFirstChild() == null)
618                     _ThrowExceptions = true;
619                 else
620                     _ThrowExceptions = java.lang.Boolean.valueOf(childNodeValue).booleanValue();
621                 _isSet_ThrowExceptions = true;
622             }
623             else if (childNodeName == "schemaLocation") {
624                 _SchemaLocation = childNodeValue;
625             }
626             else if (childNodeName == "finder") {
627                 String JavaDoc aFinder;
628                 aFinder = childNodeValue;
629                 _Finder.add(aFinder);
630             }
631             else {
632                 // Found extra unrecognized childNode
633
}
634         }
635     }
636
637     /**
638      * Takes some text to be printed into an XML stream and escapes any
639      * characters that might make it invalid XML (like '<').
640      */

641     public static void writeXML(java.io.Writer JavaDoc out, String JavaDoc msg) throws java.io.IOException JavaDoc {
642         writeXML(out, msg, true);
643     }
644
645     public static void writeXML(java.io.Writer JavaDoc out, String JavaDoc msg, boolean attribute) throws java.io.IOException JavaDoc {
646         if (msg == null)
647             return;
648         int msgLength = msg.length();
649         for (int i = 0; i < msgLength; ++i) {
650             char c = msg.charAt(i);
651             writeXML(out, c, attribute);
652         }
653     }
654
655     public static void writeXML(java.io.Writer JavaDoc out, char msg, boolean attribute) throws java.io.IOException JavaDoc {
656         if (msg == '&')
657             out.write("&amp;");
658         else if (msg == '<')
659             out.write("&lt;");
660         else if (msg == '>')
661             out.write("&gt;");
662         else if (attribute) {
663             if (msg == '"')
664                 out.write("&quot;");
665             else if (msg == '\'')
666                 out.write("&apos;");
667             else if (msg == '\n')
668                 out.write("&#xA;");
669             else if (msg == '\t')
670                 out.write("&#x9;");
671             else
672                 out.write(msg);
673         }
674         else
675             out.write(msg);
676     }
677
678     public static class ValidateException extends Exception JavaDoc {
679         private org.netbeans.modules.schema2beansdev.metadd.CommonBean failedBean;
680         private String JavaDoc failedPropertyName;
681         private FailureType failureType;
682         public ValidateException(String JavaDoc msg, String JavaDoc failedPropertyName, org.netbeans.modules.schema2beansdev.metadd.CommonBean failedBean) {
683             super(msg);
684             this.failedBean = failedBean;
685             this.failedPropertyName = failedPropertyName;
686         }
687         public ValidateException(String JavaDoc msg, FailureType ft, String JavaDoc failedPropertyName, org.netbeans.modules.schema2beansdev.metadd.CommonBean failedBean) {
688             super(msg);
689             this.failureType = ft;
690             this.failedBean = failedBean;
691             this.failedPropertyName = failedPropertyName;
692         }
693         public String JavaDoc getFailedPropertyName() {return failedPropertyName;}
694         public FailureType getFailureType() {return failureType;}
695         public org.netbeans.modules.schema2beansdev.metadd.CommonBean getFailedBean() {return failedBean;}
696         public static class FailureType {
697             private final String JavaDoc name;
698             private FailureType(String JavaDoc name) {this.name = name;}
699             public String JavaDoc toString() { return name;}
700             public static final FailureType NULL_VALUE = new FailureType("NULL_VALUE");
701             public static final FailureType DATA_RESTRICTION = new FailureType("DATA_RESTRICTION");
702             public static final FailureType ENUM_RESTRICTION = new FailureType("ENUM_RESTRICTION");
703             public static final FailureType ALL_RESTRICTIONS = new FailureType("ALL_RESTRICTIONS");
704             public static final FailureType MUTUALLY_EXCLUSIVE = new FailureType("MUTUALLY_EXCLUSIVE");
705         }
706     }
707
708     public void validate() throws org.netbeans.modules.schema2beansdev.metadd.MetaDD.ValidateException {
709         boolean restrictionFailure = false;
710         boolean restrictionPassed = false;
711         // Validating property metaElement
712
for (int _index = 0; _index < sizeMetaElement(); ++_index) {
713             org.netbeans.modules.schema2beansdev.metadd.MetaElement element = getMetaElement(_index);
714             if (element != null) {
715                 element.validate();
716             }
717         }
718         // Validating property implements
719
// Validating property extends
720
// Validating property import
721
// Validating property vetoable
722
// Validating property throwExceptions
723
// Validating property schemaLocation
724
// Validating property finder
725
}
726
727     public void changePropertyByName(String JavaDoc name, Object JavaDoc value) {
728         if (name == null) return;
729         name = name.intern();
730         if (name == "metaElement")
731             addMetaElement((MetaElement)value);
732         else if (name == "metaElement[]")
733             setMetaElement((MetaElement[]) value);
734         else if (name == "implements")
735             setImplements((String JavaDoc)value);
736         else if (name == "extends")
737             setExtends((String JavaDoc)value);
738         else if (name == "import")
739             addImport((String JavaDoc)value);
740         else if (name == "import[]")
741             setImport((String JavaDoc[]) value);
742         else if (name == "vetoable")
743             setVetoable(((java.lang.Boolean JavaDoc)value).booleanValue());
744         else if (name == "throwExceptions")
745             setThrowExceptions(((java.lang.Boolean JavaDoc)value).booleanValue());
746         else if (name == "schemaLocation")
747             setSchemaLocation((String JavaDoc)value);
748         else if (name == "finder")
749             addFinder((String JavaDoc)value);
750         else if (name == "finder[]")
751             setFinder((String JavaDoc[]) value);
752         else
753             throw new IllegalArgumentException JavaDoc(name+" is not a valid property name for MetaDD");
754     }
755
756     public Object JavaDoc fetchPropertyByName(String JavaDoc name) {
757         if (name == "metaElement[]")
758             return getMetaElement();
759         if (name == "implements")
760             return getImplements();
761         if (name == "extends")
762             return getExtends();
763         if (name == "import[]")
764             return getImport();
765         if (name == "vetoable")
766             return (isVetoable() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE);
767         if (name == "throwExceptions")
768             return (isThrowExceptions() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE);
769         if (name == "schemaLocation")
770             return getSchemaLocation();
771         if (name == "finder[]")
772             return getFinder();
773         throw new IllegalArgumentException JavaDoc(name+" is not a valid property name for MetaDD");
774     }
775
776     public String JavaDoc nameSelf() {
777         return "/MetaDD";
778     }
779
780     public String JavaDoc nameChild(Object JavaDoc childObj) {
781         return nameChild(childObj, false, false);
782     }
783
784     /**
785      * @param childObj The child object to search for
786      * @param returnSchemaName Whether or not the schema name should be returned or the property name
787      * @return null if not found
788      */

789     public String JavaDoc nameChild(Object JavaDoc childObj, boolean returnConstName, boolean returnSchemaName) {
790         return nameChild(childObj, returnConstName, returnSchemaName, false);
791     }
792
793     /**
794      * @param childObj The child object to search for
795      * @param returnSchemaName Whether or not the schema name should be returned or the property name
796      * @return null if not found
797      */

798     public String JavaDoc nameChild(Object JavaDoc childObj, boolean returnConstName, boolean returnSchemaName, boolean returnXPathName) {
799         if (childObj instanceof java.lang.String JavaDoc) {
800             java.lang.String JavaDoc child = (java.lang.String JavaDoc) childObj;
801             if (child == _Implements) {
802                 if (returnConstName) {
803                     return IMPLEMENTS;
804                 } else if (returnSchemaName) {
805                     return "implements";
806                 } else if (returnXPathName) {
807                     return "implements";
808                 } else {
809                     return "Implements";
810                 }
811             }
812             if (child == _Extends) {
813                 if (returnConstName) {
814                     return EXTENDS;
815                 } else if (returnSchemaName) {
816                     return "extends";
817                 } else if (returnXPathName) {
818                     return "extends";
819                 } else {
820                     return "Extends";
821                 }
822             }
823             int index = 0;
824             for (java.util.Iterator JavaDoc it = _Import.iterator(); it.hasNext();
825                 ) {
826                 String JavaDoc element = (String JavaDoc)it.next();
827                 if (child == element) {
828                     if (returnConstName) {
829                         return IMPORT;
830                     } else if (returnSchemaName) {
831                         return "import";
832                     } else if (returnXPathName) {
833                         return "import[position()="+index+"]";
834                     } else {
835                         return "Import."+Integer.toHexString(index);
836                     }
837                 }
838                 ++index;
839             }
840             if (child == _SchemaLocation) {
841                 if (returnConstName) {
842                     return SCHEMALOCATION;
843                 } else if (returnSchemaName) {
844                     return "schemaLocation";
845                 } else if (returnXPathName) {
846                     return "schemaLocation";
847                 } else {
848                     return "SchemaLocation";
849                 }
850             }
851             index = 0;
852             for (java.util.Iterator JavaDoc it = _Finder.iterator(); it.hasNext();
853                 ) {
854                 String JavaDoc element = (String JavaDoc)it.next();
855                 if (child == element) {
856                     if (returnConstName) {
857                         return FINDER;
858                     } else if (returnSchemaName) {
859                         return "finder";
860                     } else if (returnXPathName) {
861                         return "finder[position()="+index+"]";
862                     } else {
863                         return "Finder."+Integer.toHexString(index);
864                     }
865                 }
866                 ++index;
867             }
868         }
869         if (childObj instanceof MetaElement) {
870             MetaElement child = (MetaElement) childObj;
871             int index = 0;
872             for (java.util.Iterator JavaDoc it = _MetaElement.iterator();
873                 it.hasNext(); ) {
874                 org.netbeans.modules.schema2beansdev.metadd.MetaElement element = (org.netbeans.modules.schema2beansdev.metadd.MetaElement)it.next();
875                 if (child == element) {
876                     if (returnConstName) {
877                         return META_ELEMENT;
878                     } else if (returnSchemaName) {
879                         return "meta-element";
880                     } else if (returnXPathName) {
881                         return "meta-element[position()="+index+"]";
882                     } else {
883                         return "MetaElement."+Integer.toHexString(index);
884                     }
885                 }
886                 ++index;
887             }
888         }
889         if (childObj instanceof java.lang.Boolean JavaDoc) {
890             java.lang.Boolean JavaDoc child = (java.lang.Boolean JavaDoc) childObj;
891             if (((java.lang.Boolean JavaDoc)child).booleanValue() == _Vetoable) {
892                 if (returnConstName) {
893                     return VETOABLE;
894                 } else if (returnSchemaName) {
895                     return "vetoable";
896                 } else if (returnXPathName) {
897                     return "vetoable";
898                 } else {
899                     return "Vetoable";
900                 }
901             }
902             if (((java.lang.Boolean JavaDoc)child).booleanValue() == _ThrowExceptions) {
903                 if (returnConstName) {
904                     return THROW_EXCEPTIONS;
905                 } else if (returnSchemaName) {
906                     return "throw-exceptions";
907                 } else if (returnXPathName) {
908                     return "throw-exceptions";
909                 } else {
910                     return "ThrowExceptions";
911                 }
912             }
913         }
914         return null;
915     }
916
917     /**
918      * Return an array of all of the properties that are beans and are set.
919      */

920     public org.netbeans.modules.schema2beansdev.metadd.CommonBean[] childBeans(boolean recursive) {
921         java.util.List JavaDoc children = new java.util.LinkedList JavaDoc();
922         childBeans(recursive, children);
923         org.netbeans.modules.schema2beansdev.metadd.CommonBean[] result = new org.netbeans.modules.schema2beansdev.metadd.CommonBean[children.size()];
924         return (org.netbeans.modules.schema2beansdev.metadd.CommonBean[]) children.toArray(result);
925     }
926
927     /**
928      * Put all child beans into the beans list.
929      */

930     public void childBeans(boolean recursive, java.util.List JavaDoc beans) {
931         for (java.util.Iterator JavaDoc it = _MetaElement.iterator();
932             it.hasNext(); ) {
933             org.netbeans.modules.schema2beansdev.metadd.MetaElement element = (org.netbeans.modules.schema2beansdev.metadd.MetaElement)it.next();
934             if (element != null) {
935                 if (recursive) {
936                     element.childBeans(true, beans);
937                 }
938                 beans.add(element);
939             }
940         }
941     }
942
943     public boolean equals(Object JavaDoc o) {
944         return o instanceof org.netbeans.modules.schema2beansdev.metadd.MetaDD && equals((org.netbeans.modules.schema2beansdev.metadd.MetaDD) o);
945     }
946
947     public boolean equals(org.netbeans.modules.schema2beansdev.metadd.MetaDD inst) {
948         if (inst == this) {
949             return true;
950         }
951         if (inst == null) {
952             return false;
953         }
954         if (sizeMetaElement() != inst.sizeMetaElement())
955             return false;
956         // Compare every element.
957
for (java.util.Iterator JavaDoc it = _MetaElement.iterator(), it2 = inst._MetaElement.iterator();
958             it.hasNext() && it2.hasNext(); ) {
959             org.netbeans.modules.schema2beansdev.metadd.MetaElement element = (org.netbeans.modules.schema2beansdev.metadd.MetaElement)it.next();
960             org.netbeans.modules.schema2beansdev.metadd.MetaElement element2 = (org.netbeans.modules.schema2beansdev.metadd.MetaElement)it2.next();
961             if (!(element == null ? element2 == null : element.equals(element2))) {
962                 return false;
963             }
964         }
965         if (!(_Implements == null ? inst._Implements == null : _Implements.equals(inst._Implements))) {
966             return false;
967         }
968         if (!(_Extends == null ? inst._Extends == null : _Extends.equals(inst._Extends))) {
969             return false;
970         }
971         if (sizeImport() != inst.sizeImport())
972             return false;
973         // Compare every element.
974
for (java.util.Iterator JavaDoc it = _Import.iterator(), it2 = inst._Import.iterator();
975             it.hasNext() && it2.hasNext(); ) {
976             String JavaDoc element = (String JavaDoc)it.next();
977             String JavaDoc element2 = (String JavaDoc)it2.next();
978             if (!(element == null ? element2 == null : element.equals(element2))) {
979                 return false;
980             }
981         }
982         if (_isSet_Vetoable != inst._isSet_Vetoable) {
983             return false;
984         }
985         if (_isSet_Vetoable) {
986             if (!(_Vetoable == inst._Vetoable)) {
987                 return false;
988             }
989         }
990         if (_isSet_ThrowExceptions != inst._isSet_ThrowExceptions) {
991             return false;
992         }
993         if (_isSet_ThrowExceptions) {
994             if (!(_ThrowExceptions == inst._ThrowExceptions)) {
995                 return false;
996             }
997         }
998         if (!(_SchemaLocation == null ? inst._SchemaLocation == null : _SchemaLocation.equals(inst._SchemaLocation))) {
999             return false;
1000        }
1001        if (sizeFinder() != inst.sizeFinder())
1002            return false;
1003        // Compare every element.
1004
for (java.util.Iterator JavaDoc it = _Finder.iterator(), it2 = inst._Finder.iterator();
1005            it.hasNext() && it2.hasNext(); ) {
1006            String JavaDoc element = (String JavaDoc)it.next();
1007            String JavaDoc element2 = (String JavaDoc)it2.next();
1008            if (!(element == null ? element2 == null : element.equals(element2))) {
1009                return false;
1010            }
1011        }
1012        return true;
1013    }
1014
1015    public int hashCode() {
1016        int result = 17;
1017        result = 37*result + (_MetaElement == null ? 0 : _MetaElement.hashCode());
1018        result = 37*result + (_Implements == null ? 0 : _Implements.hashCode());
1019        result = 37*result + (_Extends == null ? 0 : _Extends.hashCode());
1020        result = 37*result + (_Import == null ? 0 : _Import.hashCode());
1021        result = 37*result + (_isSet_Vetoable ? 0 : (_Vetoable ? 0 : 1));
1022        result = 37*result + (_isSet_ThrowExceptions ? 0 : (_ThrowExceptions ? 0 : 1));
1023        result = 37*result + (_SchemaLocation == null ? 0 : _SchemaLocation.hashCode());
1024        result = 37*result + (_Finder == null ? 0 : _Finder.hashCode());
1025        return result;
1026    }
1027
1028    public String JavaDoc toString() {
1029        java.io.StringWriter JavaDoc sw = new java.io.StringWriter JavaDoc();
1030        try {
1031            writeNode(sw);
1032        } catch (java.io.IOException JavaDoc e) {
1033            // How can we actually get an IOException on a StringWriter?
1034
throw new RuntimeException JavaDoc(e);
1035        }
1036        return sw.toString();
1037    }
1038
1039}
1040
1041
1042/*
1043        The following schema file has been used for generation:
1044
1045<!-- This holds data about the schema that is not part of DTDs and/or XML Schemas.
1046-->
1047
1048<!--
1049-->
1050<!ELEMENT metaDD (meta-element*, implements?, extends?, import*, vetoable?, throw-exceptions?, schemaLocation?, finder*)>
1051
1052<!--
1053-->
1054<!ELEMENT meta-element (dtd-name, namespace?, bean-name?, bean-class?, wrapper-class?, default-value*, known-value*, meta-property*, comparator-class*, implements?, extends?, import*, user-code?, vetoable?, skip-generation?, delegator-name?, delegator-extends?, bean-interface-extends?, can-be-empty?>
1055
1056<!--
1057-->
1058<!ELEMENT meta-property (bean-name, default-value*, known-value*, key?, vetoable?)>
1059
1060<!ELEMENT delegator-name (#PCDATA)>
1061
1062<!--
1063-->
1064<!ELEMENT implements (#PCDATA)>
1065
1066<!--
1067-->
1068<!ELEMENT extends (#PCDATA)>
1069
1070<!--
1071-->
1072<!ELEMENT import (#PCDATA)>
1073
1074<!--
1075-->
1076<!ELEMENT dtd-name (#PCDATA)>
1077
1078<!ELEMENT namespace (#PCDATA)>
1079
1080<!--
1081-->
1082<!ELEMENT default-value (#PCDATA)>
1083
1084<!--
1085-->
1086<!ELEMENT skip-generation EMPTY>
1087
1088<!--
1089-->
1090<!ELEMENT key EMPTY>
1091
1092<!--
1093-->
1094<!ELEMENT vetoable EMPTY>
1095
1096<!--
1097-->
1098<!ELEMENT known-value (#PCDATA)>
1099
1100<!--
1101-->
1102<!ELEMENT bean-name (#PCDATA)>
1103
1104<!--
1105-->
1106<!ELEMENT bean-class (#PCDATA)>
1107
1108<!--
1109-->
1110<!ELEMENT wrapper-class (#PCDATA)>
1111
1112<!--
1113-->
1114<!ELEMENT comparator-class (#PCDATA)>
1115
1116<!--
1117-->
1118<!ELEMENT user-code (#PCDATA)>
1119
1120<!ELEMENT throw-exceptions EMPTY>
1121
1122<!-- Automatically set the schemaLocation -->
1123<!ELEMENT schemaLocation (#PCDATA)>
1124
1125<!ELEMENT finder (#PCDATA)>
1126
1127<!ELEMENT bean-interface-extends (#PCDATA)>
1128
1129<!ELEMENT can-be-empty EMPTY>
1130
1131*/

1132
Popular Tags