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 ExtensionElementType
044: * matches the schema element 'extensionElementType'.
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 ExtensionElementType {
052: public static final String NAME = "Name"; // NOI18N
053: public static final String EXTENSIONATTR = "ExtensionAttr"; // NOI18N
054:
055: private java.lang.String _Name;
056: private java.util.List _ExtensionAttr = new java.util.ArrayList(); // List<ExtensionAttrType>
057:
058: /**
059: * Normal starting point constructor.
060: */
061: public ExtensionElementType() {
062: }
063:
064: /**
065: * Required parameters constructor
066: */
067: public ExtensionElementType(
068: org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType[] extensionAttr) {
069: if (extensionAttr != null) {
070: ((java.util.ArrayList) _ExtensionAttr)
071: .ensureCapacity(extensionAttr.length);
072: for (int i = 0; i < extensionAttr.length; ++i) {
073: _ExtensionAttr.add(extensionAttr[i]);
074: }
075: }
076: }
077:
078: /**
079: * Deep copy
080: */
081: public ExtensionElementType(
082: org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionElementType source) {
083: this (source, false);
084: }
085:
086: /**
087: * Deep copy
088: * @param justData just copy the XML relevant data
089: */
090: public ExtensionElementType(
091: org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionElementType source,
092: boolean justData) {
093: _Name = source._Name;
094: for (java.util.Iterator it = source._ExtensionAttr.iterator(); it
095: .hasNext();) {
096: org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType srcElement = (org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType) it
097: .next();
098: _ExtensionAttr.add((srcElement == null) ? null
099: : newExtensionAttrType(srcElement, justData));
100: }
101: }
102:
103: // This attribute is optional
104: public void setName(java.lang.String value) {
105: _Name = value;
106: }
107:
108: public java.lang.String getName() {
109: return _Name;
110: }
111:
112: // This attribute is an array containing at least one element
113: public void setExtensionAttr(
114: org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType[] value) {
115: if (value == null)
116: value = new ExtensionAttrType[0];
117: _ExtensionAttr.clear();
118: ((java.util.ArrayList) _ExtensionAttr)
119: .ensureCapacity(value.length);
120: for (int i = 0; i < value.length; ++i) {
121: _ExtensionAttr.add(value[i]);
122: }
123: }
124:
125: public void setExtensionAttr(
126: int index,
127: org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType value) {
128: _ExtensionAttr.set(index, value);
129: }
130:
131: public org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType[] getExtensionAttr() {
132: ExtensionAttrType[] arr = new ExtensionAttrType[_ExtensionAttr
133: .size()];
134: return (ExtensionAttrType[]) _ExtensionAttr.toArray(arr);
135: }
136:
137: public java.util.List fetchExtensionAttrList() {
138: return _ExtensionAttr;
139: }
140:
141: public org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType getExtensionAttr(
142: int index) {
143: return (ExtensionAttrType) _ExtensionAttr.get(index);
144: }
145:
146: // Return the number of extensionAttr
147: public int sizeExtensionAttr() {
148: return _ExtensionAttr.size();
149: }
150:
151: public int addExtensionAttr(
152: org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType value) {
153: _ExtensionAttr.add(value);
154: int positionOfNewItem = _ExtensionAttr.size() - 1;
155: return positionOfNewItem;
156: }
157:
158: /**
159: * Search from the end looking for @param value, and then remove it.
160: */
161: public int removeExtensionAttr(
162: org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType value) {
163: int pos = _ExtensionAttr.indexOf(value);
164: if (pos >= 0) {
165: _ExtensionAttr.remove(pos);
166: }
167: return pos;
168: }
169:
170: /**
171: * Create a new bean using it's default constructor.
172: * This does not add it to any bean graph.
173: */
174: public org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType newExtensionAttrType() {
175: return new org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType();
176: }
177:
178: /**
179: * Create a new bean, copying from another one.
180: * This does not add it to any bean graph.
181: */
182: public org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType newExtensionAttrType(
183: ExtensionAttrType source, boolean justData) {
184: return new org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType(
185: source, justData);
186: }
187:
188: public void writeNode(java.io.Writer out)
189: throws java.io.IOException {
190: String myName;
191: myName = "extensionElementType";
192: writeNode(out, myName, ""); // NOI18N
193: }
194:
195: public void writeNode(java.io.Writer out, String nodeName,
196: String indent) throws java.io.IOException {
197: writeNode(out, nodeName, null, indent, new java.util.HashMap());
198: }
199:
200: /**
201: * It's not recommended to call this method directly.
202: */
203: public void writeNode(java.io.Writer out, String nodeName,
204: String namespace, String indent, java.util.Map namespaceMap)
205: throws java.io.IOException {
206: out.write(indent);
207: out.write("<");
208: if (namespace != null) {
209: out.write((String) namespaceMap.get(namespace));
210: out.write(":");
211: }
212: out.write(nodeName);
213: writeNodeAttributes(out, nodeName, namespace, indent,
214: namespaceMap);
215: out.write(">\n");
216: writeNodeChildren(out, nodeName, namespace, indent,
217: namespaceMap);
218: out.write(indent);
219: out.write("</");
220: if (namespace != null) {
221: out.write((String) namespaceMap.get(namespace));
222: out.write(":");
223: }
224: out.write(nodeName);
225: out.write(">\n");
226: }
227:
228: protected void writeNodeAttributes(java.io.Writer out,
229: String nodeName, String namespace, String indent,
230: java.util.Map namespaceMap) throws java.io.IOException {
231: // name is an attribute with namespace http://xml.netbeans.org/schema/templates
232: if (_Name != null) {
233: out.write(" name='");
234: org.netbeans.modules.xml.wsdl.bindingsupport.template.TemplateGroup
235: .writeXML(out, _Name, true);
236: out.write("'"); // NOI18N
237: }
238: }
239:
240: protected void writeNodeChildren(java.io.Writer out,
241: String nodeName, String namespace, String indent,
242: java.util.Map namespaceMap) throws java.io.IOException {
243: String nextIndent = indent + " ";
244: for (java.util.Iterator it = _ExtensionAttr.iterator(); it
245: .hasNext();) {
246: org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType element = (org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType) it
247: .next();
248: if (element != null) {
249: element.writeNode(out, "extensionAttr", null,
250: nextIndent, namespaceMap);
251: }
252: }
253: }
254:
255: public void readNode(org.w3c.dom.Node node) {
256: readNode(node, new java.util.HashMap());
257: }
258:
259: public void readNode(org.w3c.dom.Node node,
260: java.util.Map namespacePrefixes) {
261: if (node.hasAttributes()) {
262: org.w3c.dom.NamedNodeMap attrs = node.getAttributes();
263: org.w3c.dom.Attr attr;
264: java.lang.String attrValue;
265: boolean firstNamespaceDef = true;
266: for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) {
267: attr = (org.w3c.dom.Attr) attrs.item(attrNum);
268: String attrName = attr.getName();
269: if (attrName.startsWith("xmlns:")) {
270: if (firstNamespaceDef) {
271: firstNamespaceDef = false;
272: // Dup prefix map, so as to not write over previous values, and to make it easy to clear out our entries.
273: namespacePrefixes = new java.util.HashMap(
274: namespacePrefixes);
275: }
276: String attrNSPrefix = attrName.substring(6,
277: attrName.length());
278: namespacePrefixes
279: .put(attrNSPrefix, attr.getValue());
280: }
281: }
282: readNodeAttributes(node, namespacePrefixes, attrs);
283: }
284: readNodeChildren(node, namespacePrefixes);
285: }
286:
287: protected void readNodeAttributes(org.w3c.dom.Node node,
288: java.util.Map namespacePrefixes,
289: org.w3c.dom.NamedNodeMap attrs) {
290: org.w3c.dom.Attr attr;
291: java.lang.String attrValue;
292: attr = (org.w3c.dom.Attr) attrs.getNamedItem("name");
293: if (attr != null) {
294: attrValue = attr.getValue();
295: _Name = attrValue;
296: }
297: }
298:
299: protected void readNodeChildren(org.w3c.dom.Node node,
300: java.util.Map namespacePrefixes) {
301: org.w3c.dom.NodeList children = node.getChildNodes();
302: for (int i = 0, size = children.getLength(); i < size; ++i) {
303: org.w3c.dom.Node childNode = children.item(i);
304: String childNodeName = (childNode.getLocalName() == null ? childNode
305: .getNodeName().intern()
306: : childNode.getLocalName().intern());
307: String childNodeValue = "";
308: if (childNode.getFirstChild() != null) {
309: childNodeValue = childNode.getFirstChild()
310: .getNodeValue();
311: }
312: if (childNodeName == "extensionAttr") {
313: ExtensionAttrType aExtensionAttr = newExtensionAttrType();
314: aExtensionAttr.readNode(childNode, namespacePrefixes);
315: _ExtensionAttr.add(aExtensionAttr);
316: } else {
317: // Found extra unrecognized childNode
318: }
319: }
320: }
321:
322: public void changePropertyByName(String name, Object value) {
323: if (name == null)
324: return;
325: name = name.intern();
326: if (name == "name")
327: setName((java.lang.String) value);
328: else if (name == "extensionAttr")
329: addExtensionAttr((ExtensionAttrType) value);
330: else if (name == "extensionAttr[]")
331: setExtensionAttr((ExtensionAttrType[]) value);
332: else
333: throw new IllegalArgumentException(
334: name
335: + " is not a valid property name for ExtensionElementType");
336: }
337:
338: public Object fetchPropertyByName(String name) {
339: if (name == "name")
340: return getName();
341: if (name == "extensionAttr[]")
342: return getExtensionAttr();
343: throw new IllegalArgumentException(
344: name
345: + " is not a valid property name for ExtensionElementType");
346: }
347:
348: public String nameSelf() {
349: return "ExtensionElementType";
350: }
351:
352: public String nameChild(Object childObj) {
353: return nameChild(childObj, false, false);
354: }
355:
356: /**
357: * @param childObj The child object to search for
358: * @param returnSchemaName Whether or not the schema name should be returned or the property name
359: * @return null if not found
360: */
361: public String nameChild(Object childObj, boolean returnConstName,
362: boolean returnSchemaName) {
363: return nameChild(childObj, returnConstName, returnSchemaName,
364: false);
365: }
366:
367: /**
368: * @param childObj The child object to search for
369: * @param returnSchemaName Whether or not the schema name should be returned or the property name
370: * @return null if not found
371: */
372: public String nameChild(Object childObj, boolean returnConstName,
373: boolean returnSchemaName, boolean returnXPathName) {
374: if (childObj instanceof java.lang.String) {
375: java.lang.String child = (java.lang.String) childObj;
376: if (child == _Name) {
377: if (returnConstName) {
378: return NAME;
379: } else if (returnSchemaName) {
380: return "name";
381: } else if (returnXPathName) {
382: return "@name";
383: } else {
384: return "Name";
385: }
386: }
387: }
388: if (childObj instanceof ExtensionAttrType) {
389: ExtensionAttrType child = (ExtensionAttrType) childObj;
390: int index = 0;
391: for (java.util.Iterator it = _ExtensionAttr.iterator(); it
392: .hasNext();) {
393: org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType element = (org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType) it
394: .next();
395: if (child == element) {
396: if (returnConstName) {
397: return EXTENSIONATTR;
398: } else if (returnSchemaName) {
399: return "extensionAttr";
400: } else if (returnXPathName) {
401: return "extensionAttr[position()=" + index
402: + "]";
403: } else {
404: return "ExtensionAttr."
405: + Integer.toHexString(index);
406: }
407: }
408: ++index;
409: }
410: }
411: return null;
412: }
413:
414: /**
415: * Return an array of all of the properties that are beans and are set.
416: */
417: public java.lang.Object[] childBeans(boolean recursive) {
418: java.util.List children = new java.util.LinkedList();
419: childBeans(recursive, children);
420: java.lang.Object[] result = new java.lang.Object[children
421: .size()];
422: return (java.lang.Object[]) children.toArray(result);
423: }
424:
425: /**
426: * Put all child beans into the beans list.
427: */
428: public void childBeans(boolean recursive, java.util.List beans) {
429: for (java.util.Iterator it = _ExtensionAttr.iterator(); it
430: .hasNext();) {
431: org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType element = (org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType) it
432: .next();
433: if (element != null) {
434: if (recursive) {
435: element.childBeans(true, beans);
436: }
437: beans.add(element);
438: }
439: }
440: }
441:
442: public boolean equals(Object o) {
443: return o instanceof org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionElementType
444: && equals((org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionElementType) o);
445: }
446:
447: public boolean equals(
448: org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionElementType inst) {
449: if (inst == this ) {
450: return true;
451: }
452: if (inst == null) {
453: return false;
454: }
455: if (!(_Name == null ? inst._Name == null : _Name
456: .equals(inst._Name))) {
457: return false;
458: }
459: if (sizeExtensionAttr() != inst.sizeExtensionAttr())
460: return false;
461: // Compare every element.
462: for (java.util.Iterator it = _ExtensionAttr.iterator(), it2 = inst._ExtensionAttr
463: .iterator(); it.hasNext() && it2.hasNext();) {
464: org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType element = (org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType) it
465: .next();
466: org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType element2 = (org.netbeans.modules.xml.wsdl.bindingsupport.template.ExtensionAttrType) it2
467: .next();
468: if (!(element == null ? element2 == null : element
469: .equals(element2))) {
470: return false;
471: }
472: }
473: return true;
474: }
475:
476: public int hashCode() {
477: int result = 17;
478: result = 37 * result + (_Name == null ? 0 : _Name.hashCode());
479: result = 37
480: * result
481: + (_ExtensionAttr == null ? 0 : _ExtensionAttr
482: .hashCode());
483: return result;
484: }
485:
486: }
487:
488: /*
489: The following schema file has been used for generation:
490:
491: <?xml version="1.0" encoding="UTF-8"?>
492:
493: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
494: targetNamespace="http://xml.netbeans.org/schema/templates"
495: xmlns:tns="http://xml.netbeans.org/schema/templates"
496: elementFormDefault="qualified">
497: <xsd:element name="templateGroup">
498: <xsd:complexType>
499: <xsd:sequence>
500: <xsd:element name="template" type="tns:templateType" maxOccurs="unbounded"/>
501: </xsd:sequence>
502: <xsd:attribute name="namespace" type="xsd:string"/>
503: <xsd:attribute name="prefix" type="xsd:string"/>
504: </xsd:complexType>
505: </xsd:element>
506: <xsd:complexType name="templateType">
507: <xsd:sequence>
508: <xsd:element name="wsdlElement" type="tns:wsdlElementType" maxOccurs="unbounded"/>
509: </xsd:sequence>
510: <xsd:attribute name="name" type="xsd:string"/>
511: <xsd:attribute name="default" type="xsd:boolean"/>
512: </xsd:complexType>
513: <xsd:complexType name="wsdlElementType">
514: <xsd:sequence>
515: <xsd:element name="extensionElement" type="tns:extensionElementType" maxOccurs="unbounded"/>
516: </xsd:sequence>
517: <xsd:attribute name="name" type="xsd:string"/>
518: </xsd:complexType>
519: <xsd:complexType name="extensionElementType">
520: <xsd:sequence>
521: <xsd:element name="extensionAttr" type="tns:extensionAttrType" maxOccurs="unbounded"/>
522: </xsd:sequence>
523: <xsd:attribute name="name" type="xsd:string"/>
524: </xsd:complexType>
525: <xsd:complexType name="extensionAttrType">
526: <xsd:attribute name="name" type="xsd:string"/>
527: <xsd:attribute name="defaultValue" type="xsd:string"/>
528: </xsd:complexType>
529: </xsd:schema>
530:
531:
532: */
|