2
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
4
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
6
* The contents of this file are subject to the terms of either the GNU
7
* General Public License Version 2 only ("GPL") or the Common
8
* Development and Distribution License("CDDL") (collectively, the
9
* "License"). You may not use this file except in compliance with the
10
* License. You can obtain a copy of the License at
11
* http://www.netbeans.org/cddl-gplv2.html
12
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
* specific language governing permissions and limitations under the
14
* License. When distributing the software, include this License Header
15
* Notice in each file and include the License file at
16
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17
* particular file as subject to the "Classpath" exception as provided
18
* by Sun in the GPL Version 2 section of the License file that
19
* accompanied this code. If applicable, add the following below the
20
* License Header, with the fields enclosed by brackets [] replaced by
21
* your own identifying information:
22
* "Portions Copyrighted [year] [name of copyright owner]"
26
* The Original Software is NetBeans. The Initial Developer of the Original
27
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
28
* Microsystems, Inc. All Rights Reserved.
30
* If you wish your version of this file to be governed by only the CDDL
31
* or only the GPL Version 2, indicate your decision by adding
32
* "[Contributor] elects to include this software in this distribution
33
* under the [CDDL or GPL Version 2] license." If you do not indicate a
34
* single choice of license, a recipient has the option to distribute
35
* your version of this file under either the CDDL, the GPL Version 2 or
36
* to extend the choice of license to its licensees as provided above.
37
* However, if you add GPL Version 2 code and therefore, elected the GPL
38
* Version 2 license, then the option applies only if the new code is
39
* made subject to such option by the copyright holder.
42
* This generated bean class Schemas
43
* matches the schema element 'schemas'.
45
* Generated on Thu Apr 05 11:55:09 PDT 2007
47
* This class matches the root element of the XML Schema,
48
* and is the root of the bean graph.
50
* schemas <schemas> : Schemas
51
* [attr: destdir CDATA #IMPLIED : java.lang.String]
52
* [attr: projectName CDATA #IMPLIED : java.lang.String]
53
* schema <schema> : Schema[0,n]
54
* [attr: type CDATA #IMPLIED : java.lang.String]
55
* [attr: package CDATA #IMPLIED : java.lang.String]
56
* [attr: name CDATA #REQUIRED : java.lang.String]
57
* xjcOptions <xjc-options> : XjcOptions[0,1]
58
* xjcOption <xjc-option> : XjcOption[0,n]
59
* [attr: name CDATA #IMPLIED : java.lang.String]
60
* [attr: value CDATA #IMPLIED : java.lang.String]
61
* schemaSources <schema-sources> : SchemaSources[0,1]
62
* schemaSource <schema-source> : SchemaSource[0,n]
63
* [attr: location CDATA #IMPLIED : java.lang.String]
64
* [attr: origLocation CDATA #IMPLIED : java.lang.String]
65
* [attr: origLocationType CDATA #IMPLIED : java.lang.String]
66
* bindings <bindings> : Bindings[0,1]
67
* binding <binding> : Binding[0,n]
68
* [attr: origLocation CDATA #IMPLIED : java.lang.String]
69
* [attr: location CDATA #IMPLIED : java.lang.String]
70
* catalog <catalog> : Catalog[0,1]
71
* [attr: location CDATA #IMPLIED : java.lang.String]
72
* [attr: origLocation CDATA #IMPLIED : java.lang.String]
77
package org.netbeans.modules.xml.jaxb.cfg.schema;
79
public class Schemas {
80
public static final String DESTDIR = "Destdir"; // NOI18N
81
public static final String PROJECTNAME = "ProjectName"; // NOI18N
82
public static final String SCHEMA = "Schema"; // NOI18N
84
private java.lang.String _Destdir;
85
private java.lang.String _ProjectName;
86
private java.util.List _Schema = new java.util.ArrayList(); // List<Schema>
87
private java.lang.String schemaLocation;
90
* Normal starting point constructor.
98
public Schemas(org.netbeans.modules.xml.jaxb.cfg.schema.Schemas source) {
104
* @param justData just copy the XML relevant data
106
public Schemas(org.netbeans.modules.xml.jaxb.cfg.schema.Schemas source, boolean justData) {
107
_Destdir = source._Destdir;
108
_ProjectName = source._ProjectName;
109
for (java.util.Iterator it = source._Schema.iterator();
111
org.netbeans.modules.xml.jaxb.cfg.schema.Schema srcElement = (org.netbeans.modules.xml.jaxb.cfg.schema.Schema)it.next();
112
_Schema.add((srcElement == null) ? null : newSchema(srcElement, justData));
114
schemaLocation = source.schemaLocation;
117
// This attribute is optional
118
public void setDestdir(java.lang.String value) {
122
public java.lang.String getDestdir() {
126
// This attribute is optional
127
public void setProjectName(java.lang.String value) {
128
_ProjectName = value;
131
public java.lang.String getProjectName() {
135
// This attribute is an array, possibly empty
136
public void setSchema(org.netbeans.modules.xml.jaxb.cfg.schema.Schema[] value) {
138
value = new Schema[0];
140
((java.util.ArrayList) _Schema).ensureCapacity(value.length);
141
for (int i = 0; i < value.length; ++i) {
142
_Schema.add(value[i]);
146
public void setSchema(int index,org.netbeans.modules.xml.jaxb.cfg.schema.Schema value) {
147
_Schema.set(index, value);
150
public org.netbeans.modules.xml.jaxb.cfg.schema.Schema[] getSchema() {
151
Schema[] arr = new Schema[_Schema.size()];
152
return (Schema[]) _Schema.toArray(arr);
155
public java.util.List fetchSchemaList() {
159
public org.netbeans.modules.xml.jaxb.cfg.schema.Schema getSchema(int index) {
160
return (Schema)_Schema.get(index);
163
// Return the number of schema
164
public int sizeSchema() {
165
return _Schema.size();
168
public int addSchema(org.netbeans.modules.xml.jaxb.cfg.schema.Schema value) {
170
int positionOfNewItem = _Schema.size()-1;
171
return positionOfNewItem;
175
* Search from the end looking for @param value, and then remove it.
177
public int removeSchema(org.netbeans.modules.xml.jaxb.cfg.schema.Schema value) {
178
int pos = _Schema.indexOf(value);
185
public void _setSchemaLocation(String location) {
186
schemaLocation = location;
189
public String _getSchemaLocation() {
190
return schemaLocation;
194
* Create a new bean using it's default constructor.
195
* This does not add it to any bean graph.
197
public org.netbeans.modules.xml.jaxb.cfg.schema.Schema newSchema() {
198
return new org.netbeans.modules.xml.jaxb.cfg.schema.Schema();
202
* Create a new bean, copying from another one.
203
* This does not add it to any bean graph.
205
public org.netbeans.modules.xml.jaxb.cfg.schema.Schema newSchema(Schema source, boolean justData) {
206
return new org.netbeans.modules.xml.jaxb.cfg.schema.Schema(source, justData);
209
public void write(org.openide.filesystems.FileObject fo) throws java.io.IOException {
210
org.openide.filesystems.FileLock lock = fo.lock();
212
java.io.OutputStream out = fo.getOutputStream(lock);
220
public void write(org.openide.filesystems.FileObject dir, String filename) throws java.io.IOException {
221
org.openide.filesystems.FileObject file = dir.getFileObject(filename);
223
file = dir.createData(filename);
228
public void write(java.io.File f) throws java.io.IOException {
229
java.io.OutputStream out = new java.io.FileOutputStream(f);
237
public void write(java.io.OutputStream out) throws java.io.IOException {
241
public void write(java.io.OutputStream out, String encoding) throws java.io.IOException {
243
if (encoding == null) {
244
encoding = "UTF-8"; // NOI18N
246
w = new java.io.BufferedWriter(new java.io.OutputStreamWriter(out, encoding));
252
* Print this Java Bean to @param out including an XML header.
253
* @param encoding is the encoding style that @param out was opened with.
255
public void write(java.io.Writer out, String encoding) throws java.io.IOException {
256
out.write("<?xml version='1.0'"); // NOI18N
257
if (encoding != null)
258
out.write(" encoding='"+encoding+"'"); // NOI18N
259
out.write(" ?>\n"); // NOI18N
260
writeNode(out, "schemas", ""); // NOI18N
263
public void writeNode(java.io.Writer out) throws java.io.IOException {
266
writeNode(out, myName, ""); // NOI18N
269
public void writeNode(java.io.Writer out, String nodeName, String indent) throws java.io.IOException {
270
writeNode(out, nodeName, null, indent, new java.util.HashMap());
274
* It's not recommended to call this method directly.
276
public void writeNode(java.io.Writer out, String nodeName, String namespace, String indent, java.util.Map namespaceMap) throws java.io.IOException {
279
if (namespace != null) {
280
out.write((String)namespaceMap.get(namespace));
284
out.write(" xmlns='"); // NOI18N
285
out.write("http://xml.netbeans.org/schema/JAXBWizConfig"); // NOI18N
286
out.write("'"); // NOI18N
287
if (schemaLocation != null) {
288
namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance", "xsi");
289
out.write(" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='");
290
out.write(schemaLocation);
291
out.write("'"); // NOI18N
293
writeNodeAttributes(out, nodeName, namespace, indent, namespaceMap);
295
writeNodeChildren(out, nodeName, namespace, indent, namespaceMap);
298
if (namespace != null) {
299
out.write((String)namespaceMap.get(namespace));
306
protected void writeNodeAttributes(java.io.Writer out, String nodeName, String namespace, String indent, java.util.Map namespaceMap) throws java.io.IOException {
307
// destdir is an attribute with namespace http://xml.netbeans.org/schema/JAXBWizConfig
308
if (_Destdir != null) {
309
out.write(" destdir='");
310
org.netbeans.modules.xml.jaxb.cfg.schema.Schemas.writeXML(out, _Destdir, true);
311
out.write("'"); // NOI18N
313
// projectName is an attribute with namespace http://xml.netbeans.org/schema/JAXBWizConfig
314
if (_ProjectName != null) {
315
out.write(" projectName='");
316
org.netbeans.modules.xml.jaxb.cfg.schema.Schemas.writeXML(out, _ProjectName, true);
317
out.write("'"); // NOI18N
321
protected void writeNodeChildren(java.io.Writer out, String nodeName, String namespace, String indent, java.util.Map namespaceMap) throws java.io.IOException {
322
String nextIndent = indent + " ";
323
for (java.util.Iterator it = _Schema.iterator(); it.hasNext(); ) {
324
org.netbeans.modules.xml.jaxb.cfg.schema.Schema element = (org.netbeans.modules.xml.jaxb.cfg.schema.Schema)it.next();
325
if (element != null) {
326
element.writeNode(out, "schema", null, nextIndent, namespaceMap);
331
public static Schemas read(org.openide.filesystems.FileObject fo) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException {
332
java.io.InputStream in = fo.getInputStream();
340
public static Schemas read(java.io.File f) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException {
341
java.io.InputStream in = new java.io.FileInputStream(f);
349
public static Schemas read(java.io.InputStream in) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException {
350
return read(new org.xml.sax.InputSource(in), false, null, null);
354
* Warning: in readNoEntityResolver character and entity references will
355
* not be read from any DTD in the XML source.
356
* However, this way is faster since no DTDs are looked up
357
* (possibly skipping network access) or parsed.
359
public static Schemas readNoEntityResolver(java.io.InputStream in) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException {
360
return read(new org.xml.sax.InputSource(in), false,
361
new org.xml.sax.EntityResolver() {
362
public org.xml.sax.InputSource resolveEntity(String publicId, String systemId) {
363
java.io.ByteArrayInputStream bin = new java.io.ByteArrayInputStream(new byte[0]);
364
return new org.xml.sax.InputSource(bin);
370
public static Schemas read(org.xml.sax.InputSource in, boolean validate, org.xml.sax.EntityResolver er, org.xml.sax.ErrorHandler eh) throws javax.xml.parsers.ParserConfigurationException, org.xml.sax.SAXException, java.io.IOException {
371
javax.xml.parsers.DocumentBuilderFactory dbf = javax.xml.parsers.DocumentBuilderFactory.newInstance();
372
dbf.setValidating(validate);
373
dbf.setNamespaceAware(true);
374
javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
375
if (er != null) db.setEntityResolver(er);
376
if (eh != null) db.setErrorHandler(eh);
377
org.w3c.dom.Document doc = db.parse(in);
381
public static Schemas read(org.w3c.dom.Document document) {
382
Schemas aSchemas = new Schemas();
383
aSchemas.readFromDocument(document);
387
protected void readFromDocument(org.w3c.dom.Document document) {
388
readNode(document.getDocumentElement());
391
public void readNode(org.w3c.dom.Node node) {
392
readNode(node, new java.util.HashMap());
395
public void readNode(org.w3c.dom.Node node, java.util.Map namespacePrefixes) {
396
if (node.hasAttributes()) {
397
org.w3c.dom.NamedNodeMap attrs = node.getAttributes();
398
org.w3c.dom.Attr attr;
399
java.lang.String attrValue;
400
boolean firstNamespaceDef = true;
401
for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) {
402
attr = (org.w3c.dom.Attr) attrs.item(attrNum);
403
String attrName = attr.getName();
404
if (attrName.startsWith("xmlns:")) {
405
if (firstNamespaceDef) {
406
firstNamespaceDef = false;
407
// Dup prefix map, so as to not write over previous values, and to make it easy to clear out our entries.
408
namespacePrefixes = new java.util.HashMap(namespacePrefixes);
410
String attrNSPrefix = attrName.substring(6, attrName.length());
411
namespacePrefixes.put(attrNSPrefix, attr.getValue());
414
String xsiPrefix = "xsi";
415
for (java.util.Iterator it = namespacePrefixes.keySet().iterator();
417
String prefix = (String) it.next();
418
String ns = (String) namespacePrefixes.get(prefix);
419
if ("http://www.w3.org/2001/XMLSchema-instance".equals(ns)) {
424
attr = (org.w3c.dom.Attr) attrs.getNamedItem(""+xsiPrefix+":schemaLocation");
426
attrValue = attr.getValue();
427
schemaLocation = attrValue;
429
readNodeAttributes(node, namespacePrefixes, attrs);
431
readNodeChildren(node, namespacePrefixes);
434
protected void readNodeAttributes(org.w3c.dom.Node node, java.util.Map namespacePrefixes, org.w3c.dom.NamedNodeMap attrs) {
435
org.w3c.dom.Attr attr;
436
java.lang.String attrValue;
437
attr = (org.w3c.dom.Attr) attrs.getNamedItem("destdir");
439
attrValue = attr.getValue();
440
_Destdir = attrValue;
442
attr = (org.w3c.dom.Attr) attrs.getNamedItem("projectName");
444
attrValue = attr.getValue();
445
_ProjectName = attrValue;
449
protected void readNodeChildren(org.w3c.dom.Node node, java.util.Map namespacePrefixes) {
450
org.w3c.dom.NodeList children = node.getChildNodes();
451
for (int i = 0, size = children.getLength(); i < size; ++i) {
452
org.w3c.dom.Node childNode = children.item(i);
453
String childNodeName = (childNode.getLocalName() == null ? childNode.getNodeName().intern() : childNode.getLocalName().intern());
454
String childNodeValue = "";
455
if (childNode.getFirstChild() != null) {
456
childNodeValue = childNode.getFirstChild().getNodeValue();
458
if (childNodeName == "schema") {
459
Schema aSchema = newSchema();
460
aSchema.readNode(childNode, namespacePrefixes);
461
_Schema.add(aSchema);
464
// Found extra unrecognized childNode
470
* Takes some text to be printed into an XML stream and escapes any
471
* characters that might make it invalid XML (like '<').
473
public static void writeXML(java.io.Writer out, String msg) throws java.io.IOException {
474
writeXML(out, msg, true);
477
public static void writeXML(java.io.Writer out, String msg, boolean attribute) throws java.io.IOException {
480
int msgLength = msg.length();
481
for (int i = 0; i < msgLength; ++i) {
482
char c = msg.charAt(i);
483
writeXML(out, c, attribute);
487
public static void writeXML(java.io.Writer out, char msg, boolean attribute) throws java.io.IOException {
494
else if (attribute) {
497
else if (msg == '\'')
499
else if (msg == '\n')
501
else if (msg == '\t')
510
public void changePropertyByName(String name, Object value) {
511
if (name == null) return;
512
name = name.intern();
513
if (name == "destdir")
514
setDestdir((java.lang.String)value);
515
else if (name == "projectName")
516
setProjectName((java.lang.String)value);
517
else if (name == "schema")
518
addSchema((Schema)value);
519
else if (name == "schema[]")
520
setSchema((Schema[]) value);
522
throw new IllegalArgumentException(name+" is not a valid property name for Schemas");
525
public Object fetchPropertyByName(String name) {
526
if (name == "destdir")
528
if (name == "projectName")
529
return getProjectName();
530
if (name == "schema[]")
532
throw new IllegalArgumentException(name+" is not a valid property name for Schemas");
535
public String nameSelf() {
539
public String nameChild(Object childObj) {
540
return nameChild(childObj, false, false);
544
* @param childObj The child object to search for
545
* @param returnSchemaName Whether or not the schema name should be returned or the property name
546
* @return null if not found
548
public String nameChild(Object childObj, boolean returnConstName, boolean returnSchemaName) {
549
return nameChild(childObj, returnConstName, returnSchemaName, false);
553
* @param childObj The child object to search for
554
* @param returnSchemaName Whether or not the schema name should be returned or the property name
555
* @return null if not found
557
public String nameChild(Object childObj, boolean returnConstName, boolean returnSchemaName, boolean returnXPathName) {
558
if (childObj instanceof Schema) {
559
Schema child = (Schema) childObj;
561
for (java.util.Iterator it = _Schema.iterator(); it.hasNext();
563
org.netbeans.modules.xml.jaxb.cfg.schema.Schema element = (org.netbeans.modules.xml.jaxb.cfg.schema.Schema)it.next();
564
if (child == element) {
565
if (returnConstName) {
567
} else if (returnSchemaName) {
569
} else if (returnXPathName) {
570
return "schema[position()="+index+"]";
572
return "Schema."+Integer.toHexString(index);
578
if (childObj instanceof java.lang.String) {
579
java.lang.String child = (java.lang.String) childObj;
580
if (child == _Destdir) {
581
if (returnConstName) {
583
} else if (returnSchemaName) {
585
} else if (returnXPathName) {
591
if (child == _ProjectName) {
592
if (returnConstName) {
594
} else if (returnSchemaName) {
595
return "projectName";
596
} else if (returnXPathName) {
597
return "@projectName";
599
return "ProjectName";
607
* Return an array of all of the properties that are beans and are set.
609
public java.lang.Object[] childBeans(boolean recursive) {
610
java.util.List children = new java.util.LinkedList();
611
childBeans(recursive, children);
612
java.lang.Object[] result = new java.lang.Object[children.size()];
613
return (java.lang.Object[]) children.toArray(result);
617
* Put all child beans into the beans list.
619
public void childBeans(boolean recursive, java.util.List beans) {
620
for (java.util.Iterator it = _Schema.iterator(); it.hasNext(); ) {
621
org.netbeans.modules.xml.jaxb.cfg.schema.Schema element = (org.netbeans.modules.xml.jaxb.cfg.schema.Schema)it.next();
622
if (element != null) {
624
element.childBeans(true, beans);
631
public boolean equals(Object o) {
632
return o instanceof org.netbeans.modules.xml.jaxb.cfg.schema.Schemas && equals((org.netbeans.modules.xml.jaxb.cfg.schema.Schemas) o);
635
public boolean equals(org.netbeans.modules.xml.jaxb.cfg.schema.Schemas inst) {
642
if (!(_Destdir == null ? inst._Destdir == null : _Destdir.equals(inst._Destdir))) {
645
if (!(_ProjectName == null ? inst._ProjectName == null : _ProjectName.equals(inst._ProjectName))) {
648
if (sizeSchema() != inst.sizeSchema())
650
// Compare every element.
651
for (java.util.Iterator it = _Schema.iterator(), it2 = inst._Schema.iterator();
652
it.hasNext() && it2.hasNext(); ) {
653
org.netbeans.modules.xml.jaxb.cfg.schema.Schema element = (org.netbeans.modules.xml.jaxb.cfg.schema.Schema)it.next();
654
org.netbeans.modules.xml.jaxb.cfg.schema.Schema element2 = (org.netbeans.modules.xml.jaxb.cfg.schema.Schema)it2.next();
655
if (!(element == null ? element2 == null : element.equals(element2))) {
662
public int hashCode() {
664
result = 37*result + (_Destdir == null ? 0 : _Destdir.hashCode());
665
result = 37*result + (_ProjectName == null ? 0 : _ProjectName.hashCode());
666
result = 37*result + (_Schema == null ? 0 : _Schema.hashCode());
674
The following schema file has been used for generation:
676
<?xml version="1.0" encoding="UTF-8"?>
677
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
678
targetNamespace="http://xml.netbeans.org/schema/JAXBWizConfig"
679
xmlns:tns="http://xml.netbeans.org/schema/JAXBWizConfig"
680
elementFormDefault="qualified">
682
<xsd:element name="schemas">
685
<xsd:element ref="tns:schema" maxOccurs="unbounded" minOccurs="0"/>
687
<xsd:attribute name="destdir" type="xsd:string"/>
688
<xsd:attribute name="projectName" type="xsd:string"/>
692
<xsd:element name="schema">
693
<xsd:complexType xmlns:xsd="http://www.w3.org/2001/XMLSchema">
695
<xsd:element ref="tns:xjc-options" minOccurs="0"/>
696
<xsd:element ref="tns:schema-sources" minOccurs="0"/>
697
<xsd:element ref="tns:bindings" minOccurs="0"/>
698
<xsd:element ref="tns:catalog" minOccurs="0"/>
700
<xsd:attribute name="type" type="xsd:string"/>
701
<xsd:attribute name="package" type="xsd:string"/>
702
<xsd:attribute name="name" type="xsd:string" use="required"/>
706
<xsd:element name="xjc-options">
709
<xsd:element ref="tns:xjc-option" maxOccurs="unbounded" minOccurs="0"/>
714
<xsd:element name="xjc-option">
717
<xsd:attribute name="name" type="xsd:string"/>
718
<xsd:attribute name="value" type="xsd:string"/>
722
<xsd:element name="schema-sources">
725
<xsd:element ref="tns:schema-source" maxOccurs="unbounded" minOccurs="0"/>
730
<xsd:element name="schema-source">
733
<xsd:attribute name="location" type="xsd:string">
735
<xsd:documentation>location is relative to Project Root. origLocation is either local file path or URL</xsd:documentation>
738
<xsd:attribute name="origLocation" type="xsd:string"/>
739
<xsd:attribute name="origLocationType" type="xsd:string"/>
743
<xsd:element name="bindings">
746
<xsd:element ref="tns:binding" maxOccurs="unbounded" minOccurs="0"/>
751
<xsd:element name="binding">
754
<xsd:attribute name="origLocation" type="xsd:string"/>
755
<xsd:attribute name="location" type="xsd:string"/>
759
<xsd:element name="catalog">
762
<xsd:attribute name="location" type="xsd:string"/>
763
<xsd:attribute name="origLocation" type="xsd:string"/>