1 19 70 71 package org.netbeans.modules.schema2beansdev.metadd; 72 73 public class MetaDD implements org.netbeans.modules.schema2beansdev.metadd.CommonBean { 74 public static final String META_ELEMENT = "MetaElement"; public static final String IMPLEMENTS = "Implements"; public static final String EXTENDS = "Extends"; public static final String IMPORT = "Import"; public static final String VETOABLE = "Vetoable"; public static final String THROW_EXCEPTIONS = "ThrowExceptions"; public static final String SCHEMALOCATION = "SchemaLocation"; public static final String FINDER = "Finder"; 83 private java.util.List _MetaElement = new java.util.ArrayList (); private String _Implements; 85 private String _Extends; 86 private java.util.List _Import = new java.util.ArrayList (); private boolean _Vetoable; 88 private boolean _isSet_Vetoable = false; 89 private boolean _ThrowExceptions; 90 private boolean _isSet_ThrowExceptions = false; 91 private String _SchemaLocation; 92 private java.util.List _Finder = new java.util.ArrayList (); private java.lang.String schemaLocation; 94 95 98 public MetaDD() { 99 } 100 101 104 public MetaDD(org.netbeans.modules.schema2beansdev.metadd.MetaDD source) { 105 this(source, false); 106 } 107 108 112 public MetaDD(org.netbeans.modules.schema2beansdev.metadd.MetaDD source, boolean justData) { 113 for (java.util.Iterator it = source._MetaElement.iterator(); 114 it.hasNext(); ) { 115 org.netbeans.modules.schema2beansdev.metadd.MetaElement srcElement = (org.netbeans.modules.schema2beansdev.metadd.MetaElement)it.next(); 116 _MetaElement.add((srcElement == null) ? null : newMetaElement(srcElement, justData)); 117 } 118 _Implements = source._Implements; 119 _Extends = source._Extends; 120 for (java.util.Iterator it = source._Import.iterator(); 121 it.hasNext(); ) { 122 String srcElement = (String )it.next(); 123 _Import.add(srcElement); 124 } 125 _Vetoable = source._Vetoable; 126 _isSet_Vetoable = source._isSet_Vetoable; 127 _ThrowExceptions = source._ThrowExceptions; 128 _isSet_ThrowExceptions = source._isSet_ThrowExceptions; 129 _SchemaLocation = source._SchemaLocation; 130 for (java.util.Iterator it = source._Finder.iterator(); 131 it.hasNext(); ) { 132 String srcElement = (String )it.next(); 133 _Finder.add(srcElement); 134 } 135 schemaLocation = source.schemaLocation; 136 } 137 138 public void setMetaElement(org.netbeans.modules.schema2beansdev.metadd.MetaElement[] value) { 140 if (value == null) 141 value = new MetaElement[0]; 142 _MetaElement.clear(); 143 ((java.util.ArrayList ) _MetaElement).ensureCapacity(value.length); 144 for (int i = 0; i < value.length; ++i) { 145 _MetaElement.add(value[i]); 146 } 147 } 148 149 public void setMetaElement(int index, org.netbeans.modules.schema2beansdev.metadd.MetaElement value) { 150 _MetaElement.set(index, value); 151 } 152 153 public org.netbeans.modules.schema2beansdev.metadd.MetaElement[] getMetaElement() { 154 MetaElement[] arr = new MetaElement[_MetaElement.size()]; 155 return (MetaElement[]) _MetaElement.toArray(arr); 156 } 157 158 public java.util.List fetchMetaElementList() { 159 return _MetaElement; 160 } 161 162 public org.netbeans.modules.schema2beansdev.metadd.MetaElement getMetaElement(int index) { 163 return (MetaElement)_MetaElement.get(index); 164 } 165 166 public int sizeMetaElement() { 168 return _MetaElement.size(); 169 } 170 171 public int addMetaElement(org.netbeans.modules.schema2beansdev.metadd.MetaElement value) { 172 _MetaElement.add(value); 173 int positionOfNewItem = _MetaElement.size()-1; 174 return positionOfNewItem; 175 } 176 177 180 public int removeMetaElement(org.netbeans.modules.schema2beansdev.metadd.MetaElement value) { 181 int pos = _MetaElement.indexOf(value); 182 if (pos >= 0) { 183 _MetaElement.remove(pos); 184 } 185 return pos; 186 } 187 188 public void setImplements(String value) { 190 _Implements = value; 191 } 192 193 public String getImplements() { 194 return _Implements; 195 } 196 197 public void setExtends(String value) { 199 _Extends = value; 200 } 201 202 public String getExtends() { 203 return _Extends; 204 } 205 206 public void setImport(String [] value) { 208 if (value == null) 209 value = new String [0]; 210 _Import.clear(); 211 ((java.util.ArrayList ) _Import).ensureCapacity(value.length); 212 for (int i = 0; i < value.length; ++i) { 213 _Import.add(value[i]); 214 } 215 } 216 217 public void setImport(int index, String value) { 218 _Import.set(index, value); 219 } 220 221 public String [] getImport() { 222 String [] arr = new String [_Import.size()]; 223 return (String []) _Import.toArray(arr); 224 } 225 226 public java.util.List fetchImportList() { 227 return _Import; 228 } 229 230 public String getImport(int index) { 231 return (String )_Import.get(index); 232 } 233 234 public int sizeImport() { 236 return _Import.size(); 237 } 238 239 public int addImport(String value) { 240 _Import.add(value); 241 int positionOfNewItem = _Import.size()-1; 242 return positionOfNewItem; 243 } 244 245 248 public int removeImport(String value) { 249 int pos = _Import.indexOf(value); 250 if (pos >= 0) { 251 _Import.remove(pos); 252 } 253 return pos; 254 } 255 256 public void setVetoable(boolean value) { 258 _Vetoable = value; 259 _isSet_Vetoable = true; 260 } 261 262 public boolean isVetoable() { 263 return _Vetoable; 264 } 265 266 public void setThrowExceptions(boolean value) { 268 _ThrowExceptions = value; 269 _isSet_ThrowExceptions = true; 270 } 271 272 public boolean isThrowExceptions() { 273 return _ThrowExceptions; 274 } 275 276 public void setSchemaLocation(String value) { 278 _SchemaLocation = value; 279 } 280 281 public String getSchemaLocation() { 282 return _SchemaLocation; 283 } 284 285 public void setFinder(String [] value) { 287 if (value == null) 288 value = new String [0]; 289 _Finder.clear(); 290 ((java.util.ArrayList ) _Finder).ensureCapacity(value.length); 291 for (int i = 0; i < value.length; ++i) { 292 _Finder.add(value[i]); 293 } 294 } 295 296 public void setFinder(int index, String value) { 297 _Finder.set(index, value); 298 } 299 300 public String [] getFinder() { 301 String [] arr = new String [_Finder.size()]; 302 return (String []) _Finder.toArray(arr); 303 } 304 305 public java.util.List fetchFinderList() { 306 return _Finder; 307 } 308 309 public String getFinder(int index) { 310 return (String )_Finder.get(index); 311 } 312 313 public int sizeFinder() { 315 return _Finder.size(); 316 } 317 318 public int addFinder(String value) { 319 _Finder.add(value); 320 int positionOfNewItem = _Finder.size()-1; 321 return positionOfNewItem; 322 } 323 324 327 public int removeFinder(String value) { 328 int pos = _Finder.indexOf(value); 329 if (pos >= 0) { 330 _Finder.remove(pos); 331 } 332 return pos; 333 } 334 335 public void _setSchemaLocation(String location) { 336 schemaLocation = location; 337 } 338 339 public String _getSchemaLocation() { 340 return schemaLocation; 341 } 342 343 347 public org.netbeans.modules.schema2beansdev.metadd.MetaElement newMetaElement() { 348 return new org.netbeans.modules.schema2beansdev.metadd.MetaElement(); 349 } 350 351 355 public org.netbeans.modules.schema2beansdev.metadd.MetaElement newMetaElement(MetaElement source, boolean justData) { 356 return new org.netbeans.modules.schema2beansdev.metadd.MetaElement(source, justData); 357 } 358 359 public void write(java.io.File f) throws java.io.IOException { 360 java.io.OutputStream out = new java.io.FileOutputStream (f); 361 try { 362 write(out); 363 } finally { 364 out.close(); 365 } 366 } 367 368 public void write(java.io.OutputStream out) throws java.io.IOException { 369 write(out, null); 370 } 371 372 public void write(java.io.OutputStream out, String encoding) throws java.io.IOException { 373 java.io.Writer w; 374 if (encoding == null) { 375 encoding = "UTF-8"; } 377 w = new java.io.BufferedWriter (new java.io.OutputStreamWriter (out, encoding)); 378 write(w, encoding); 379 w.flush(); 380 } 381 382 386 public void write(java.io.Writer out, String encoding) throws java.io.IOException { 387 out.write("<?xml version='1.0'"); if (encoding != null) 389 out.write(" encoding='"+encoding+"'"); out.write(" ?>\n"); writeNode(out, "metaDD", ""); } 393 394 public void writeNode(java.io.Writer out) throws java.io.IOException { 395 String myName; 396 myName = "metaDD"; 397 writeNode(out, myName, ""); } 399 400 public void writeNode(java.io.Writer out, String nodeName, String indent) throws java.io.IOException { 401 writeNode(out, nodeName, null, indent, new java.util.HashMap ()); 402 } 403 404 407 public void writeNode(java.io.Writer out, String nodeName, String namespace, String indent, java.util.Map namespaceMap) throws java.io.IOException { 408 out.write(indent); 409 out.write("<"); 410 if (namespace != null) { 411 out.write((String )namespaceMap.get(namespace)); 412 out.write(":"); 413 } 414 out.write(nodeName); 415 if (schemaLocation != null) { 416 namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance", "xsi"); 417 out.write(" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='"); 418 out.write(schemaLocation); 419 out.write("'"); } 421 out.write(">\n"); 422 String nextIndent = indent + " "; 423 for (java.util.Iterator it = _MetaElement.iterator(); 424 it.hasNext(); ) { 425 org.netbeans.modules.schema2beansdev.metadd.MetaElement element = (org.netbeans.modules.schema2beansdev.metadd.MetaElement)it.next(); 426 if (element != null) { 427 element.writeNode(out, "meta-element", null, nextIndent, namespaceMap); 428 } 429 } 430 if (_Implements != null) { 431 out.write(nextIndent); 432 out.write("<implements"); out.write(">"); org.netbeans.modules.schema2beansdev.metadd.MetaDD.writeXML(out, _Implements, false); 435 out.write("</implements>\n"); } 437 if (_Extends != null) { 438 out.write(nextIndent); 439 out.write("<extends"); out.write(">"); org.netbeans.modules.schema2beansdev.metadd.MetaDD.writeXML(out, _Extends, false); 442 out.write("</extends>\n"); } 444 for (java.util.Iterator it = _Import.iterator(); it.hasNext(); ) { 445 String element = (String )it.next(); 446 if (element != null) { 447 out.write(nextIndent); 448 out.write("<import"); out.write(">"); org.netbeans.modules.schema2beansdev.metadd.MetaDD.writeXML(out, element, false); 451 out.write("</import>\n"); } 453 } 454 if (_isSet_Vetoable) { 455 if (_Vetoable) { 456 out.write(nextIndent); 457 out.write("<vetoable"); out.write("/>\n"); } 460 } 461 if (_isSet_ThrowExceptions) { 462 if (_ThrowExceptions) { 463 out.write(nextIndent); 464 out.write("<throw-exceptions"); out.write("/>\n"); } 467 } 468 if (_SchemaLocation != null) { 469 out.write(nextIndent); 470 out.write("<schemaLocation"); out.write(">"); org.netbeans.modules.schema2beansdev.metadd.MetaDD.writeXML(out, _SchemaLocation, false); 473 out.write("</schemaLocation>\n"); } 475 for (java.util.Iterator it = _Finder.iterator(); it.hasNext(); ) { 476 String element = (String )it.next(); 477 if (element != null) { 478 out.write(nextIndent); 479 out.write("<finder"); out.write(">"); org.netbeans.modules.schema2beansdev.metadd.MetaDD.writeXML(out, element, false); 482 out.write("</finder>\n"); } 484 } 485 out.write(indent); 486 out.write("</"); 487 if (namespace != null) { 488 out.write((String )namespaceMap.get(namespace)); 489 out.write(":"); 490 } 491 out.write(nodeName); 492 out.write(">\n"); 493 } 494 495 public static MetaDD read(java.io.File f) throws javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException , java.io.IOException { 496 java.io.InputStream in = new java.io.FileInputStream (f); 497 try { 498 return read(in); 499 } finally { 500 in.close(); 501 } 502 } 503 504 public static MetaDD read(java.io.InputStream in) throws javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException , java.io.IOException { 505 return read(new org.xml.sax.InputSource (in), false, null, null); 506 } 507 508 514 public static MetaDD readNoEntityResolver(java.io.InputStream in) throws javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException , java.io.IOException { 515 return read(new org.xml.sax.InputSource (in), false, 516 new org.xml.sax.EntityResolver () { 517 public org.xml.sax.InputSource resolveEntity(String publicId, String systemId) { 518 java.io.ByteArrayInputStream bin = new java.io.ByteArrayInputStream (new byte[0]); 519 return new org.xml.sax.InputSource (bin); 520 } 521 } 522 , null); 523 } 524 525 public static MetaDD read(org.xml.sax.InputSource in, boolean validate, org.xml.sax.EntityResolver er, org.xml.sax.ErrorHandler eh) throws javax.xml.parsers.ParserConfigurationException , org.xml.sax.SAXException , java.io.IOException { 526 javax.xml.parsers.DocumentBuilderFactory dbf = javax.xml.parsers.DocumentBuilderFactory.newInstance(); 527 dbf.setValidating(validate); 528 dbf.setNamespaceAware(true); 529 javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder(); 530 if (er != null) db.setEntityResolver(er); 531 if (eh != null) db.setErrorHandler(eh); 532 org.w3c.dom.Document doc = db.parse(in); 533 return read(doc); 534 } 535 536 public static MetaDD read(org.w3c.dom.Document document) { 537 MetaDD aMetaDD = new MetaDD(); 538 aMetaDD.readFromDocument(document); 539 return aMetaDD; 540 } 541 542 protected void readFromDocument(org.w3c.dom.Document document) { 543 readNode(document.getDocumentElement()); 544 } 545 546 public void readNode(org.w3c.dom.Node node) { 547 readNode(node, new java.util.HashMap ()); 548 } 549 550 public void readNode(org.w3c.dom.Node node, java.util.Map namespacePrefixes) { 551 if (node.hasAttributes()) { 552 org.w3c.dom.NamedNodeMap attrs = node.getAttributes(); 553 org.w3c.dom.Attr attr; 554 java.lang.String attrValue; 555 boolean firstNamespaceDef = true; 556 for (int attrNum = 0; attrNum < attrs.getLength(); ++attrNum) { 557 attr = (org.w3c.dom.Attr ) attrs.item(attrNum); 558 String attrName = attr.getName(); 559 if (attrName.startsWith("xmlns:")) { 560 if (firstNamespaceDef) { 561 firstNamespaceDef = false; 562 namespacePrefixes = new java.util.HashMap (namespacePrefixes); 564 } 565 String attrNSPrefix = attrName.substring(6, attrName.length()); 566 namespacePrefixes.put(attrNSPrefix, attr.getValue()); 567 } 568 } 569 String xsiPrefix = "xsi"; 570 for (java.util.Iterator it = namespacePrefixes.keySet().iterator(); 571 it.hasNext(); ) { 572 String prefix = (String ) it.next(); 573 String ns = (String ) namespacePrefixes.get(prefix); 574 if ("http://www.w3.org/2001/XMLSchema-instance".equals(ns)) { 575 xsiPrefix = prefix; 576 break; 577 } 578 } 579 attr = (org.w3c.dom.Attr ) attrs.getNamedItem(""+xsiPrefix+":schemaLocation"); 580 if (attr != null) { 581 attrValue = attr.getValue(); 582 schemaLocation = attrValue; 583 } 584 } 585 org.w3c.dom.NodeList children = node.getChildNodes(); 586 for (int i = 0, size = children.getLength(); i < size; ++i) { 587 org.w3c.dom.Node childNode = children.item(i); 588 String childNodeName = (childNode.getLocalName() == null ? childNode.getNodeName().intern() : childNode.getLocalName().intern()); 589 String childNodeValue = ""; 590 if (childNode.getFirstChild() != null) { 591 childNodeValue = childNode.getFirstChild().getNodeValue(); 592 } 593 if (childNodeName == "meta-element") { 594 MetaElement aMetaElement = newMetaElement(); 595 aMetaElement.readNode(childNode, namespacePrefixes); 596 _MetaElement.add(aMetaElement); 597 } 598 else if (childNodeName == "implements") { 599 _Implements = childNodeValue; 600 } 601 else if (childNodeName == "extends") { 602 _Extends = childNodeValue; 603 } 604 else if (childNodeName == "import") { 605 String aImport; 606 aImport = childNodeValue; 607 _Import.add(aImport); 608 } 609 else if (childNodeName == "vetoable") { 610 if (childNode.getFirstChild() == null) 611 _Vetoable = true; 612 else 613 _Vetoable = java.lang.Boolean.valueOf(childNodeValue).booleanValue(); 614 _isSet_Vetoable = true; 615 } 616 else if (childNodeName == "throw-exceptions") { 617 if (childNode.getFirstChild() == null) 618 _ThrowExceptions = true; 619 else 620 _ThrowExceptions = java.lang.Boolean.valueOf(childNodeValue).booleanValue(); 621 _isSet_ThrowExceptions = true; 622 } 623 else if (childNodeName == "schemaLocation") { 624 _SchemaLocation = childNodeValue; 625 } 626 else if (childNodeName == "finder") { 627 String aFinder; 628 aFinder = childNodeValue; 629 _Finder.add(aFinder); 630 } 631 else { 632 } 634 } 635 } 636 637 641 public static void writeXML(java.io.Writer out, String msg) throws java.io.IOException { 642 writeXML(out, msg, true); 643 } 644 645 public static void writeXML(java.io.Writer out, String msg, boolean attribute) throws java.io.IOException { 646 if (msg == null) 647 return; 648 int msgLength = msg.length(); 649 for (int i = 0; i < msgLength; ++i) { 650 char c = msg.charAt(i); 651 writeXML(out, c, attribute); 652 } 653 } 654 655 public static void writeXML(java.io.Writer out, char msg, boolean attribute) throws java.io.IOException { 656 if (msg == '&') 657 out.write("&"); 658 else if (msg == '<') 659 out.write("<"); 660 else if (msg == '>') 661 out.write(">"); 662 else if (attribute) { 663 if (msg == '"') 664 out.write("""); 665 else if (msg == '\'') 666 out.write("'"); 667 else if (msg == '\n') 668 out.write("
"); 669 else if (msg == '\t') 670 out.write("	"); 671 else 672 out.write(msg); 673 } 674 else 675 out.write(msg); 676 } 677 678 public static class ValidateException extends Exception { 679 private org.netbeans.modules.schema2beansdev.metadd.CommonBean failedBean; 680 private String failedPropertyName; 681 private FailureType failureType; 682 public ValidateException(String msg, String failedPropertyName, org.netbeans.modules.schema2beansdev.metadd.CommonBean failedBean) { 683 super(msg); 684 this.failedBean = failedBean; 685 this.failedPropertyName = failedPropertyName; 686 } 687 public ValidateException(String msg, FailureType ft, String failedPropertyName, org.netbeans.modules.schema2beansdev.metadd.CommonBean failedBean) { 688 super(msg); 689 this.failureType = ft; 690 this.failedBean = failedBean; 691 this.failedPropertyName = failedPropertyName; 692 } 693 public String getFailedPropertyName() {return failedPropertyName;} 694 public FailureType getFailureType() {return failureType;} 695 public org.netbeans.modules.schema2beansdev.metadd.CommonBean getFailedBean() {return failedBean;} 696 public static class FailureType { 697 private final String name; 698 private FailureType(String name) {this.name = name;} 699 public String toString() { return name;} 700 public static final FailureType NULL_VALUE = new FailureType("NULL_VALUE"); 701 public static final FailureType DATA_RESTRICTION = new FailureType("DATA_RESTRICTION"); 702 public static final FailureType ENUM_RESTRICTION = new FailureType("ENUM_RESTRICTION"); 703 public static final FailureType ALL_RESTRICTIONS = new FailureType("ALL_RESTRICTIONS"); 704 public static final FailureType MUTUALLY_EXCLUSIVE = new FailureType("MUTUALLY_EXCLUSIVE"); 705 } 706 } 707 708 public void validate() throws org.netbeans.modules.schema2beansdev.metadd.MetaDD.ValidateException { 709 boolean restrictionFailure = false; 710 boolean restrictionPassed = false; 711 for (int _index = 0; _index < sizeMetaElement(); ++_index) { 713 org.netbeans.modules.schema2beansdev.metadd.MetaElement element = getMetaElement(_index); 714 if (element != null) { 715 element.validate(); 716 } 717 } 718 } 726 727 public void changePropertyByName(String name, Object value) { 728 if (name == null) return; 729 name = name.intern(); 730 if (name == "metaElement") 731 addMetaElement((MetaElement)value); 732 else if (name == "metaElement[]") 733 setMetaElement((MetaElement[]) value); 734 else if (name == "implements") 735 setImplements((String )value); 736 else if (name == "extends") 737 setExtends((String )value); 738 else if (name == "import") 739 addImport((String )value); 740 else if (name == "import[]") 741 setImport((String []) value); 742 else if (name == "vetoable") 743 setVetoable(((java.lang.Boolean )value).booleanValue()); 744 else if (name == "throwExceptions") 745 setThrowExceptions(((java.lang.Boolean )value).booleanValue()); 746 else if (name == "schemaLocation") 747 setSchemaLocation((String )value); 748 else if (name == "finder") 749 addFinder((String )value); 750 else if (name == "finder[]") 751 setFinder((String []) value); 752 else 753 throw new IllegalArgumentException (name+" is not a valid property name for MetaDD"); 754 } 755 756 public Object fetchPropertyByName(String name) { 757 if (name == "metaElement[]") 758 return getMetaElement(); 759 if (name == "implements") 760 return getImplements(); 761 if (name == "extends") 762 return getExtends(); 763 if (name == "import[]") 764 return getImport(); 765 if (name == "vetoable") 766 return (isVetoable() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); 767 if (name == "throwExceptions") 768 return (isThrowExceptions() ? java.lang.Boolean.TRUE : java.lang.Boolean.FALSE); 769 if (name == "schemaLocation") 770 return getSchemaLocation(); 771 if (name == "finder[]") 772 return getFinder(); 773 throw new IllegalArgumentException (name+" is not a valid property name for MetaDD"); 774 } 775 776 public String nameSelf() { 777 return "/MetaDD"; 778 } 779 780 public String nameChild(Object childObj) { 781 return nameChild(childObj, false, false); 782 } 783 784 789 public String nameChild(Object childObj, boolean returnConstName, boolean returnSchemaName) { 790 return nameChild(childObj, returnConstName, returnSchemaName, false); 791 } 792 793 798 public String nameChild(Object childObj, boolean returnConstName, boolean returnSchemaName, boolean returnXPathName) { 799 if (childObj instanceof java.lang.String ) { 800 java.lang.String child = (java.lang.String ) childObj; 801 if (child == _Implements) { 802 if (returnConstName) { 803 return IMPLEMENTS; 804 } else if (returnSchemaName) { 805 return "implements"; 806 } else if (returnXPathName) { 807 return "implements"; 808 } else { 809 return "Implements"; 810 } 811 } 812 if (child == _Extends) { 813 if (returnConstName) { 814 return EXTENDS; 815 } else if (returnSchemaName) { 816 return "extends"; 817 } else if (returnXPathName) { 818 return "extends"; 819 } else { 820 return "Extends"; 821 } 822 } 823 int index = 0; 824 for (java.util.Iterator it = _Import.iterator(); it.hasNext(); 825 ) { 826 String element = (String )it.next(); 827 if (child == element) { 828 if (returnConstName) { 829 return IMPORT; 830 } else if (returnSchemaName) { 831 return "import"; 832 } else if (returnXPathName) { 833 return "import[position()="+index+"]"; 834 } else { 835 return "Import."+Integer.toHexString(index); 836 } 837 } 838 ++index; 839 } 840 if (child == _SchemaLocation) { 841 if (returnConstName) { 842 return SCHEMALOCATION; 843 } else if (returnSchemaName) { 844 return "schemaLocation"; 845 } else if (returnXPathName) { 846 return "schemaLocation"; 847 } else { 848 return "SchemaLocation"; 849 } 850 } 851 index = 0; 852 for (java.util.Iterator it = _Finder.iterator(); it.hasNext(); 853 ) { 854 String element = (String )it.next(); 855 if (child == element) { 856 if (returnConstName) { 857 return FINDER; 858 } else if (returnSchemaName) { 859 return "finder"; 860 } else if (returnXPathName) { 861 return "finder[position()="+index+"]"; 862 } else { 863 return "Finder."+Integer.toHexString(index); 864 } 865 } 866 ++index; 867 } 868 } 869 if (childObj instanceof MetaElement) { 870 MetaElement child = (MetaElement) childObj; 871 int index = 0; 872 for (java.util.Iterator it = _MetaElement.iterator(); 873 it.hasNext(); ) { 874 org.netbeans.modules.schema2beansdev.metadd.MetaElement element = (org.netbeans.modules.schema2beansdev.metadd.MetaElement)it.next(); 875 if (child == element) { 876 if (returnConstName) { 877 return META_ELEMENT; 878 } else if (returnSchemaName) { 879 return "meta-element"; 880 } else if (returnXPathName) { 881 return "meta-element[position()="+index+"]"; 882 } else { 883 return "MetaElement."+Integer.toHexString(index); 884 } 885 } 886 ++index; 887 } 888 } 889 if (childObj instanceof java.lang.Boolean ) { 890 java.lang.Boolean child = (java.lang.Boolean ) childObj; 891 if (((java.lang.Boolean )child).booleanValue() == _Vetoable) { 892 if (returnConstName) { 893 return VETOABLE; 894 } else if (returnSchemaName) { 895 return "vetoable"; 896 } else if (returnXPathName) { 897 return "vetoable"; 898 } else { 899 return "Vetoable"; 900 } 901 } 902 if (((java.lang.Boolean )child).booleanValue() == _ThrowExceptions) { 903 if (returnConstName) { 904 return THROW_EXCEPTIONS; 905 } else if (returnSchemaName) { 906 return "throw-exceptions"; 907 } else if (returnXPathName) { 908 return "throw-exceptions"; 909 } else { 910 return "ThrowExceptions"; 911 } 912 } 913 } 914 return null; 915 } 916 917 920 public org.netbeans.modules.schema2beansdev.metadd.CommonBean[] childBeans(boolean recursive) { 921 java.util.List children = new java.util.LinkedList (); 922 childBeans(recursive, children); 923 org.netbeans.modules.schema2beansdev.metadd.CommonBean[] result = new org.netbeans.modules.schema2beansdev.metadd.CommonBean[children.size()]; 924 return (org.netbeans.modules.schema2beansdev.metadd.CommonBean[]) children.toArray(result); 925 } 926 927 930 public void childBeans(boolean recursive, java.util.List beans) { 931 for (java.util.Iterator it = _MetaElement.iterator(); 932 it.hasNext(); ) { 933 org.netbeans.modules.schema2beansdev.metadd.MetaElement element = (org.netbeans.modules.schema2beansdev.metadd.MetaElement)it.next(); 934 if (element != null) { 935 if (recursive) { 936 element.childBeans(true, beans); 937 } 938 beans.add(element); 939 } 940 } 941 } 942 943 public boolean equals(Object o) { 944 return o instanceof org.netbeans.modules.schema2beansdev.metadd.MetaDD && equals((org.netbeans.modules.schema2beansdev.metadd.MetaDD) o); 945 } 946 947 public boolean equals(org.netbeans.modules.schema2beansdev.metadd.MetaDD inst) { 948 if (inst == this) { 949 return true; 950 } 951 if (inst == null) { 952 return false; 953 } 954 if (sizeMetaElement() != inst.sizeMetaElement()) 955 return false; 956 for (java.util.Iterator it = _MetaElement.iterator(), it2 = inst._MetaElement.iterator(); 958 it.hasNext() && it2.hasNext(); ) { 959 org.netbeans.modules.schema2beansdev.metadd.MetaElement element = (org.netbeans.modules.schema2beansdev.metadd.MetaElement)it.next(); 960 org.netbeans.modules.schema2beansdev.metadd.MetaElement element2 = (org.netbeans.modules.schema2beansdev.metadd.MetaElement)it2.next(); 961 if (!(element == null ? element2 == null : element.equals(element2))) { 962 return false; 963 } 964 } 965 if (!(_Implements == null ? inst._Implements == null : _Implements.equals(inst._Implements))) { 966 return false; 967 } 968 if (!(_Extends == null ? inst._Extends == null : _Extends.equals(inst._Extends))) { 969 return false; 970 } 971 if (sizeImport() != inst.sizeImport()) 972 return false; 973 for (java.util.Iterator it = _Import.iterator(), it2 = inst._Import.iterator(); 975 it.hasNext() && it2.hasNext(); ) { 976 String element = (String )it.next(); 977 String element2 = (String )it2.next(); 978 if (!(element == null ? element2 == null : element.equals(element2))) { 979 return false; 980 } 981 } 982 if (_isSet_Vetoable != inst._isSet_Vetoable) { 983 return false; 984 } 985 if (_isSet_Vetoable) { 986 if (!(_Vetoable == inst._Vetoable)) { 987 return false; 988 } 989 } 990 if (_isSet_ThrowExceptions != inst._isSet_ThrowExceptions) { 991 return false; 992 } 993 if (_isSet_ThrowExceptions) { 994 if (!(_ThrowExceptions == inst._ThrowExceptions)) { 995 return false; 996 } 997 } 998 if (!(_SchemaLocation == null ? inst._SchemaLocation == null : _SchemaLocation.equals(inst._SchemaLocation))) { 999 return false; 1000 } 1001 if (sizeFinder() != inst.sizeFinder()) 1002 return false; 1003 for (java.util.Iterator it = _Finder.iterator(), it2 = inst._Finder.iterator(); 1005 it.hasNext() && it2.hasNext(); ) { 1006 String element = (String )it.next(); 1007 String element2 = (String )it2.next(); 1008 if (!(element == null ? element2 == null : element.equals(element2))) { 1009 return false; 1010 } 1011 } 1012 return true; 1013 } 1014 1015 public int hashCode() { 1016 int result = 17; 1017 result = 37*result + (_MetaElement == null ? 0 : _MetaElement.hashCode()); 1018 result = 37*result + (_Implements == null ? 0 : _Implements.hashCode()); 1019 result = 37*result + (_Extends == null ? 0 : _Extends.hashCode()); 1020 result = 37*result + (_Import == null ? 0 : _Import.hashCode()); 1021 result = 37*result + (_isSet_Vetoable ? 0 : (_Vetoable ? 0 : 1)); 1022 result = 37*result + (_isSet_ThrowExceptions ? 0 : (_ThrowExceptions ? 0 : 1)); 1023 result = 37*result + (_SchemaLocation == null ? 0 : _SchemaLocation.hashCode()); 1024 result = 37*result + (_Finder == null ? 0 : _Finder.hashCode()); 1025 return result; 1026 } 1027 1028 public String toString() { 1029 java.io.StringWriter sw = new java.io.StringWriter (); 1030 try { 1031 writeNode(sw); 1032 } catch (java.io.IOException e) { 1033 throw new RuntimeException (e); 1035 } 1036 return sw.toString(); 1037 } 1038 1039} 1040 1041 1042 1132 | Popular Tags |