KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > wsdl > ui > view > wizard > ExtensionElementType


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /**
21  * This generated bean class ExtensionElementType
22  * matches the schema element 'extensionElementType'.
23  * The root bean class is TemplateGroup
24  *
25  * Generated on Thu Sep 14 11:59:06 PDT 2006
26  * @Generated
27  */

28
29 package org.netbeans.modules.xml.wsdl.ui.view.wizard;
30
31 public class ExtensionElementType {
32     public static final String JavaDoc NAME = "Name"; // NOI18N
33
public static final String JavaDoc EXTENSIONATTR = "ExtensionAttr"; // NOI18N
34

35     private java.lang.String JavaDoc _Name;
36     private java.util.List JavaDoc _ExtensionAttr = new java.util.ArrayList JavaDoc(); // List<ExtensionAttrType>
37

38     /**
39      * Normal starting point constructor.
40      */

41     public ExtensionElementType() {
42     }
43
44     /**
45      * Required parameters constructor
46      */

47     public ExtensionElementType(org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType[] extensionAttr) {
48         if (extensionAttr!= null) {
49             ((java.util.ArrayList JavaDoc) _ExtensionAttr).ensureCapacity(extensionAttr.length);
50             for (int i = 0; i < extensionAttr.length; ++i) {
51                 _ExtensionAttr.add(extensionAttr[i]);
52             }
53         }
54     }
55
56     /**
57      * Deep copy
58      */

59     public ExtensionElementType(org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionElementType source) {
60         this(source, false);
61     }
62
63     /**
64      * Deep copy
65      * @param justData just copy the XML relevant data
66      */

67     public ExtensionElementType(org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionElementType source, boolean justData) {
68         _Name = source._Name;
69         for (java.util.Iterator JavaDoc it = source._ExtensionAttr.iterator();
70             it.hasNext(); ) {
71             org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType srcElement = (org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType)it.next();
72             _ExtensionAttr.add((srcElement == null) ? null : newExtensionAttrType(srcElement, justData));
73         }
74     }
75
76     // This attribute is optional
77
public void setName(java.lang.String JavaDoc value) {
78         _Name = value;
79     }
80
81     public java.lang.String JavaDoc getName() {
82         return _Name;
83     }
84
85     // This attribute is an array containing at least one element
86
public void setExtensionAttr(org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType[] value) {
87         if (value == null)
88             value = new ExtensionAttrType[0];
89         _ExtensionAttr.clear();
90         ((java.util.ArrayList JavaDoc) _ExtensionAttr).ensureCapacity(value.length);
91         for (int i = 0; i < value.length; ++i) {
92             _ExtensionAttr.add(value[i]);
93         }
94     }
95
96     public void setExtensionAttr(int index, org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType value) {
97         _ExtensionAttr.set(index, value);
98     }
99
100     public org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType[] getExtensionAttr() {
101         ExtensionAttrType[] arr = new ExtensionAttrType[_ExtensionAttr.size()];
102         return (ExtensionAttrType[]) _ExtensionAttr.toArray(arr);
103     }
104
105     public java.util.List JavaDoc fetchExtensionAttrList() {
106         return _ExtensionAttr;
107     }
108
109     public org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType getExtensionAttr(int index) {
110         return (ExtensionAttrType)_ExtensionAttr.get(index);
111     }
112
113     // Return the number of extensionAttr
114
public int sizeExtensionAttr() {
115         return _ExtensionAttr.size();
116     }
117
118     public int addExtensionAttr(org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType value) {
119         _ExtensionAttr.add(value);
120         int positionOfNewItem = _ExtensionAttr.size()-1;
121         return positionOfNewItem;
122     }
123
124     /**
125      * Search from the end looking for @param value, and then remove it.
126      */

127     public int removeExtensionAttr(org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType value) {
128         int pos = _ExtensionAttr.indexOf(value);
129         if (pos >= 0) {
130             _ExtensionAttr.remove(pos);
131         }
132         return pos;
133     }
134
135     /**
136      * Create a new bean using it's default constructor.
137      * This does not add it to any bean graph.
138      */

139     public org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType newExtensionAttrType() {
140         return new org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType();
141     }
142
143     /**
144      * Create a new bean, copying from another one.
145      * This does not add it to any bean graph.
146      */

147     public org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType newExtensionAttrType(ExtensionAttrType source, boolean justData) {
148         return new org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType(source, justData);
149     }
150
151     public void writeNode(java.io.Writer JavaDoc out) throws java.io.IOException JavaDoc {
152         String JavaDoc myName;
153         myName = "extensionElementType";
154         writeNode(out, myName, ""); // NOI18N
155
}
156
157     public void writeNode(java.io.Writer JavaDoc out, String JavaDoc nodeName, String JavaDoc indent) throws java.io.IOException JavaDoc {
158         writeNode(out, nodeName, null, indent, new java.util.HashMap JavaDoc());
159     }
160
161     /**
162      * It's not recommended to call this method directly.
163      */

164     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 {
165         out.write(indent);
166         out.write("<");
167         if (namespace != null) {
168             out.write((String JavaDoc)namespaceMap.get(namespace));
169             out.write(":");
170         }
171         out.write(nodeName);
172         writeNodeAttributes(out, nodeName, namespace, indent, namespaceMap);
173         out.write(">\n");
174         writeNodeChildren(out, nodeName, namespace, indent, namespaceMap);
175         out.write(indent);
176         out.write("</");
177         if (namespace != null) {
178             out.write((String JavaDoc)namespaceMap.get(namespace));
179             out.write(":");
180         }
181         out.write(nodeName);
182         out.write(">\n");
183     }
184
185     protected void writeNodeAttributes(java.io.Writer JavaDoc out, String JavaDoc nodeName, String JavaDoc namespace, String JavaDoc indent, java.util.Map JavaDoc namespaceMap) throws java.io.IOException JavaDoc {
186         // name is an attribute with namespace http://xml.netbeans.org/schema/templates
187
if (_Name != null) {
188             out.write(" name='");
189             org.netbeans.modules.xml.wsdl.ui.view.wizard.TemplateGroup.writeXML(out, _Name, true);
190             out.write("'"); // NOI18N
191
}
192     }
193
194     protected void writeNodeChildren(java.io.Writer JavaDoc out, String JavaDoc nodeName, String JavaDoc namespace, String JavaDoc indent, java.util.Map JavaDoc namespaceMap) throws java.io.IOException JavaDoc {
195         String JavaDoc nextIndent = indent + " ";
196         for (java.util.Iterator JavaDoc it = _ExtensionAttr.iterator();
197             it.hasNext(); ) {
198             org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType element = (org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType)it.next();
199             if (element != null) {
200                 element.writeNode(out, "extensionAttr", null, nextIndent, namespaceMap);
201             }
202         }
203     }
204
205     public void readNode(org.w3c.dom.Node JavaDoc node) {
206         readNode(node, new java.util.HashMap JavaDoc());
207     }
208
209     public void readNode(org.w3c.dom.Node JavaDoc node, java.util.Map JavaDoc namespacePrefixes) {
210         if (node.hasAttributes()) {
211             org.w3c.dom.NamedNodeMap JavaDoc attrs = node.getAttributes();
212             org.w3c.dom.Attr JavaDoc attr;
213             java.lang.String JavaDoc attrValue;
214             boolean firstNamespaceDef = true;
215             for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) {
216                 attr = (org.w3c.dom.Attr JavaDoc) attrs.item(attrNum);
217                 String JavaDoc attrName = attr.getName();
218                 if (attrName.startsWith("xmlns:")) {
219                     if (firstNamespaceDef) {
220                         firstNamespaceDef = false;
221                         // Dup prefix map, so as to not write over previous values, and to make it easy to clear out our entries.
222
namespacePrefixes = new java.util.HashMap JavaDoc(namespacePrefixes);
223                     }
224                     String JavaDoc attrNSPrefix = attrName.substring(6, attrName.length());
225                     namespacePrefixes.put(attrNSPrefix, attr.getValue());
226                 }
227             }
228             readNodeAttributes(node, namespacePrefixes, attrs);
229         }
230         readNodeChildren(node, namespacePrefixes);
231     }
232
233     protected void readNodeAttributes(org.w3c.dom.Node JavaDoc node, java.util.Map JavaDoc namespacePrefixes, org.w3c.dom.NamedNodeMap JavaDoc attrs) {
234         org.w3c.dom.Attr JavaDoc attr;
235         java.lang.String JavaDoc attrValue;
236         attr = (org.w3c.dom.Attr JavaDoc) attrs.getNamedItem("name");
237         if (attr != null) {
238             attrValue = attr.getValue();
239             _Name = attrValue;
240         }
241     }
242
243     protected void readNodeChildren(org.w3c.dom.Node JavaDoc node, java.util.Map JavaDoc namespacePrefixes) {
244         org.w3c.dom.NodeList JavaDoc children = node.getChildNodes();
245         for (int i = 0, size = children.getLength(); i < size; ++i) {
246             org.w3c.dom.Node JavaDoc childNode = children.item(i);
247             String JavaDoc childNodeName = (childNode.getLocalName() == null ? childNode.getNodeName().intern() : childNode.getLocalName().intern());
248             String JavaDoc childNodeValue = "";
249             if (childNode.getFirstChild() != null) {
250                 childNodeValue = childNode.getFirstChild().getNodeValue();
251             }
252             if (childNodeName == "extensionAttr") {
253                 ExtensionAttrType aExtensionAttr = newExtensionAttrType();
254                 aExtensionAttr.readNode(childNode, namespacePrefixes);
255                 _ExtensionAttr.add(aExtensionAttr);
256             }
257             else {
258                 // Found extra unrecognized childNode
259
}
260         }
261     }
262
263     public void changePropertyByName(String JavaDoc name, Object JavaDoc value) {
264         if (name == null) return;
265         name = name.intern();
266         if (name == "name")
267             setName((java.lang.String JavaDoc)value);
268         else if (name == "extensionAttr")
269             addExtensionAttr((ExtensionAttrType)value);
270         else if (name == "extensionAttr[]")
271             setExtensionAttr((ExtensionAttrType[]) value);
272         else
273             throw new IllegalArgumentException JavaDoc(name+" is not a valid property name for ExtensionElementType");
274     }
275
276     public Object JavaDoc fetchPropertyByName(String JavaDoc name) {
277         if (name == "name")
278             return getName();
279         if (name == "extensionAttr[]")
280             return getExtensionAttr();
281         throw new IllegalArgumentException JavaDoc(name+" is not a valid property name for ExtensionElementType");
282     }
283
284     public String JavaDoc nameSelf() {
285         return "ExtensionElementType";
286     }
287
288     public String JavaDoc nameChild(Object JavaDoc childObj) {
289         return nameChild(childObj, false, false);
290     }
291
292     /**
293      * @param childObj The child object to search for
294      * @param returnSchemaName Whether or not the schema name should be returned or the property name
295      * @return null if not found
296      */

