001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /**
043: * This generated bean class TemplateType
044: * matches the schema element 'templateType'.
045: * The root bean class is TemplateGroup
046: *
047: * Generated on Thu Sep 14 11:59:06 PDT 2006
048: * @Generated
049: */package org.netbeans.modules.xml.wsdl.bindingsupport.template;
050:
051: public class TemplateType {
052: public static final String NAME = "Name"; // NOI18N
053: public static final String DEFAULT = "Default"; // NOI18N
054: public static final String WSDLELEMENT = "WsdlElement"; // NOI18N
055:
056: private java.lang.String _Name;
057: private boolean _Default;
058: private java.util.List _WsdlElement = new java.util.ArrayList(); // List<WsdlElementType>
059:
060: /**
061: * Normal starting point constructor.
062: */
063: public TemplateType() {
064: }
065:
066: /**
067: * Required parameters constructor
068: */
069: public TemplateType(
070: org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType[] wsdlElement) {
071: if (wsdlElement != null) {
072: ((java.util.ArrayList) _WsdlElement)
073: .ensureCapacity(wsdlElement.length);
074: for (int i = 0; i < wsdlElement.length; ++i) {
075: _WsdlElement.add(wsdlElement[i]);
076: }
077: }
078: }
079:
080: /**
081: * Deep copy
082: */
083: public TemplateType(
084: org.netbeans.modules.xml.wsdl.bindingsupport.template.TemplateType source) {
085: this (source, false);
086: }
087:
088: /**
089: * Deep copy
090: * @param justData just copy the XML relevant data
091: */
092: public TemplateType(
093: org.netbeans.modules.xml.wsdl.bindingsupport.template.TemplateType source,
094: boolean justData) {
095: _Name = source._Name;
096: _Default = source._Default;
097: for (java.util.Iterator it = source._WsdlElement.iterator(); it
098: .hasNext();) {
099: org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType srcElement = (org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType) it
100: .next();
101: _WsdlElement.add((srcElement == null) ? null
102: : newWsdlElementType(srcElement, justData));
103: }
104: }
105:
106: // This attribute is optional
107: public void setName(java.lang.String value) {
108: _Name = value;
109: }
110:
111: public java.lang.String getName() {
112: return _Name;
113: }
114:
115: // This attribute is optional
116: public void setDefault(boolean value) {
117: _Default = value;
118: }
119:
120: public boolean isDefault() {
121: return _Default;
122: }
123:
124: // This attribute is an array containing at least one element
125: public void setWsdlElement(
126: org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType[] value) {
127: if (value == null)
128: value = new WsdlElementType[0];
129: _WsdlElement.clear();
130: ((java.util.ArrayList) _WsdlElement)
131: .ensureCapacity(value.length);
132: for (int i = 0; i < value.length; ++i) {
133: _WsdlElement.add(value[i]);
134: }
135: }
136:
137: public void setWsdlElement(
138: int index,
139: org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType value) {
140: _WsdlElement.set(index, value);
141: }
142:
143: public org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType[] getWsdlElement() {
144: WsdlElementType[] arr = new WsdlElementType[_WsdlElement.size()];
145: return (WsdlElementType[]) _WsdlElement.toArray(arr);
146: }
147:
148: public java.util.List fetchWsdlElementList() {
149: return _WsdlElement;
150: }
151:
152: public org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType getWsdlElement(
153: int index) {
154: return (WsdlElementType) _WsdlElement.get(index);
155: }
156:
157: // Return the number of wsdlElement
158: public int sizeWsdlElement() {
159: return _WsdlElement.size();
160: }
161:
162: public int addWsdlElement(
163: org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType value) {
164: _WsdlElement.add(value);
165: int positionOfNewItem = _WsdlElement.size() - 1;
166: return positionOfNewItem;
167: }
168:
169: /**
170: * Search from the end looking for @param value, and then remove it.
171: */
172: public int removeWsdlElement(
173: org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType value) {
174: int pos = _WsdlElement.indexOf(value);
175: if (pos >= 0) {
176: _WsdlElement.remove(pos);
177: }
178: return pos;
179: }
180:
181: /**
182: * Create a new bean using it's default constructor.
183: * This does not add it to any bean graph.
184: */
185: public org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType newWsdlElementType() {
186: return new org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType();
187: }
188:
189: /**
190: * Create a new bean, copying from another one.
191: * This does not add it to any bean graph.
192: */
193: public org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType newWsdlElementType(
194: WsdlElementType source, boolean justData) {
195: return new org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType(
196: source, justData);
197: }
198:
199: public void writeNode(java.io.Writer out)
200: throws java.io.IOException {
201: String myName;
202: myName = "templateType";
203: writeNode(out, myName, ""); // NOI18N
204: }
205:
206: public void writeNode(java.io.Writer out, String nodeName,
207: String indent) throws java.io.IOException {
208: writeNode(out, nodeName, null, indent, new java.util.HashMap());
209: }
210:
211: /**
212: * It's not recommended to call this method directly.
213: */
214: public void writeNode(java.io.Writer out, String nodeName,
215: String namespace, String indent, java.util.Map namespaceMap)
216: throws java.io.IOException {
217: out.write(indent);
218: out.write("<");
219: if (namespace != null) {
220: out.write((String) namespaceMap.get(namespace));
221: out.write(":");
222: }
223: out.write(nodeName);
224: writeNodeAttributes(out, nodeName, namespace, indent,
225: namespaceMap);
226: out.write(">\n");
227: writeNodeChildren(out, nodeName, namespace, indent,
228: namespaceMap);
229: out.write(indent);
230: out.write("</");
231: if (namespace != null) {
232: out.write((String) namespaceMap.get(namespace));
233: out.write(":");
234: }
235: out.write(nodeName);
236: out.write(">\n");
237: }
238:
239: protected void writeNodeAttributes(java.io.Writer out,
240: String nodeName, String namespace, String indent,
241: java.util.Map namespaceMap) throws java.io.IOException {
242: // name is an attribute with namespace http://xml.netbeans.org/schema/templates
243: if (_Name != null) {
244: out.write(" name='");
245: org.netbeans.modules.xml.wsdl.bindingsupport.template.TemplateGroup
246: .writeXML(out, _Name, true);
247: out.write("'"); // NOI18N
248: }
249: // default is an attribute with namespace http://xml.netbeans.org/schema/templates
250: out.write(" default='");
251: out.write(_Default ? "true" : "false");
252: out.write("'"); // NOI18N
253: }
254:
255: protected void writeNodeChildren(java.io.Writer out,
256: String nodeName, String namespace, String indent,
257: java.util.Map namespaceMap) throws java.io.IOException {
258: String nextIndent = indent + " ";
259: for (java.util.Iterator it = _WsdlElement.iterator(); it
260: .hasNext();) {
261: org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType element = (org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType) it
262: .next();
263: if (element != null) {
264: element.writeNode(out, "wsdlElement", null, nextIndent,
265: namespaceMap);
266: }
267: }
268: }
269:
270: public void readNode(org.w3c.dom.Node node) {
271: readNode(node, new java.util.HashMap());
272: }
273:
274: public void readNode(org.w3c.dom.Node node,
275: java.util.Map namespacePrefixes) {
276: if (node.hasAttributes()) {
277: org.w3c.dom.NamedNodeMap attrs = node.getAttributes();
278: org.w3c.dom.Attr attr;
279: java.lang.String attrValue;
280: boolean firstNamespaceDef = true;
281: for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) {
282: attr = (org.w3c.dom.Attr) attrs.item(attrNum);
283: String attrName = attr.getName();
284: if (attrName.startsWith("xmlns:")) {
285: if (firstNamespaceDef) {
286: firstNamespaceDef = false;
287: // Dup prefix map, so as to not write over previous values, and to make it easy to clear out our entries.
288: namespacePrefixes = new java.util.HashMap(
289: namespacePrefixes);
290: }
291: String attrNSPrefix = attrName.substring(6,
292: attrName.length());
293: namespacePrefixes
294: .put(attrNSPrefix, attr.getValue());
295: }
296: }
297: readNodeAttributes(node, namespacePrefixes, attrs);
298: }
299: readNodeChildren(node, namespacePrefixes);
300: }
301:
302: protected void readNodeAttributes(org.w3c.dom.Node node,
303: java.util.Map namespacePrefixes,
304: org.w3c.dom.NamedNodeMap attrs) {
305: org.w3c.dom.Attr attr;
306: java.lang.String attrValue;
307: attr = (org.w3c.dom.Attr) attrs.getNamedItem("name");
308: if (attr != null) {
309: attrValue = attr.getValue();
310: _Name = attrValue;
311: }
312: attr = (org.w3c.dom.Attr) attrs.getNamedItem("default");
313: if (attr != null) {
314: attrValue = attr.getValue();
315: _Default = java.lang.Boolean.valueOf(attrValue)
316: .booleanValue();
317: }
318: }
319:
320: protected void readNodeChildren(org.w3c.dom.Node node,
321: java.util.Map namespacePrefixes) {
322: org.w3c.dom.NodeList children = node.getChildNodes();
323: for (int i = 0, size = children.getLength(); i < size; ++i) {
324: org.w3c.dom.Node childNode = children.item(i);
325: String childNodeName = (childNode.getLocalName() == null ? childNode
326: .getNodeName().intern()
327: : childNode.getLocalName().intern());
328: String childNodeValue = "";
329: if (childNode.getFirstChild() != null) {
330: childNodeValue = childNode.getFirstChild()
331: .getNodeValue();
332: }
333: if (childNodeName == "wsdlElement") {
334: WsdlElementType aWsdlElement = newWsdlElementType();
335: aWsdlElement.readNode(childNode, namespacePrefixes);
336: _WsdlElement.add(aWsdlElement);
337: } else {
338: // Found extra unrecognized childNode
339: }
340: }
341: }
342:
343: public void changePropertyByName(String name, Object value) {
344: if (name == null)
345: return;
346: name = name.intern();
347: if (name == "name")
348: setName((java.lang.String) value);
349: else if (name == "default")
350: setDefault(((java.lang.Boolean) value).booleanValue());
351: else if (name == "wsdlElement")
352: addWsdlElement((WsdlElementType) value);
353: else if (name == "wsdlElement[]")
354: setWsdlElement((WsdlElementType[]) value);
355: else
356: throw new IllegalArgumentException(name
357: + " is not a valid property name for TemplateType");
358: }
359:
360: public Object fetchPropertyByName(String name) {
361: if (name == "name")
362: return getName();
363: if (name == "default")
364: return (isDefault() ? java.lang.Boolean.TRUE
365: : java.lang.Boolean.FALSE);
366: if (name == "wsdlElement[]")
367: return getWsdlElement();
368: throw new IllegalArgumentException(name
369: + " is not a valid property name for TemplateType");
370: }
371:
372: public String nameSelf() {
373: return "TemplateType";
374: }
375:
376: public String nameChild(Object childObj) {
377: return nameChild(childObj, false, false);
378: }
379:
380: /**
381: * @param childObj The child object to search for
382: * @param returnSchemaName Whether or not the schema name should be returned or the property name
383: * @return null if not found
384: */
385: public String nameChild(Object childObj, boolean returnConstName,
386: boolean returnSchemaName) {
387: return nameChild(childObj, returnConstName, returnSchemaName,
388: false);
389: }
390:
391: /**
392: * @param childObj The child object to search for
393: * @param returnSchemaName Whether or not the schema name should be returned or the property name
394: * @return null if not found
395: */
396: public String nameChild(Object childObj, boolean returnConstName,
397: boolean returnSchemaName, boolean returnXPathName) {
398: if (childObj instanceof java.lang.String) {
399: java.lang.String child = (java.lang.String) childObj;
400: if (child == _Name) {
401: if (returnConstName) {
402: return NAME;
403: } else if (returnSchemaName) {
404: return "name";
405: } else if (returnXPathName) {
406: return "@name";
407: } else {
408: return "Name";
409: }
410: }
411: }
412: if (childObj instanceof WsdlElementType) {
413: WsdlElementType child = (WsdlElementType) childObj;
414: int index = 0;
415: for (java.util.Iterator it = _WsdlElement.iterator(); it
416: .hasNext();) {
417: org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType element = (org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType) it
418: .next();
419: if (child == element) {
420: if (returnConstName) {
421: return WSDLELEMENT;
422: } else if (returnSchemaName) {
423: return "wsdlElement";
424: } else if (returnXPathName) {
425: return "wsdlElement[position()=" + index + "]";
426: } else {
427: return "WsdlElement."
428: + Integer.toHexString(index);
429: }
430: }
431: ++index;
432: }
433: }
434: if (childObj instanceof java.lang.Boolean) {
435: java.lang.Boolean child = (java.lang.Boolean) childObj;
436: if (((java.lang.Boolean) child).booleanValue() == _Default) {
437: if (returnConstName) {
438: return DEFAULT;
439: } else if (returnSchemaName) {
440: return "default";
441: } else if (returnXPathName) {
442: return "@default";
443: } else {
444: return "Default";
445: }
446: }
447: }
448: return null;
449: }
450:
451: /**
452: * Return an array of all of the properties that are beans and are set.
453: */
454: public java.lang.Object[] childBeans(boolean recursive) {
455: java.util.List children = new java.util.LinkedList();
456: childBeans(recursive, children);
457: java.lang.Object[] result = new java.lang.Object[children
458: .size()];
459: return (java.lang.Object[]) children.toArray(result);
460: }
461:
462: /**
463: * Put all child beans into the beans list.
464: */
465: public void childBeans(boolean recursive, java.util.List beans) {
466: for (java.util.Iterator it = _WsdlElement.iterator(); it
467: .hasNext();) {
468: org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType element = (org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType) it
469: .next();
470: if (element != null) {
471: if (recursive) {
472: element.childBeans(true, beans);
473: }
474: beans.add(element);
475: }
476: }
477: }
478:
479: public boolean equals(Object o) {
480: return o instanceof org.netbeans.modules.xml.wsdl.bindingsupport.template.TemplateType
481: && equals((org.netbeans.modules.xml.wsdl.bindingsupport.template.TemplateType) o);
482: }
483:
484: public boolean equals(
485: org.netbeans.modules.xml.wsdl.bindingsupport.template.TemplateType inst) {
486: if (inst == this ) {
487: return true;
488: }
489: if (inst == null) {
490: return false;
491: }
492: if (!(_Name == null ? inst._Name == null : _Name
493: .equals(inst._Name))) {
494: return false;
495: }
496: if (!(_Default == inst._Default)) {
497: return false;
498: }
499: if (sizeWsdlElement() != inst.sizeWsdlElement())
500: return false;
501: // Compare every element.
502: for (java.util.Iterator it = _WsdlElement.iterator(), it2 = inst._WsdlElement
503: .iterator(); it.hasNext() && it2.hasNext();) {
504: org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType element = (org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType) it
505: .next();
506: org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType element2 = (org.netbeans.modules.xml.wsdl.bindingsupport.template.WsdlElementType) it2
507: .next();
508: if (!(element == null ? element2 == null : element
509: .equals(element2))) {
510: return false;
511: }
512: }
513: return true;
514: }
515:
516: public int hashCode() {
517: int result = 17;
518: result = 37 * result + (_Name == null ? 0 : _Name.hashCode());
519: result = 37 * result + (_Default ? 0 : 1);
520: result = 37 * result
521: + (_WsdlElement == null ? 0 : _WsdlElement.hashCode());
522: return result;
523: }
524:
525: }
526:
527: /*
528: The following schema file has been used for generation:
529:
530: <?xml version="1.0" encoding="UTF-8"?>
531:
532: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
533: targetNamespace="http://xml.netbeans.org/schema/templates"
534: xmlns:tns="http://xml.netbeans.org/schema/templates"
535: elementFormDefault="qualified">
536: <xsd:element name="templateGroup">
537: <xsd:complexType>
538: <xsd:sequence>
539: <xsd:element name="template" type="tns:templateType" maxOccurs="unbounded"/>
540: </xsd:sequence>
541: <xsd:attribute name="namespace" type="xsd:string"/>
542: <xsd:attribute name="prefix" type="xsd:string"/>
543: </xsd:complexType>
544: </xsd:element>
545: <xsd:complexType name="templateType">
546: <xsd:sequence>
547: <xsd:element name="wsdlElement" type="tns:wsdlElementType" maxOccurs="unbounded"/>
548: </xsd:sequence>
549: <xsd:attribute name="name" type="xsd:string"/>
550: <xsd:attribute name="default" type="xsd:boolean"/>
551: </xsd:complexType>
552: <xsd:complexType name="wsdlElementType">
553: <xsd:sequence>
554: <xsd:element name="extensionElement" type="tns:extensionElementType" maxOccurs="unbounded"/>
555: </xsd:sequence>
556: <xsd:attribute name="name" type="xsd:string"/>
557: </xsd:complexType>
558: <xsd:complexType name="extensionElementType">
559: <xsd:sequence>
560: <xsd:element name="extensionAttr" type="tns:extensionAttrType" maxOccurs="unbounded"/>
561: </xsd:sequence>
562: <xsd:attribute name="name" type="xsd:string"/>
563: </xsd:complexType>
564: <xsd:complexType name="extensionAttrType">
565: <xsd:attribute name="name" type="xsd:string"/>
566: <xsd:attribute name="defaultValue" type="xsd:string"/>
567: </xsd:complexType>
568: </xsd:schema>
569:
570:
571: */
|