1 19 20 28 29 package org.netbeans.modules.xml.wsdl.ui.view.wizard; 30 31 public class TemplateType { 32 public static final String NAME = "Name"; public static final String DEFAULT = "Default"; public static final String WSDLELEMENT = "WsdlElement"; 36 private java.lang.String _Name; 37 private boolean _Default; 38 private java.util.List _WsdlElement = new java.util.ArrayList (); 40 43 public TemplateType() { 44 } 45 46 49 public TemplateType(org.netbeans.modules.xml.wsdl.ui.view.wizard.WsdlElementType[] wsdlElement) { 50 if (wsdlElement!= null) { 51 ((java.util.ArrayList ) _WsdlElement).ensureCapacity(wsdlElement.length); 52 for (int i = 0; i < wsdlElement.length; ++i) { 53 _WsdlElement.add(wsdlElement[i]); 54 } 55 } 56 } 57 58 61 public TemplateType(org.netbeans.modules.xml.wsdl.ui.view.wizard.TemplateType source) { 62 this(source, false); 63 } 64 65 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 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 public void setName(java.lang.String value) { 81 _Name = value; 82 } 83 84 public java.lang.String getName() { 85 return _Name; 86 } 87 88 public void setDefault(boolean value) { 90 _Default = value; 91 } 92 93 public boolean isDefault() { 94 return _Default; 95 } 96 97 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 ) _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 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 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 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 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 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 out) throws java.io.IOException { 164 String myName; 165 myName = "templateType"; 166 writeNode(out, myName, ""); } 168 169 public void writeNode(java.io.Writer out, String nodeName, String indent) throws java.io.IOException { 170 writeNode(out, nodeName, null, indent, new java.util.HashMap ()); 171 } 172 173 176 public void writeNode(java.io.Writer out, String nodeName, String namespace, String indent, java.util.Map namespaceMap) throws java.io.IOException { 177 out.write(indent); 178 out.write("<"); 179 if (namespace != null) { 180 out.write((String )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 )namespaceMap.get(namespace)); 191 out.write(":"); 192 } 193 out.write(nodeName); 194 out.write(">\n"); 195 } 196 197 protected void writeNodeAttributes(java.io.Writer out, String nodeName, String namespace, String indent, java.util.Map namespaceMap) throws java.io.IOException { 198 if (_Name != null) { 200 out.write(" name='"); 201 org.netbeans.modules.xml.wsdl.ui.view.wizard.TemplateGroup.writeXML(out, _Name, true); 202 out.write("'"); } 204 out.write(" default='"); 206 out.write(_Default ? "true" : "false"); 207 out.write("'"); } 209 210 protected void writeNodeChildren(java.io.Writer out, String nodeName, String namespace, String indent, java.util.Map namespaceMap) throws java.io.IOException { 211 String nextIndent = indent + " "; 212 for (java.util.Iterator 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 node) { 222 readNode(node, new java.util.HashMap ()); 223 } 224 225 public void readNode(org.w3c.dom.Node node, java.util.Map namespacePrefixes) { 226 if (node.hasAttributes()) { 227 org.w3c.dom.NamedNodeMap attrs = node.getAttributes(); 228 org.w3c.dom.Attr attr; 229 java.lang.String attrValue; 230 boolean firstNamespaceDef = true; 231 for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) { 232 attr = (org.w3c.dom.Attr ) attrs.item(attrNum); 233 String attrName = attr.getName(); 234 if (attrName.startsWith("xmlns:")) { 235 if (firstNamespaceDef) { 236 firstNamespaceDef = false; 237 namespacePrefixes = new java.util.HashMap (namespacePrefixes); 239 } 240 String 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 node, java.util.Map namespacePrefixes, org.w3c.dom.NamedNodeMap attrs) { 250 org.w3c.dom.Attr attr; 251 java.lang.String attrValue; 252 attr = (org.w3c.dom.Attr ) attrs.getNamedItem("name"); 253 if (attr != null) { 254 attrValue = attr.getValue(); 255 _Name = attrValue; 256 } 257 attr = (org.w3c.dom.Attr ) 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 node, java.util.Map namespacePrefixes) { 265 org.w3c.dom.NodeList children = node.getChildNodes(); 266 for (int i = 0, size = children.getLength(); i < size; ++i) { 267 org.w3c.dom.Node childNode = children.item(i); 268 String childNodeName = (childNode.getLocalName() == null ? childNode.getNodeName().intern() : childNode.getLocalName().intern()); 269 String 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 } 281 } 282 } 283 284 public void changePropertyByName(String name, Object value) { 285 if (name == null) return; 286 name = name.intern(); 287 if (name == "name") 288 setName((java.lang.String )value); 289 else if (name == "default") 290 setDefault(((java.lang.Boolean )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 (name+" is not a valid property name for TemplateType"); 297 } 298 299 public Object fetchPropertyByName(String 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 (name+" is not a valid property name for TemplateType"); 307 } 308 309 public String nameSelf() { 310 return "TemplateType"; 311 } 312 313 public String nameChild(Object childObj) { 314 return nameChild(childObj, false, false); 315 } 316 317 322 public String nameChild(Object childObj, boolean returnConstName, boolean returnSchemaName) { 323 return nameChild(childObj, returnConstName, returnSchemaName, false); 324 } 325 326 331 public String nameChild(Object childObj, boolean returnConstName, boolean returnSchemaName, boolean returnXPathName) { 332 if (childObj instanceof java.lang.String ) { 333 java.lang.String child = (java.lang.String ) 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 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 ) { 367 java.lang.Boolean child = (java.lang.Boolean ) childObj; 368 if (((java.lang.Boolean )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 386 public java.lang.Object [] childBeans(boolean recursive) { 387 java.util.List children = new java.util.LinkedList (); 388 childBeans(recursive, children); 389 java.lang.Object [] result = new java.lang.Object [children.size()]; 390 return (java.lang.Object []) children.toArray(result); 391 } 392 393 396 public void childBeans(boolean recursive, java.util.List beans) { 397 for (java.util.Iterator 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 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 for (java.util.Iterator 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 496 | Popular Tags |