297     public String JavaDoc nameChild(Object JavaDoc childObj, boolean returnConstName, boolean returnSchemaName) {
298         return nameChild(childObj, returnConstName, returnSchemaName, false);
299     }
300
301     /**
302      * @param childObj The child object to search for
303      * @param returnSchemaName Whether or not the schema name should be returned or the property name
304      * @return null if not found
305      */

306     public String JavaDoc nameChild(Object JavaDoc childObj, boolean returnConstName, boolean returnSchemaName, boolean returnXPathName) {
307         if (childObj instanceof java.lang.String JavaDoc) {
308             java.lang.String JavaDoc child = (java.lang.String JavaDoc) childObj;
309             if (child == _Name) {
310                 if (returnConstName) {
311                     return NAME;
312                 } else if (returnSchemaName) {
313                     return "name";
314                 } else if (returnXPathName) {
315                     return "@name";
316                 } else {
317                     return "Name";
318                 }
319             }
320         }
321         if (childObj instanceof ExtensionAttrType) {
322             ExtensionAttrType child = (ExtensionAttrType) childObj;
323             int index = 0;
324             for (java.util.Iterator JavaDoc it = _ExtensionAttr.iterator();
325                 it.hasNext(); ) {
326                 org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType element = (org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType)it.next();
327                 if (child == element) {
328                     if (returnConstName) {
329                         return EXTENSIONATTR;
330                     } else if (returnSchemaName) {
331                         return "extensionAttr";
332                     } else if (returnXPathName) {
333                         return "extensionAttr[position()="+index+"]";
334                     } else {
335                         return "ExtensionAttr."+Integer.toHexString(index);
336                     }
337                 }
338                 ++index;
339             }
340         }
341         return null;
342     }
343
344     /**
345      * Return an array of all of the properties that are beans and are set.
346      */

