KickJava   Java API By Example, From Geeks To Geeks.

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


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 TemplateType
22  * matches the schema element 'templateType'.
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 TemplateType {
32     public static final String JavaDoc NAME = "Name"; // NOI18N
33
public static final String JavaDoc DEFAULT = "Default"; // NOI18N
34
public static final String JavaDoc WSDLELEMENT = "WsdlElement"; // NOI18N
35

36     private java.lang.String JavaDoc _Name;
37     private boolean _Default;
38     private java.util.List JavaDoc _WsdlElement = new java.util.ArrayList JavaDoc(); // List<WsdlElementType>
39

40     /**
41      * Normal starting point constructor.
42      */

43     public TemplateType() {
44     }
45
46     /**
47      * Required parameters constructor
48      */

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

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

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

139     public int removeWsdlElement(org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType value) {
140         int pos = _WsdlElement.indexOf(value);
141         if (pos >= 0) {
142             _WsdlElement.remove(pos);
143         }
144         return pos;
145     }
146
147     /**
148      * Create a new bean using it's default constructor.
149      * This does not add it to any bean graph.
150      */

151     public org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType newWsdlElementType() {
152         return new org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType();
153     }
154
155     /**
156      * Create a new bean, copying from another one.
157      * This does not add it to any bean graph.
158      */

159     public org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType newWsdlElementType(WsdlElementType source, boolean justData) {
160         return new org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType(source, justData);
161     }
162
163     public void writeNode(java.io.Writer JavaDoc out) throws java.io.IOException JavaDoc {
164         String JavaDoc myName;
165         myName = "templateType";
166         writeNode(out, myName, ""); // NOI18N
167
}
168
169     public void writeNode(java.io.Writer JavaDoc out, String JavaDoc nodeName, String JavaDoc indent) throws java.io.IOException JavaDoc {
170         writeNode(out, nodeName, null, indent, new java.util.HashMap JavaDoc());
171     }
172
173     /**
174      * It's not recommended to call this method directly.
175      */

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

322     public String JavaDoc nameChild(Object JavaDoc childObj, boolean returnConstName, boolean returnSchemaName) {
323         return nameChild(childObj, returnConstName, returnSchemaName, false);
324     }
325
326     /**
327      * @param childObj The child object to search for
328      * @param returnSchemaName Whether or not the schema name should be returned or the property name
329      * @return null if not found
330      */

331     public String JavaDoc nameChild(Object JavaDoc childObj, boolean returnConstName, boolean returnSchemaName, boolean returnXPathName) {
332         if (childObj instanceof java.lang.String JavaDoc) {
333             java.lang.String JavaDoc child = (java.lang.String JavaDoc) childObj;
334             if (child == _Name) {
335                 if (returnConstName) {
336                     return NAME;
337                 } else if (returnSchemaName) {
338                     return "name";
339                 } else if (returnXPathName) {
340                     return "@name";
341                 } else {
342                     return "Name";
343                 }
344             }
345         }
346         if (childObj instanceof WsdlElementType) {
347             WsdlElementType child = (WsdlElementType) childObj;
348             int index = 0;
349             for (java.util.Iterator JavaDoc it = _WsdlElement.iterator();
350                 it.hasNext(); ) {
351                 org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType element = (org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType)it.next();
352                 if (child == element) {
353                     if (returnConstName) {
354                         return WSDLELEMENT;
355                     } else if (returnSchemaName) {
356                         return "wsdlElement";
357                     } else if (returnXPathName) {
358                         return "wsdlElement[position()="+index+"]";
359                     } else {
360                         return "WsdlElement."+Integer.toHexString(index);
361                     }
362                 }
363                 ++index;
364             }
365         }
366         if (childObj instanceof java.lang.Boolean JavaDoc) {
367             java.lang.Boolean JavaDoc child = (java.lang.Boolean JavaDoc) childObj;
368             if (((java.lang.Boolean JavaDoc)child).booleanValue() == _Default) {
369                 if (returnConstName) {
370                     return DEFAULT;
371                 } else if (returnSchemaName) {
372                     return "default";
373                 } else if (returnXPathName) {
374                     return "@default";
375                 } else {
376                     return "Default";
377                 }
378             }
379         }
380         return null;
381     }
382
383     /**
384      * Return an array of all of the properties that are beans and are set.
385      */

386     public java.lang.Object JavaDoc[] childBeans(boolean recursive) {
387         java.util.List JavaDoc children = new java.util.LinkedList JavaDoc();
388         childBeans(recursive, children);
389         java.lang.Object JavaDoc[] result = new java.lang.Object JavaDoc[children.size()];
390         return (java.lang.Object JavaDoc[]) children.toArray(result);
391     }
392
393     /**
394      * Put all child beans into the beans list.
395      */

396     public void childBeans(boolean recursive, java.util.List JavaDoc beans) {
397         for (java.util.Iterator JavaDoc it = _WsdlElement.iterator();
398             it.hasNext(); ) {
399             org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType element = (org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType)it.next();
400             if (element != null) {
401                 if (recursive) {
402                     element.childBeans(true, beans);
403                 }
404                 beans.add(element);
405             }
406         }
407     }
408
409     public boolean equals(Object JavaDoc o) {
410         return o instanceof org.netbeans.modules.xml.wsdl.ui.view.wizard.TemplateType && equals((org.netbeans.modules.xml.wsdl.ui.view.wizard.TemplateType) o);
411     }
412
413     public boolean equals(org.netbeans.modules.xml.wsdl.ui.view.wizard.TemplateType inst) {
414         if (inst == this) {
415             return true;
416         }
417         if (inst == null) {
418             return false;
419         }
420         if (!(_Name == null ? inst._Name == null : _Name.equals(inst._Name))) {
421             return false;
422         }
423         if (!(_Default == inst._Default)) {
424             return false;
425         }
426         if (sizeWsdlElement() != inst.sizeWsdlElement())
427             return false;
428         // Compare every element.
429
for (java.util.Iterator JavaDoc it = _WsdlElement.iterator(), it2 = inst._WsdlElement.iterator();
430             it.hasNext() && it2.hasNext(); ) {
431             org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType element = (org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType)it.next();
432             org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType element2 = (org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType)it2.next();
433             if (!(element == null ? element2 == null : element.equals(element2))) {
434                 return false;
435             }
436         }
437         return true;
438     }
439
440     public int hashCode() {
441         int result = 17;
442         result = 37*result + (_Name == null ? 0 : _Name.hashCode());
443         result = 37*result + (_Default ? 0 : 1);
444         result = 37*result + (_WsdlElement == null ? 0 : _WsdlElement.hashCode());
445         return result;
446     }
447
448 }
449
450
451 /*
452         The following schema file has been used for generation:
453
454 <?xml version="1.0" encoding="UTF-8"?>
455
456 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
457             targetNamespace="http://xml.netbeans.org/schema/templates"
458             xmlns:tns="http://xml.netbeans.org/schema/templates"
459             elementFormDefault="qualified">
460     <xsd:element name="templateGroup">
461         <xsd:complexType>
462             <xsd:sequence>
463                 <xsd:element name="template" type="tns:templateType" maxOccurs="unbounded"/>
464             </xsd:sequence>
465             <xsd:attribute name="namespace" type="xsd:string"/>
466             <xsd:attribute name="prefix" type="xsd:string"/>
467         </xsd:complexType>
468     </xsd:element>
469     <xsd:complexType name="templateType">
470         <xsd:sequence>
471             <xsd:element name="wsdlElement" type="tns:wsdlElementType" maxOccurs="unbounded"/>
472         </xsd:sequence>
473         <xsd:attribute name="name" type="xsd:string"/>
474         <xsd:attribute name="default" type="xsd:boolean"/>
475     </xsd:complexType>
476     <xsd:complexType name="wsdlElementType">
477         <xsd:sequence>
478             <xsd:element name="extensionElement" type="tns:extensionElementType" maxOccurs="unbounded"/>
479         </xsd:sequence>
480         <xsd:attribute name="name" type="xsd:string"/>
481     </xsd:complexType>
482     <xsd:complexType name="extensionElementType">
483         <xsd:sequence>
484             <xsd:element name="extensionAttr" type="tns:extensionAttrType" maxOccurs="unbounded"/>
485         </xsd:sequence>
486         <xsd:attribute name="name" type="xsd:string"/>
487     </xsd:complexType>
488     <xsd:complexType name="extensionAttrType">
489         <xsd:attribute name="name" type="xsd:string"/>
490         <xsd:attribute name="defaultValue" type="xsd:string"/>
491     </xsd:complexType>
492 </xsd:schema>
493
494
495 */

496
Popular Tags