347     public java.lang.Object JavaDoc[] childBeans(boolean recursive) {
348         java.util.List JavaDoc children = new java.util.LinkedList JavaDoc();
349         childBeans(recursive, children);
350         java.lang.Object JavaDoc[] result = new java.lang.Object JavaDoc[children.size()];
351         return (java.lang.Object JavaDoc[]) children.toArray(result);
352     }
353
354     /**
355      * Put all child beans into the beans list.
356      */

357     public void childBeans(boolean recursive, java.util.List JavaDoc beans) {
358         for (java.util.Iterator JavaDoc it = _ExtensionAttr.iterator();
359             it.hasNext(); ) {
360             org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType element = (org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType)it.next();
361             if (element != null) {
362                 if (recursive) {
363                     element.childBeans(true, beans);
364                 }
365                 beans.add(element);
366             }
367         }
368     }
369
370     public boolean equals(Object JavaDoc o) {
371         return o instanceof org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionElementType && equals((org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionElementType) o);
372     }
373
374     public boolean equals(org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionElementType inst) {
375         if (inst == this) {
376             return true;
377         }
378         if (inst == null) {
379             return false;
380         }
381         if (!(_Name == null ? inst._Name == null : _Name.equals(inst._Name))) {
382             return false;
383         }
384         if (sizeExtensionAttr() != inst.sizeExtensionAttr())
385             return false;
386         // Compare every element.
387
for (java.util.Iterator JavaDoc it = _ExtensionAttr.iterator(), it2 = inst._ExtensionAttr.iterator();
388             it.hasNext() && it2.hasNext(); ) {
389             org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType element = (org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType)it.next();
390             org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType element2 = (org.netbeans.modules.xml.wsdl.ui.view.wizard.ExtensionAttrType)it2.next();
391             if (!(element == null ? element2 == null : element.equals(element2))) {
392                 return false;
393             }
394         }
395         return true;
396     }
397
398     public int hashCode() {
399         int result = 17;
400         result = 37*result + (_Name == null ? 0 : _Name.hashCode());
401         result = 37*result + (_ExtensionAttr == null ? 0 : _ExtensionAttr.hashCode());
402         return result;
403     }
404
405 }
406
407
408 /*
409         The following schema file has been used for generation:
410
411 <?xml version="1.0" encoding="UTF-8"?>
412
413 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
414             targetNamespace="http://xml.netbeans.org/schema/templates"
415             xmlns:tns="http://xml.netbeans.org/schema/templates"
416             elementFormDefault="qualified">
417     <xsd:element name="templateGroup">
418         <xsd:complexType>
419             <xsd:sequence>
420                 <xsd:element name="template" type="tns:templateType" maxOccurs="unbounded"/>
421             </xsd:sequence>
422             <xsd:attribute name="namespace" type="xsd:string"/>
423             <xsd:attribute name="prefix" type="xsd:string"/>
424         </xsd:complexType>
425     </xsd:element>
426     <xsd:complexType name="templateType">
427         <xsd:sequence>
428             <xsd:element name="wsdlElement" type="tns:wsdlElementType" maxOccurs="unbounded"/>
429         </xsd:sequence>
430         <xsd:attribute name="name" type="xsd:string"/>
431         <xsd:attribute name="default" type="xsd:boolean"/>
432     </xsd:complexType>
433     <xsd:complexType name="wsdlElementType">
434         <xsd:sequence>
435             <xsd:element name="extensionElement" type="tns:extensionElementType" maxOccurs="unbounded"/>
436         </xsd:sequence>
437         <xsd:attribute name="name" type="xsd:string"/>
438     </xsd:complexType>
439     <xsd:complexType name="extensionElementType">
440         <xsd:sequence>
441             <xsd:element name="extensionAttr" type="tns:extensionAttrType" maxOccurs="unbounded"/>
442         </xsd:sequence>
443         <xsd:attribute name="name" type="xsd:string"/>
444     </xsd:complexType>
445     <xsd:complexType name="extensionAttrType">
446         <xsd:attribute name="name" type="xsd:string"/>
447         <xsd:attribute name="defaultValue" type="xsd:string"/>
448     </xsd:complexType>
449 </xsd:schema>
450
451
452 */

453
Popular Tags