1 /* 2 * reserved comment block 3 * DO NOT REMOVE OR ALTER! 4 */ 5 /* 6 * Licensed to the Apache Software Foundation (ASF) under one or more 7 * contributor license agreements. See the NOTICE file distributed with 8 * this work for additional information regarding copyright ownership. 9 * The ASF licenses this file to You under the Apache License, Version 2.0 10 * (the "License"); you may not use this file except in compliance with 11 * the License. You may obtain a copy of the License at 12 * 13 * http://www.apache.org/licenses/LICENSE-2.0 14 * 15 * Unless required by applicable law or agreed to in writing, software 16 * distributed under the License is distributed on an "AS IS" BASIS, 17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 * See the License for the specific language governing permissions and 19 * limitations under the License. 20 */ 21 /* 22 * $Id: UnImplNode.java,v 23 */ 24 25 package com.sun.org.apache.xml.internal.utils; 26 27 import com.sun.org.apache.xml.internal.res.XMLErrorResources; 28 import com.sun.org.apache.xml.internal.res.XMLMessages; 29 30 import org.w3c.dom.Attr; 31 import org.w3c.dom.CDATASection; 32 import org.w3c.dom.Comment; 33 import org.w3c.dom.DOMException; 34 import org.w3c.dom.DOMImplementation; 35 import org.w3c.dom.Document; 36 import org.w3c.dom.DocumentFragment; 37 import org.w3c.dom.DocumentType; 38 import org.w3c.dom.Element; 39 import org.w3c.dom.EntityReference; 40 import org.w3c.dom.NamedNodeMap; 41 import org.w3c.dom.Node; 42 import org.w3c.dom.NodeList; 43 import org.w3c.dom.ProcessingInstruction; 44 import org.w3c.dom.Text; 45 46 import org.w3c.dom.UserDataHandler; 47 import org.w3c.dom.DOMConfiguration; 48 import org.w3c.dom.TypeInfo; 49 /** 50 * <meta name="usage" content="internal"/> 51 * To be subclassed by classes that wish to fake being nodes. 52 */ 53 public class UnImplNode implements Node, Element, NodeList, Document 54 { 55 56 /** 57 * Constructor UnImplNode 58 * 59 */ UnImplNode()60 public UnImplNode(){} 61 62 /** 63 * Throw an error. 64 * 65 * @param msg Message Key for the error 66 */ error(String msg)67 public void error(String msg) 68 { 69 70 System.out.println("DOM ERROR! class: " + this.getClass().getName()); 71 72 throw new RuntimeException(XMLMessages.createXMLMessage(msg, null)); 73 } 74 75 /** 76 * Throw an error. 77 * 78 * @param msg Message Key for the error 79 * @param args Array of arguments to be used in the error message 80 */ error(String msg, Object[] args)81 public void error(String msg, Object[] args) 82 { 83 84 System.out.println("DOM ERROR! class: " + this.getClass().getName()); 85 86 throw new RuntimeException(XMLMessages.createXMLMessage(msg, args)); //"UnImplNode error: "+msg); 87 } 88 89 /** 90 * Unimplemented. See org.w3c.dom.Node 91 * 92 * @param newChild New node to append to the list of this node's children 93 * 94 * @return null 95 * 96 * @throws DOMException 97 */ appendChild(Node newChild)98 public Node appendChild(Node newChild) throws DOMException 99 { 100 101 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"appendChild not supported!"); 102 103 return null; 104 } 105 106 /** 107 * Unimplemented. See org.w3c.dom.Node 108 * 109 * @return false 110 */ hasChildNodes()111 public boolean hasChildNodes() 112 { 113 114 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"hasChildNodes not supported!"); 115 116 return false; 117 } 118 119 /** 120 * Unimplemented. See org.w3c.dom.Node 121 * 122 * @return 0 123 */ getNodeType()124 public short getNodeType() 125 { 126 127 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getNodeType not supported!"); 128 129 return 0; 130 } 131 132 /** 133 * Unimplemented. See org.w3c.dom.Node 134 * 135 * @return null 136 */ getParentNode()137 public Node getParentNode() 138 { 139 140 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getParentNode not supported!"); 141 142 return null; 143 } 144 145 /** 146 * Unimplemented. See org.w3c.dom.Node 147 * 148 * @return null 149 */ getChildNodes()150 public NodeList getChildNodes() 151 { 152 153 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getChildNodes not supported!"); 154 155 return null; 156 } 157 158 /** 159 * Unimplemented. See org.w3c.dom.Node 160 * 161 * @return null 162 */ getFirstChild()163 public Node getFirstChild() 164 { 165 166 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getFirstChild not supported!"); 167 168 return null; 169 } 170 171 /** 172 * Unimplemented. See org.w3c.dom.Node 173 * 174 * @return null 175 */ getLastChild()176 public Node getLastChild() 177 { 178 179 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getLastChild not supported!"); 180 181 return null; 182 } 183 184 /** 185 * Unimplemented. See org.w3c.dom.Node 186 * 187 * @return null 188 */ getNextSibling()189 public Node getNextSibling() 190 { 191 192 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getNextSibling not supported!"); 193 194 return null; 195 } 196 197 /** 198 * Unimplemented. See org.w3c.dom.NodeList 199 * 200 * @return 0 201 */ getLength()202 public int getLength() 203 { 204 205 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getLength not supported!"); 206 207 return 0; 208 } // getLength():int 209 210 /** 211 * Unimplemented. See org.w3c.dom.NodeList 212 * 213 * @param index index of a child of this node in its list of children 214 * 215 * @return null 216 */ item(int index)217 public Node item(int index) 218 { 219 220 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"item not supported!"); 221 222 return null; 223 } // item(int):Node 224 225 /** 226 * Unimplemented. See org.w3c.dom.Node 227 * 228 * @return null 229 */ getOwnerDocument()230 public Document getOwnerDocument() 231 { 232 233 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getOwnerDocument not supported!"); 234 235 return null; 236 } 237 238 /** 239 * Unimplemented. See org.w3c.dom.Node 240 * 241 * @return null 242 */ getTagName()243 public String getTagName() 244 { 245 246 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getTagName not supported!"); 247 248 return null; 249 } 250 251 /** 252 * Unimplemented. See org.w3c.dom.Node 253 * 254 * @return null 255 */ getNodeName()256 public String getNodeName() 257 { 258 259 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getNodeName not supported!"); 260 261 return null; 262 } 263 264 /** Unimplemented. See org.w3c.dom.Node */ normalize()265 public void normalize() 266 { 267 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"normalize not supported!"); 268 } 269 270 /** 271 * Unimplemented. See org.w3c.dom.Element 272 * 273 * @param name Name of the element 274 * 275 * @return null 276 */ getElementsByTagName(String name)277 public NodeList getElementsByTagName(String name) 278 { 279 280 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getElementsByTagName not supported!"); 281 282 return null; 283 } 284 285 /** 286 * Unimplemented. See org.w3c.dom.Element 287 * 288 * @param oldAttr Attribute to be removed from this node's list of attributes 289 * 290 * @return null 291 * 292 * @throws DOMException 293 */ removeAttributeNode(Attr oldAttr)294 public Attr removeAttributeNode(Attr oldAttr) throws DOMException 295 { 296 297 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"removeAttributeNode not supported!"); 298 299 return null; 300 } 301 302 /** 303 * Unimplemented. See org.w3c.dom.Element 304 * 305 * @param newAttr Attribute node to be added to this node's list of attributes 306 * 307 * @return null 308 * 309 * @throws DOMException 310 */ setAttributeNode(Attr newAttr)311 public Attr setAttributeNode(Attr newAttr) throws DOMException 312 { 313 314 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setAttributeNode not supported!"); 315 316 return null; 317 } 318 319 /** 320 * Unimplemented. See org.w3c.dom.Element 321 * 322 * 323 * @param name Name of an attribute 324 * 325 * @return false 326 */ hasAttribute(String name)327 public boolean hasAttribute(String name) 328 { 329 330 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"hasAttribute not supported!"); 331 332 return false; 333 } 334 335 /** 336 * Unimplemented. See org.w3c.dom.Element 337 * 338 * 339 * @param name 340 * @param x 341 * 342 * @return false 343 */ hasAttributeNS(String name, String x)344 public boolean hasAttributeNS(String name, String x) 345 { 346 347 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"hasAttributeNS not supported!"); 348 349 return false; 350 } 351 352 /** 353 * Unimplemented. See org.w3c.dom.Element 354 * 355 * 356 * @param name Attribute node name 357 * 358 * @return null 359 */ getAttributeNode(String name)360 public Attr getAttributeNode(String name) 361 { 362 363 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getAttributeNode not supported!"); 364 365 return null; 366 } 367 368 /** 369 * Unimplemented. See org.w3c.dom.Element 370 * 371 * @param name Attribute node name to remove from list of attributes 372 * 373 * @throws DOMException 374 */ removeAttribute(String name)375 public void removeAttribute(String name) throws DOMException 376 { 377 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"removeAttribute not supported!"); 378 } 379 380 /** 381 * Unimplemented. See org.w3c.dom.Element 382 * 383 * @param name Name of attribute to set 384 * @param value Value of attribute 385 * 386 * @throws DOMException 387 */ setAttribute(String name, String value)388 public void setAttribute(String name, String value) throws DOMException 389 { 390 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setAttribute not supported!"); 391 } 392 393 /** 394 * Unimplemented. See org.w3c.dom.Element 395 * 396 * @param name Name of attribute to get 397 * 398 * @return null 399 */ getAttribute(String name)400 public String getAttribute(String name) 401 { 402 403 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getAttribute not supported!"); 404 405 return null; 406 } 407 408 /** 409 * Unimplemented. Introduced in DOM Level 2. 410 * 411 * @return false 412 */ hasAttributes()413 public boolean hasAttributes() 414 { 415 416 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"hasAttributes not supported!"); 417 418 return false; 419 } 420 421 /** 422 * Unimplemented. See org.w3c.dom.Element 423 * 424 * @param namespaceURI Namespace URI of the element 425 * @param localName Local part of qualified name of the element 426 * 427 * @return null 428 */ getElementsByTagNameNS(String namespaceURI, String localName)429 public NodeList getElementsByTagNameNS(String namespaceURI, 430 String localName) 431 { 432 433 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getElementsByTagNameNS not supported!"); 434 435 return null; 436 } 437 438 /** 439 * Unimplemented. See org.w3c.dom.Element 440 * 441 * @param newAttr Attribute to set 442 * 443 * @return null 444 * 445 * @throws DOMException 446 */ setAttributeNodeNS(Attr newAttr)447 public Attr setAttributeNodeNS(Attr newAttr) throws DOMException 448 { 449 450 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setAttributeNodeNS not supported!"); 451 452 return null; 453 } 454 455 /** 456 * Unimplemented. See org.w3c.dom.Element 457 * 458 * @param namespaceURI Namespace URI of attribute node to get 459 * @param localName Local part of qualified name of attribute node to get 460 * 461 * @return null 462 */ getAttributeNodeNS(String namespaceURI, String localName)463 public Attr getAttributeNodeNS(String namespaceURI, String localName) 464 { 465 466 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getAttributeNodeNS not supported!"); 467 468 return null; 469 } 470 471 /** 472 * Unimplemented. See org.w3c.dom.Element 473 * 474 * @param namespaceURI Namespace URI of attribute node to remove 475 * @param localName Local part of qualified name of attribute node to remove 476 * 477 * @throws DOMException 478 */ removeAttributeNS(String namespaceURI, String localName)479 public void removeAttributeNS(String namespaceURI, String localName) 480 throws DOMException 481 { 482 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"removeAttributeNS not supported!"); 483 } 484 485 /** 486 * Unimplemented. See org.w3c.dom.Element 487 * 488 * @param namespaceURI Namespace URI of attribute node to set 489 * @param qualifiedName qualified name of attribute 490 * @param value value of attribute 491 * 492 * @throws DOMException 493 */ setAttributeNS( String namespaceURI, String qualifiedName, String value)494 public void setAttributeNS( 495 String namespaceURI, String qualifiedName, String value) 496 throws DOMException 497 { 498 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setAttributeNS not supported!"); 499 } 500 501 /** 502 * Unimplemented. See org.w3c.dom.Element 503 * 504 * @param namespaceURI Namespace URI of attribute node to get 505 * @param localName Local part of qualified name of attribute node to get 506 * 507 * @return null 508 */ getAttributeNS(String namespaceURI, String localName)509 public String getAttributeNS(String namespaceURI, String localName) 510 { 511 512 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getAttributeNS not supported!"); 513 514 return null; 515 } 516 517 /** 518 * Unimplemented. See org.w3c.dom.Node 519 * 520 * @return null 521 */ getPreviousSibling()522 public Node getPreviousSibling() 523 { 524 525 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getPreviousSibling not supported!"); 526 527 return null; 528 } 529 530 /** 531 * Unimplemented. See org.w3c.dom.Node 532 * 533 * @param deep Flag indicating whether to clone deep (clone member variables) 534 * 535 * @return null 536 */ cloneNode(boolean deep)537 public Node cloneNode(boolean deep) 538 { 539 540 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"cloneNode not supported!"); 541 542 return null; 543 } 544 545 /** 546 * Unimplemented. See org.w3c.dom.Node 547 * 548 * @return null 549 * 550 * @throws DOMException 551 */ getNodeValue()552 public String getNodeValue() throws DOMException 553 { 554 555 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getNodeValue not supported!"); 556 557 return null; 558 } 559 560 /** 561 * Unimplemented. See org.w3c.dom.Node 562 * 563 * @param nodeValue Value to set this node to 564 * 565 * @throws DOMException 566 */ setNodeValue(String nodeValue)567 public void setNodeValue(String nodeValue) throws DOMException 568 { 569 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setNodeValue not supported!"); 570 } 571 572 /** 573 * Unimplemented. See org.w3c.dom.Node 574 * 575 * 576 * NEEDSDOC @param value 577 * @return value Node value 578 * 579 * @throws DOMException 580 */ 581 582 // public String getValue () 583 // { 584 // error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getValue not supported!"); 585 // return null; 586 // } 587 588 /** 589 * Unimplemented. See org.w3c.dom.Node 590 * 591 * @param value Value to set this node to 592 * 593 * @throws DOMException 594 */ setValue(String value)595 public void setValue(String value) throws DOMException 596 { 597 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setValue not supported!"); 598 } 599 600 /** 601 * Returns the name of this attribute. 602 * 603 * @return the name of this attribute. 604 */ 605 606 // public String getName() 607 // { 608 // return this.getNodeName(); 609 // } 610 611 /** 612 * Unimplemented. See org.w3c.dom.Node 613 * 614 * @return null 615 */ getOwnerElement()616 public Element getOwnerElement() 617 { 618 619 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getOwnerElement not supported!"); 620 621 return null; 622 } 623 624 /** 625 * Unimplemented. See org.w3c.dom.Node 626 * 627 * @return False 628 */ getSpecified()629 public boolean getSpecified() 630 { 631 632 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setValue not supported!"); 633 634 return false; 635 } 636 637 /** 638 * Unimplemented. See org.w3c.dom.Node 639 * 640 * @return null 641 */ getAttributes()642 public NamedNodeMap getAttributes() 643 { 644 645 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getAttributes not supported!"); 646 647 return null; 648 } 649 650 /** 651 * Unimplemented. See org.w3c.dom.Node 652 * 653 * @param newChild New child node to insert 654 * @param refChild Insert in front of this child 655 * 656 * @return null 657 * 658 * @throws DOMException 659 */ insertBefore(Node newChild, Node refChild)660 public Node insertBefore(Node newChild, Node refChild) throws DOMException 661 { 662 663 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"insertBefore not supported!"); 664 665 return null; 666 } 667 668 /** 669 * Unimplemented. See org.w3c.dom.Node 670 * 671 * @param newChild Replace existing child with this one 672 * @param oldChild Existing child to be replaced 673 * 674 * @return null 675 * 676 * @throws DOMException 677 */ replaceChild(Node newChild, Node oldChild)678 public Node replaceChild(Node newChild, Node oldChild) throws DOMException 679 { 680 681 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"replaceChild not supported!"); 682 683 return null; 684 } 685 686 /** 687 * Unimplemented. See org.w3c.dom.Node 688 * 689 * @param oldChild Child to be removed 690 * 691 * @return null 692 * 693 * @throws DOMException 694 */ removeChild(Node oldChild)695 public Node removeChild(Node oldChild) throws DOMException 696 { 697 698 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"replaceChild not supported!"); 699 700 return null; 701 } 702 703 /** 704 * Tests whether the DOM implementation implements a specific feature and 705 * that feature is supported by this node. 706 * @param feature The name of the feature to test. This is the same name 707 * which can be passed to the method <code>hasFeature</code> on 708 * <code>DOMImplementation</code>. 709 * @param version This is the version number of the feature to test. In 710 * Level 2, version 1, this is the string "2.0". If the version is not 711 * specified, supporting any version of the feature will cause the 712 * method to return <code>true</code>. 713 * 714 * @return Returns <code>false</code> 715 * @since DOM Level 2 716 */ isSupported(String feature, String version)717 public boolean isSupported(String feature, String version) 718 { 719 return false; 720 } 721 722 /** 723 * Unimplemented. See org.w3c.dom.Node 724 * 725 * @return null 726 */ getNamespaceURI()727 public String getNamespaceURI() 728 { 729 730 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getNamespaceURI not supported!"); 731 732 return null; 733 } 734 735 /** 736 * Unimplemented. See org.w3c.dom.Node 737 * 738 * @return null 739 */ getPrefix()740 public String getPrefix() 741 { 742 743 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getPrefix not supported!"); 744 745 return null; 746 } 747 748 /** 749 * Unimplemented. See org.w3c.dom.Node 750 * 751 * @param prefix Prefix to set for this node 752 * 753 * @throws DOMException 754 */ setPrefix(String prefix)755 public void setPrefix(String prefix) throws DOMException 756 { 757 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"setPrefix not supported!"); 758 } 759 760 /** 761 * Unimplemented. See org.w3c.dom.Node 762 * 763 * @return null 764 */ getLocalName()765 public String getLocalName() 766 { 767 768 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); //"getLocalName not supported!"); 769 770 return null; 771 } 772 773 /** 774 * Unimplemented. See org.w3c.dom.Document 775 * 776 * @return null 777 */ getDoctype()778 public DocumentType getDoctype() 779 { 780 781 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 782 783 return null; 784 } 785 786 /** 787 * Unimplemented. See org.w3c.dom.Document 788 * 789 * @return null 790 */ getImplementation()791 public DOMImplementation getImplementation() 792 { 793 794 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 795 796 return null; 797 } 798 799 /** 800 * Unimplemented. See org.w3c.dom.Document 801 * 802 * @return null 803 */ getDocumentElement()804 public Element getDocumentElement() 805 { 806 807 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 808 809 return null; 810 } 811 812 /** 813 * Unimplemented. See org.w3c.dom.Document 814 * 815 * @param tagName Element tag name 816 * 817 * @return null 818 * 819 * @throws DOMException 820 */ createElement(String tagName)821 public Element createElement(String tagName) throws DOMException 822 { 823 824 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 825 826 return null; 827 } 828 829 /** 830 * Unimplemented. See org.w3c.dom.Document 831 * 832 * @return null 833 */ createDocumentFragment()834 public DocumentFragment createDocumentFragment() 835 { 836 837 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 838 839 return null; 840 } 841 842 /** 843 * Unimplemented. See org.w3c.dom.Document 844 * 845 * @param data Data for text node 846 * 847 * @return null 848 */ createTextNode(String data)849 public Text createTextNode(String data) 850 { 851 852 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 853 854 return null; 855 } 856 857 /** 858 * Unimplemented. See org.w3c.dom.Document 859 * 860 * @param data Data for comment 861 * 862 * @return null 863 */ createComment(String data)864 public Comment createComment(String data) 865 { 866 867 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 868 869 return null; 870 } 871 872 /** 873 * Unimplemented. See org.w3c.dom.Document 874 * 875 * @param data Data for CDATA section 876 * 877 * @return null 878 * 879 * @throws DOMException 880 */ createCDATASection(String data)881 public CDATASection createCDATASection(String data) throws DOMException 882 { 883 884 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 885 886 return null; 887 } 888 889 /** 890 * Unimplemented. See org.w3c.dom.Document 891 * 892 * @param target Target for Processing instruction 893 * @param data Data for Processing instruction 894 * 895 * @return null 896 * 897 * @throws DOMException 898 */ createProcessingInstruction( String target, String data)899 public ProcessingInstruction createProcessingInstruction( 900 String target, String data) throws DOMException 901 { 902 903 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 904 905 return null; 906 } 907 908 /** 909 * Unimplemented. See org.w3c.dom.Document 910 * 911 * @param name Attribute name 912 * 913 * @return null 914 * 915 * @throws DOMException 916 */ createAttribute(String name)917 public Attr createAttribute(String name) throws DOMException 918 { 919 920 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 921 922 return null; 923 } 924 925 /** 926 * Unimplemented. See org.w3c.dom.Document 927 * 928 * @param name Entity Reference name 929 * 930 * @return null 931 * 932 * @throws DOMException 933 */ createEntityReference(String name)934 public EntityReference createEntityReference(String name) 935 throws DOMException 936 { 937 938 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 939 940 return null; 941 } 942 943 /** 944 * Unimplemented. See org.w3c.dom.Document 945 * 946 * @param importedNode The node to import. 947 * @param deep If <code>true</code>, recursively import the subtree under 948 * the specified node; if <code>false</code>, import only the node 949 * itself, as explained above. This has no effect on <code>Attr</code> 950 * , <code>EntityReference</code>, and <code>Notation</code> nodes. 951 * 952 * @return null 953 * 954 * @throws DOMException 955 */ importNode(Node importedNode, boolean deep)956 public Node importNode(Node importedNode, boolean deep) throws DOMException 957 { 958 959 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 960 961 return null; 962 } 963 964 /** 965 * Unimplemented. See org.w3c.dom.Document 966 * 967 * @param namespaceURI Namespace URI for the element 968 * @param qualifiedName Qualified name of the element 969 * 970 * @return null 971 * 972 * @throws DOMException 973 */ createElementNS(String namespaceURI, String qualifiedName)974 public Element createElementNS(String namespaceURI, String qualifiedName) 975 throws DOMException 976 { 977 978 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 979 980 return null; 981 } 982 983 /** 984 * Unimplemented. See org.w3c.dom.Document 985 * 986 * @param namespaceURI Namespace URI of the attribute 987 * @param qualifiedName Qualified name of the attribute 988 * 989 * @return null 990 * 991 * @throws DOMException 992 */ createAttributeNS(String namespaceURI, String qualifiedName)993 public Attr createAttributeNS(String namespaceURI, String qualifiedName) 994 throws DOMException 995 { 996 997 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 998 999 return null; 1000 } 1001 1002 /** 1003 * Unimplemented. See org.w3c.dom.Document 1004 * 1005 * @param elementId ID of the element to get 1006 * 1007 * @return null 1008 */ getElementById(String elementId)1009 public Element getElementById(String elementId) 1010 { 1011 1012 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1013 1014 return null; 1015 } 1016 1017 /** 1018 * Set Node data 1019 * 1020 * 1021 * @param data data to set for this node 1022 * 1023 * @throws DOMException 1024 */ setData(String data)1025 public void setData(String data) throws DOMException 1026 { 1027 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1028 } 1029 1030 /** 1031 * Unimplemented. 1032 * 1033 * @param offset Start offset of substring to extract. 1034 * @param count The length of the substring to extract. 1035 * 1036 * @return null 1037 * 1038 * @throws DOMException 1039 */ substringData(int offset, int count)1040 public String substringData(int offset, int count) throws DOMException 1041 { 1042 1043 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1044 1045 return null; 1046 } 1047 1048 /** 1049 * Unimplemented. 1050 * 1051 * @param arg String data to append 1052 * 1053 * @throws DOMException 1054 */ appendData(String arg)1055 public void appendData(String arg) throws DOMException 1056 { 1057 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1058 } 1059 1060 /** 1061 * Unimplemented. 1062 * 1063 * @param offset Start offset of substring to insert. 1064 * @param arg The (sub)string to insert. 1065 * 1066 * @throws DOMException 1067 */ insertData(int offset, String arg)1068 public void insertData(int offset, String arg) throws DOMException 1069 { 1070 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1071 } 1072 1073 /** 1074 * Unimplemented. 1075 * 1076 * @param offset Start offset of substring to delete. 1077 * @param count The length of the substring to delete. 1078 * 1079 * @throws DOMException 1080 */ deleteData(int offset, int count)1081 public void deleteData(int offset, int count) throws DOMException 1082 { 1083 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1084 } 1085 1086 /** 1087 * Unimplemented. 1088 * 1089 * @param offset Start offset of substring to replace. 1090 * @param count The length of the substring to replace. 1091 * @param arg substring to replace with 1092 * 1093 * @throws DOMException 1094 */ replaceData(int offset, int count, String arg)1095 public void replaceData(int offset, int count, String arg) 1096 throws DOMException 1097 { 1098 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1099 } 1100 1101 /** 1102 * Unimplemented. 1103 * 1104 * @param offset Offset into text to split 1105 * 1106 * @return null, unimplemented 1107 * 1108 * @throws DOMException 1109 */ splitText(int offset)1110 public Text splitText(int offset) throws DOMException 1111 { 1112 1113 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1114 1115 return null; 1116 } 1117 1118 /** 1119 * NEEDSDOC Method adoptNode 1120 * 1121 * 1122 * NEEDSDOC @param source 1123 * 1124 * NEEDSDOC (adoptNode) @return 1125 * 1126 * @throws DOMException 1127 */ adoptNode(Node source)1128 public Node adoptNode(Node source) throws DOMException 1129 { 1130 1131 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1132 1133 return null; 1134 } 1135 1136 /** 1137 * <p>EXPERIMENTAL! Based on the <a 1138 * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document 1139 * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>. 1140 * <p> 1141 * An attribute specifying, as part of the XML declaration, the encoding 1142 * of this document. This is <code>null</code> when unspecified. 1143 * @since DOM Level 3 1144 * 1145 * NEEDSDOC ($objectName$) @return 1146 */ getInputEncoding()1147 public String getInputEncoding() 1148 { 1149 1150 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1151 1152 return null; 1153 } 1154 1155 /** 1156 * <p>EXPERIMENTAL! Based on the <a 1157 * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document 1158 * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>. 1159 * <p> 1160 * An attribute specifying, as part of the XML declaration, the encoding 1161 * of this document. This is <code>null</code> when unspecified. 1162 * @since DOM Level 3 1163 * 1164 * NEEDSDOC @param encoding 1165 */ setInputEncoding(String encoding)1166 public void setInputEncoding(String encoding) 1167 { 1168 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1169 } 1170 1171 /** 1172 * <p>EXPERIMENTAL! Based on the <a 1173 * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document 1174 * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>. 1175 * <p> 1176 * An attribute specifying, as part of the XML declaration, whether this 1177 * document is standalone. 1178 * @since DOM Level 3 1179 * 1180 * NEEDSDOC ($objectName$) @return 1181 */ getStandalone()1182 public boolean getStandalone() 1183 { 1184 1185 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1186 1187 return false; 1188 } 1189 1190 /** 1191 * <p>EXPERIMENTAL! Based on the <a 1192 * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document 1193 * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>. 1194 * <p> 1195 * An attribute specifying, as part of the XML declaration, whether this 1196 * document is standalone. 1197 * @since DOM Level 3 1198 * 1199 * NEEDSDOC @param standalone 1200 */ setStandalone(boolean standalone)1201 public void setStandalone(boolean standalone) 1202 { 1203 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1204 } 1205 1206 /** 1207 * <p>EXPERIMENTAL! Based on the <a 1208 * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document 1209 * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>. 1210 * <p> 1211 * An attribute specifying whether errors checking is enforced or not. 1212 * When set to <code>false</code>, the implementation is free to not 1213 * test every possible error case normally defined on DOM operations, 1214 * and not raise any <code>DOMException</code>. In case of error, the 1215 * behavior is undefined. This attribute is <code>true</code> by 1216 * defaults. 1217 * @since DOM Level 3 1218 * 1219 * NEEDSDOC ($objectName$) @return 1220 */ getStrictErrorChecking()1221 public boolean getStrictErrorChecking() 1222 { 1223 1224 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1225 1226 return false; 1227 } 1228 1229 /** 1230 * <p>EXPERIMENTAL! Based on the <a 1231 * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document 1232 * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>. 1233 * <p> 1234 * An attribute specifying whether errors checking is enforced or not. 1235 * When set to <code>false</code>, the implementation is free to not 1236 * test every possible error case normally defined on DOM operations, 1237 * and not raise any <code>DOMException</code>. In case of error, the 1238 * behavior is undefined. This attribute is <code>true</code> by 1239 * defaults. 1240 * @since DOM Level 3 1241 * 1242 * NEEDSDOC @param strictErrorChecking 1243 */ setStrictErrorChecking(boolean strictErrorChecking)1244 public void setStrictErrorChecking(boolean strictErrorChecking) 1245 { 1246 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1247 } 1248 1249 /** 1250 * <p>EXPERIMENTAL! Based on the <a 1251 * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document 1252 * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>. 1253 * <p> 1254 * An attribute specifying, as part of the XML declaration, the version 1255 * number of this document. This is <code>null</code> when unspecified. 1256 * @since DOM Level 3 1257 * 1258 * NEEDSDOC ($objectName$) @return 1259 */ getVersion()1260 public String getVersion() 1261 { 1262 1263 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1264 1265 return null; 1266 } 1267 1268 /** 1269 * <p>EXPERIMENTAL! Based on the <a 1270 * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document 1271 * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>. 1272 * <p> 1273 * An attribute specifying, as part of the XML declaration, the version 1274 * number of this document. This is <code>null</code> when unspecified. 1275 * @since DOM Level 3 1276 * 1277 * NEEDSDOC @param version 1278 */ setVersion(String version)1279 public void setVersion(String version) 1280 { 1281 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1282 } 1283 1284 1285 1286 //RAMESH : Pending proper implementation of DOM Level 3 1287 setUserData(String key, Object data, UserDataHandler handler)1288 public Object setUserData(String key, 1289 Object data, 1290 UserDataHandler handler) { 1291 return getOwnerDocument().setUserData( key, data, handler); 1292 } 1293 1294 /** 1295 * Retrieves the object associated to a key on a this node. The object 1296 * must first have been set to this node by calling 1297 * <code>setUserData</code> with the same key. 1298 * @param key The key the object is associated to. 1299 * @return Returns the <code>DOMObject</code> associated to the given key 1300 * on this node, or <code>null</code> if there was none. 1301 * @since DOM Level 3 1302 */ getUserData(String key)1303 public Object getUserData(String key) { 1304 return getOwnerDocument().getUserData( key); 1305 } 1306 1307 /** 1308 * This method returns a specialized object which implements the 1309 * specialized APIs of the specified feature and version. The 1310 * specialized object may also be obtained by using binding-specific 1311 * casting methods but is not necessarily expected to, as discussed in Mixed DOM implementations. 1312 * @param feature The name of the feature requested (case-insensitive). 1313 * @param version This is the version number of the feature to test. If 1314 * the version is <code>null</code> or the empty string, supporting 1315 * any version of the feature will cause the method to return an 1316 * object that supports at least one version of the feature. 1317 * @return Returns an object which implements the specialized APIs of 1318 * the specified feature and version, if any, or <code>null</code> if 1319 * there is no object which implements interfaces associated with that 1320 * feature. If the <code>DOMObject</code> returned by this method 1321 * implements the <code>Node</code> interface, it must delegate to the 1322 * primary core <code>Node</code> and not return results inconsistent 1323 * with the primary core <code>Node</code> such as attributes, 1324 * childNodes, etc. 1325 * @since DOM Level 3 1326 */ getFeature(String feature, String version)1327 public Object getFeature(String feature, String version) { 1328 // we don't have any alternate node, either this node does the job 1329 // or we don't have anything that does 1330 return isSupported(feature, version) ? this : null; 1331 } 1332 1333 /** 1334 * Tests whether two nodes are equal. 1335 * <br>This method tests for equality of nodes, not sameness (i.e., 1336 * whether the two nodes are references to the same object) which can be 1337 * tested with <code>Node.isSameNode</code>. All nodes that are the same 1338 * will also be equal, though the reverse may not be true. 1339 * <br>Two nodes are equal if and only if the following conditions are 1340 * satisfied: The two nodes are of the same type.The following string 1341 * attributes are equal: <code>nodeName</code>, <code>localName</code>, 1342 * <code>namespaceURI</code>, <code>prefix</code>, <code>nodeValue</code> 1343 * , <code>baseURI</code>. This is: they are both <code>null</code>, or 1344 * they have the same length and are character for character identical. 1345 * The <code>attributes</code> <code>NamedNodeMaps</code> are equal. 1346 * This is: they are both <code>null</code>, or they have the same 1347 * length and for each node that exists in one map there is a node that 1348 * exists in the other map and is equal, although not necessarily at the 1349 * same index.The <code>childNodes</code> <code>NodeLists</code> are 1350 * equal. This is: they are both <code>null</code>, or they have the 1351 * same length and contain equal nodes at the same index. This is true 1352 * for <code>Attr</code> nodes as for any other type of node. Note that 1353 * normalization can affect equality; to avoid this, nodes should be 1354 * normalized before being compared. 1355 * <br>For two <code>DocumentType</code> nodes to be equal, the following 1356 * conditions must also be satisfied: The following string attributes 1357 * are equal: <code>publicId</code>, <code>systemId</code>, 1358 * <code>internalSubset</code>.The <code>entities</code> 1359 * <code>NamedNodeMaps</code> are equal.The <code>notations</code> 1360 * <code>NamedNodeMaps</code> are equal. 1361 * <br>On the other hand, the following do not affect equality: the 1362 * <code>ownerDocument</code> attribute, the <code>specified</code> 1363 * attribute for <code>Attr</code> nodes, the 1364 * <code>isWhitespaceInElementContent</code> attribute for 1365 * <code>Text</code> nodes, as well as any user data or event listeners 1366 * registered on the nodes. 1367 * 1368 * @param arg The node to compare equality with. 1369 * @return If the nodes, and possibly subtrees are equal, 1370 * <code>true</code> otherwise <code>false</code>. 1371 * @since DOM Level 3 1372 */ isEqualNode(Node arg)1373 public boolean isEqualNode(Node arg) { 1374 if (arg == this) { 1375 return true; 1376 } 1377 if (arg.getNodeType() != getNodeType()) { 1378 return false; 1379 } 1380 // in theory nodeName can't be null but better be careful 1381 // who knows what other implementations may be doing?... 1382 if (getNodeName() == null) { 1383 if (arg.getNodeName() != null) { 1384 return false; 1385 } 1386 } 1387 else if (!getNodeName().equals(arg.getNodeName())) { 1388 return false; 1389 } 1390 1391 if (getLocalName() == null) { 1392 if (arg.getLocalName() != null) { 1393 return false; 1394 } 1395 } 1396 else if (!getLocalName().equals(arg.getLocalName())) { 1397 return false; 1398 } 1399 1400 if (getNamespaceURI() == null) { 1401 if (arg.getNamespaceURI() != null) { 1402 return false; 1403 } 1404 } 1405 else if (!getNamespaceURI().equals(arg.getNamespaceURI())) { 1406 return false; 1407 } 1408 1409 if (getPrefix() == null) { 1410 if (arg.getPrefix() != null) { 1411 return false; 1412 } 1413 } 1414 else if (!getPrefix().equals(arg.getPrefix())) { 1415 return false; 1416 } 1417 1418 if (getNodeValue() == null) { 1419 if (arg.getNodeValue() != null) { 1420 return false; 1421 } 1422 } 1423 else if (!getNodeValue().equals(arg.getNodeValue())) { 1424 return false; 1425 } 1426 /* 1427 if (getBaseURI() == null) { 1428 if (((NodeImpl) arg).getBaseURI() != null) { 1429 return false; 1430 } 1431 } 1432 else if (!getBaseURI().equals(((NodeImpl) arg).getBaseURI())) { 1433 return false; 1434 } 1435 */ 1436 1437 return true; 1438 } 1439 1440 /** 1441 * DOM Level 3 - Experimental: 1442 * Look up the namespace URI associated to the given prefix, starting from this node. 1443 * Use lookupNamespaceURI(null) to lookup the default namespace 1444 * 1445 * @param namespaceURI 1446 * @return th URI for the namespace 1447 * @since DOM Level 3 1448 */ lookupNamespaceURI(String specifiedPrefix)1449 public String lookupNamespaceURI(String specifiedPrefix) { 1450 short type = this.getNodeType(); 1451 switch (type) { 1452 case Node.ELEMENT_NODE : { 1453 1454 String namespace = this.getNamespaceURI(); 1455 String prefix = this.getPrefix(); 1456 if (namespace !=null) { 1457 // REVISIT: is it possible that prefix is empty string? 1458 if (specifiedPrefix== null && prefix==specifiedPrefix) { 1459 // looking for default namespace 1460 return namespace; 1461 } else if (prefix != null && prefix.equals(specifiedPrefix)) { 1462 // non default namespace 1463 return namespace; 1464 } 1465 } 1466 if (this.hasAttributes()) { 1467 NamedNodeMap map = this.getAttributes(); 1468 int length = map.getLength(); 1469 for (int i=0;i<length;i++) { 1470 Node attr = map.item(i); 1471 String attrPrefix = attr.getPrefix(); 1472 String value = attr.getNodeValue(); 1473 namespace = attr.getNamespaceURI(); 1474 if (namespace !=null && namespace.equals("http://www.w3.org/2000/xmlns/")) { 1475 // at this point we are dealing with DOM Level 2 nodes only 1476 if (specifiedPrefix == null && 1477 attr.getNodeName().equals("xmlns")) { 1478 // default namespace 1479 return value; 1480 } else if (attrPrefix !=null && 1481 attrPrefix.equals("xmlns") && 1482 attr.getLocalName().equals(specifiedPrefix)) { 1483 // non default namespace 1484 return value; 1485 } 1486 } 1487 } 1488 } 1489 /* 1490 NodeImpl ancestor = (NodeImpl)getElementAncestor(this); 1491 if (ancestor != null) { 1492 return ancestor.lookupNamespaceURI(specifiedPrefix); 1493 } 1494 */ 1495 1496 return null; 1497 1498 1499 } 1500 /* 1501 case Node.DOCUMENT_NODE : { 1502 return((NodeImpl)((Document)this).getDocumentElement()).lookupNamespaceURI(specifiedPrefix) ; 1503 } 1504 */ 1505 case Node.ENTITY_NODE : 1506 case Node.NOTATION_NODE: 1507 case Node.DOCUMENT_FRAGMENT_NODE: 1508 case Node.DOCUMENT_TYPE_NODE: 1509 // type is unknown 1510 return null; 1511 case Node.ATTRIBUTE_NODE:{ 1512 if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) { 1513 return getOwnerElement().lookupNamespaceURI(specifiedPrefix); 1514 1515 } 1516 return null; 1517 } 1518 default:{ 1519 /* 1520 NodeImpl ancestor = (NodeImpl)getElementAncestor(this); 1521 if (ancestor != null) { 1522 return ancestor.lookupNamespaceURI(specifiedPrefix); 1523 } 1524 */ 1525 return null; 1526 } 1527 1528 } 1529 } 1530 1531 1532 /** 1533 * DOM Level 3: Experimental 1534 * This method checks if the specified <code>namespaceURI</code> is the 1535 * default namespace or not. 1536 * @param namespaceURI The namespace URI to look for. 1537 * @return <code>true</code> if the specified <code>namespaceURI</code> 1538 * is the default namespace, <code>false</code> otherwise. 1539 * @since DOM Level 3 1540 */ isDefaultNamespace(String namespaceURI)1541 public boolean isDefaultNamespace(String namespaceURI){ 1542 /* 1543 // REVISIT: remove casts when DOM L3 becomes REC. 1544 short type = this.getNodeType(); 1545 switch (type) { 1546 case Node.ELEMENT_NODE: { 1547 String namespace = this.getNamespaceURI(); 1548 String prefix = this.getPrefix(); 1549 1550 // REVISIT: is it possible that prefix is empty string? 1551 if (prefix == null || prefix.length() == 0) { 1552 if (namespaceURI == null) { 1553 return (namespace == namespaceURI); 1554 } 1555 return namespaceURI.equals(namespace); 1556 } 1557 if (this.hasAttributes()) { 1558 ElementImpl elem = (ElementImpl)this; 1559 NodeImpl attr = (NodeImpl)elem.getAttributeNodeNS("http://www.w3.org/2000/xmlns/", "xmlns"); 1560 if (attr != null) { 1561 String value = attr.getNodeValue(); 1562 if (namespaceURI == null) { 1563 return (namespace == value); 1564 } 1565 return namespaceURI.equals(value); 1566 } 1567 } 1568 1569 NodeImpl ancestor = (NodeImpl)getElementAncestor(this); 1570 if (ancestor != null) { 1571 return ancestor.isDefaultNamespace(namespaceURI); 1572 } 1573 return false; 1574 } 1575 case Node.DOCUMENT_NODE:{ 1576 return((NodeImpl)((Document)this).getDocumentElement()).isDefaultNamespace(namespaceURI); 1577 } 1578 1579 case Node.ENTITY_NODE : 1580 case Node.NOTATION_NODE: 1581 case Node.DOCUMENT_FRAGMENT_NODE: 1582 case Node.DOCUMENT_TYPE_NODE: 1583 // type is unknown 1584 return false; 1585 case Node.ATTRIBUTE_NODE:{ 1586 if (this.ownerNode.getNodeType() == Node.ELEMENT_NODE) { 1587 return ownerNode.isDefaultNamespace(namespaceURI); 1588 1589 } 1590 return false; 1591 } 1592 default:{ 1593 NodeImpl ancestor = (NodeImpl)getElementAncestor(this); 1594 if (ancestor != null) { 1595 return ancestor.isDefaultNamespace(namespaceURI); 1596 } 1597 return false; 1598 } 1599 1600 } 1601 */ 1602 return false; 1603 1604 1605 } 1606 1607 /** 1608 * 1609 * DOM Level 3 - Experimental: 1610 * Look up the prefix associated to the given namespace URI, starting from this node. 1611 * 1612 * @param namespaceURI 1613 * @return the prefix for the namespace 1614 */ lookupPrefix(String namespaceURI)1615 public String lookupPrefix(String namespaceURI){ 1616 1617 // REVISIT: When Namespaces 1.1 comes out this may not be true 1618 // Prefix can't be bound to null namespace 1619 if (namespaceURI == null) { 1620 return null; 1621 } 1622 1623 short type = this.getNodeType(); 1624 1625 switch (type) { 1626 /* 1627 case Node.ELEMENT_NODE: { 1628 1629 String namespace = this.getNamespaceURI(); // to flip out children 1630 return lookupNamespacePrefix(namespaceURI, (ElementImpl)this); 1631 } 1632 1633 case Node.DOCUMENT_NODE:{ 1634 return((NodeImpl)((Document)this).getDocumentElement()).lookupPrefix(namespaceURI); 1635 } 1636 */ 1637 case Node.ENTITY_NODE : 1638 case Node.NOTATION_NODE: 1639 case Node.DOCUMENT_FRAGMENT_NODE: 1640 case Node.DOCUMENT_TYPE_NODE: 1641 // type is unknown 1642 return null; 1643 case Node.ATTRIBUTE_NODE:{ 1644 if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) { 1645 return getOwnerElement().lookupPrefix(namespaceURI); 1646 1647 } 1648 return null; 1649 } 1650 default:{ 1651 /* 1652 NodeImpl ancestor = (NodeImpl)getElementAncestor(this); 1653 if (ancestor != null) { 1654 return ancestor.lookupPrefix(namespaceURI); 1655 } 1656 */ 1657 return null; 1658 } 1659 } 1660 } 1661 1662 /** 1663 * Returns whether this node is the same node as the given one. 1664 * <br>This method provides a way to determine whether two 1665 * <code>Node</code> references returned by the implementation reference 1666 * the same object. When two <code>Node</code> references are references 1667 * to the same object, even if through a proxy, the references may be 1668 * used completely interchangably, such that all attributes have the 1669 * same values and calling the same DOM method on either reference 1670 * always has exactly the same effect. 1671 * @param other The node to test against. 1672 * @return Returns <code>true</code> if the nodes are the same, 1673 * <code>false</code> otherwise. 1674 * @since DOM Level 3 1675 */ isSameNode(Node other)1676 public boolean isSameNode(Node other) { 1677 // we do not use any wrapper so the answer is obvious 1678 return this == other; 1679 } 1680 1681 /** 1682 * This attribute returns the text content of this node and its 1683 * descendants. When it is defined to be null, setting it has no effect. 1684 * When set, any possible children this node may have are removed and 1685 * replaced by a single <code>Text</code> node containing the string 1686 * this attribute is set to. On getting, no serialization is performed, 1687 * the returned string does not contain any markup. No whitespace 1688 * normalization is performed, the returned string does not contain the 1689 * element content whitespaces . Similarly, on setting, no parsing is 1690 * performed either, the input string is taken as pure textual content. 1691 * <br>The string returned is made of the text content of this node 1692 * depending on its type, as defined below: 1693 * <table border='1'> 1694 * <tr> 1695 * <th>Node type</th> 1696 * <th>Content</th> 1697 * </tr> 1698 * <tr> 1699 * <td valign='top' rowspan='1' colspan='1'> 1700 * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, 1701 * DOCUMENT_FRAGMENT_NODE</td> 1702 * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code> 1703 * attribute value of every child node, excluding COMMENT_NODE and 1704 * PROCESSING_INSTRUCTION_NODE nodes</td> 1705 * </tr> 1706 * <tr> 1707 * <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE, 1708 * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td> 1709 * <td valign='top' rowspan='1' colspan='1'> 1710 * <code>nodeValue</code></td> 1711 * </tr> 1712 * <tr> 1713 * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td> 1714 * <td valign='top' rowspan='1' colspan='1'> 1715 * null</td> 1716 * </tr> 1717 * </table> 1718 * @exception DOMException 1719 * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. 1720 * @exception DOMException 1721 * DOMSTRING_SIZE_ERR: Raised when it would return more characters than 1722 * fit in a <code>DOMString</code> variable on the implementation 1723 * platform. 1724 * @since DOM Level 3 1725 */ setTextContent(String textContent)1726 public void setTextContent(String textContent) 1727 throws DOMException { 1728 setNodeValue(textContent); 1729 } 1730 /** 1731 * This attribute returns the text content of this node and its 1732 * descendants. When it is defined to be null, setting it has no effect. 1733 * When set, any possible children this node may have are removed and 1734 * replaced by a single <code>Text</code> node containing the string 1735 * this attribute is set to. On getting, no serialization is performed, 1736 * the returned string does not contain any markup. No whitespace 1737 * normalization is performed, the returned string does not contain the 1738 * element content whitespaces . Similarly, on setting, no parsing is 1739 * performed either, the input string is taken as pure textual content. 1740 * <br>The string returned is made of the text content of this node 1741 * depending on its type, as defined below: 1742 * <table border='1'> 1743 * <tr> 1744 * <th>Node type</th> 1745 * <th>Content</th> 1746 * </tr> 1747 * <tr> 1748 * <td valign='top' rowspan='1' colspan='1'> 1749 * ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, 1750 * DOCUMENT_FRAGMENT_NODE</td> 1751 * <td valign='top' rowspan='1' colspan='1'>concatenation of the <code>textContent</code> 1752 * attribute value of every child node, excluding COMMENT_NODE and 1753 * PROCESSING_INSTRUCTION_NODE nodes</td> 1754 * </tr> 1755 * <tr> 1756 * <td valign='top' rowspan='1' colspan='1'>ATTRIBUTE_NODE, TEXT_NODE, 1757 * CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td> 1758 * <td valign='top' rowspan='1' colspan='1'> 1759 * <code>nodeValue</code></td> 1760 * </tr> 1761 * <tr> 1762 * <td valign='top' rowspan='1' colspan='1'>DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td> 1763 * <td valign='top' rowspan='1' colspan='1'> 1764 * null</td> 1765 * </tr> 1766 * </table> 1767 * @exception DOMException 1768 * NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly. 1769 * @exception DOMException 1770 * DOMSTRING_SIZE_ERR: Raised when it would return more characters than 1771 * fit in a <code>DOMString</code> variable on the implementation 1772 * platform. 1773 * @since DOM Level 3 1774 */ getTextContent()1775 public String getTextContent() throws DOMException { 1776 return getNodeValue(); // overriden in some subclasses 1777 } 1778 1779 /** 1780 * Compares a node with this node with regard to their position in the 1781 * document. 1782 * @param other The node to compare against this node. 1783 * @return Returns how the given node is positioned relatively to this 1784 * node. 1785 * @since DOM Level 3 1786 */ compareDocumentPosition(Node other)1787 public short compareDocumentPosition(Node other) throws DOMException { 1788 return 0; 1789 } 1790 1791 /** 1792 * The absolute base URI of this node or <code>null</code> if undefined. 1793 * This value is computed according to . However, when the 1794 * <code>Document</code> supports the feature "HTML" , the base URI is 1795 * computed using first the value of the href attribute of the HTML BASE 1796 * element if any, and the value of the <code>documentURI</code> 1797 * attribute from the <code>Document</code> interface otherwise. 1798 * <br> When the node is an <code>Element</code>, a <code>Document</code> 1799 * or a a <code>ProcessingInstruction</code>, this attribute represents 1800 * the properties [base URI] defined in . When the node is a 1801 * <code>Notation</code>, an <code>Entity</code>, or an 1802 * <code>EntityReference</code>, this attribute represents the 1803 * properties [declaration base URI] in the . How will this be affected 1804 * by resolution of relative namespace URIs issue?It's not.Should this 1805 * only be on Document, Element, ProcessingInstruction, Entity, and 1806 * Notation nodes, according to the infoset? If not, what is it equal to 1807 * on other nodes? Null? An empty string? I think it should be the 1808 * parent's.No.Should this be read-only and computed or and actual 1809 * read-write attribute?Read-only and computed (F2F 19 Jun 2000 and 1810 * teleconference 30 May 2001).If the base HTML element is not yet 1811 * attached to a document, does the insert change the Document.baseURI? 1812 * Yes. (F2F 26 Sep 2001) 1813 * @since DOM Level 3 1814 */ getBaseURI()1815 public String getBaseURI() { 1816 return null; 1817 } 1818 1819 /** 1820 * DOM Level 3 WD - Experimental. 1821 * Renaming node 1822 */ renameNode(Node n, String namespaceURI, String name)1823 public Node renameNode(Node n, 1824 String namespaceURI, 1825 String name) 1826 throws DOMException{ 1827 return n; 1828 } 1829 1830 1831 /** 1832 * DOM Level 3 WD - Experimental 1833 * Normalize document. 1834 */ normalizeDocument()1835 public void normalizeDocument(){ 1836 1837 } 1838 /** 1839 * The configuration used when <code>Document.normalizeDocument</code> is 1840 * invoked. 1841 * @since DOM Level 3 1842 */ getDomConfig()1843 public DOMConfiguration getDomConfig(){ 1844 return null; 1845 } 1846 1847 1848 /**Experimental DOM Level 3 feature: documentURI */ 1849 protected String fDocumentURI; 1850 1851 /** 1852 * DOM Level 3 WD - Experimental. 1853 */ setDocumentURI(String documentURI)1854 public void setDocumentURI(String documentURI){ 1855 1856 fDocumentURI= documentURI; 1857 } 1858 1859 /** 1860 * DOM Level 3 WD - Experimental. 1861 * The location of the document or <code>null</code> if undefined. 1862 * <br>Beware that when the <code>Document</code> supports the feature 1863 * "HTML" , the href attribute of the HTML BASE element takes precedence 1864 * over this attribute. 1865 * @since DOM Level 3 1866 */ getDocumentURI()1867 public String getDocumentURI(){ 1868 return fDocumentURI; 1869 } 1870 1871 /**Experimental DOM Level 3 feature: Document actualEncoding */ 1872 protected String actualEncoding; 1873 1874 /** 1875 * DOM Level 3 WD - Experimental. 1876 * An attribute specifying the actual encoding of this document. This is 1877 * <code>null</code> otherwise. 1878 * <br> This attribute represents the property [character encoding scheme] 1879 * defined in . 1880 * @since DOM Level 3 1881 */ getActualEncoding()1882 public String getActualEncoding() { 1883 return actualEncoding; 1884 } 1885 1886 /** 1887 * DOM Level 3 WD - Experimental. 1888 * An attribute specifying the actual encoding of this document. This is 1889 * <code>null</code> otherwise. 1890 * <br> This attribute represents the property [character encoding scheme] 1891 * defined in . 1892 * @since DOM Level 3 1893 */ setActualEncoding(String value)1894 public void setActualEncoding(String value) { 1895 actualEncoding = value; 1896 } 1897 1898 /** 1899 * DOM Level 3 WD - Experimental. 1900 */ replaceWholeText(String content)1901 public Text replaceWholeText(String content) 1902 throws DOMException{ 1903 /* 1904 1905 if (needsSyncData()) { 1906 synchronizeData(); 1907 } 1908 1909 // make sure we can make the replacement 1910 if (!canModify(nextSibling)) { 1911 throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, 1912 DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "NO_MODIFICATION_ALLOWED_ERR", null)); 1913 } 1914 1915 Node parent = this.getParentNode(); 1916 if (content == null || content.length() == 0) { 1917 // remove current node 1918 if (parent !=null) { // check if node in the tree 1919 parent.removeChild(this); 1920 return null; 1921 } 1922 } 1923 Text currentNode = null; 1924 if (isReadOnly()){ 1925 Text newNode = this.ownerDocument().createTextNode(content); 1926 if (parent !=null) { // check if node in the tree 1927 parent.insertBefore(newNode, this); 1928 parent.removeChild(this); 1929 currentNode = newNode; 1930 } else { 1931 return newNode; 1932 } 1933 } else { 1934 this.setData(content); 1935 currentNode = this; 1936 } 1937 Node sibling = currentNode.getNextSibling(); 1938 while ( sibling !=null) { 1939 parent.removeChild(sibling); 1940 sibling = currentNode.getNextSibling(); 1941 } 1942 1943 return currentNode; 1944 */ 1945 return null; //Pending 1946 } 1947 1948 /** 1949 * DOM Level 3 WD - Experimental. 1950 * Returns all text of <code>Text</code> nodes logically-adjacent text 1951 * nodes to this node, concatenated in document order. 1952 * @since DOM Level 3 1953 */ getWholeText()1954 public String getWholeText(){ 1955 1956 /* 1957 if (needsSyncData()) { 1958 synchronizeData(); 1959 } 1960 if (nextSibling == null) { 1961 return data; 1962 } 1963 StringBuffer buffer = new StringBuffer(); 1964 if (data != null && data.length() != 0) { 1965 buffer.append(data); 1966 } 1967 getWholeText(nextSibling, buffer); 1968 return buffer.toString(); 1969 */ 1970 return null; // PENDING 1971 1972 } 1973 1974 /** 1975 * DOM Level 3 WD - Experimental. 1976 * Returns whether this text node contains whitespace in element content, 1977 * often abusively called "ignorable whitespace". 1978 */ isWhitespaceInElementContent()1979 public boolean isWhitespaceInElementContent(){ 1980 return false; 1981 } 1982 1983 1984 1985 1986 /** 1987 * NON-DOM: set the type of this attribute to be ID type. 1988 * 1989 * @param id 1990 */ setIdAttribute(boolean id)1991 public void setIdAttribute(boolean id){ 1992 //PENDING 1993 } 1994 1995 /** 1996 * DOM Level 3: register the given attribute node as an ID attribute 1997 */ setIdAttribute(String name, boolean makeId)1998 public void setIdAttribute(String name, boolean makeId) { 1999 //PENDING 2000 } 2001 2002 2003 /** 2004 * DOM Level 3: register the given attribute node as an ID attribute 2005 */ setIdAttributeNode(Attr at, boolean makeId)2006 public void setIdAttributeNode(Attr at, boolean makeId) { 2007 //PENDING 2008 } 2009 2010 /** 2011 * DOM Level 3: register the given attribute node as an ID attribute 2012 */ setIdAttributeNS(String namespaceURI, String localName, boolean makeId)2013 public void setIdAttributeNS(String namespaceURI, String localName, 2014 boolean makeId) { 2015 //PENDING 2016 } 2017 /** 2018 * Method getSchemaTypeInfo. 2019 * @return TypeInfo 2020 */ getSchemaTypeInfo()2021 public TypeInfo getSchemaTypeInfo(){ 2022 return null; //PENDING 2023 } 2024 isId()2025 public boolean isId() { 2026 return false; //PENDING 2027 } 2028 2029 private String xmlEncoding; getXmlEncoding( )2030 public String getXmlEncoding ( ) { 2031 return xmlEncoding; 2032 } setXmlEncoding( String xmlEncoding )2033 public void setXmlEncoding ( String xmlEncoding ) { 2034 this.xmlEncoding = xmlEncoding; 2035 } 2036 2037 private boolean xmlStandalone; getXmlStandalone()2038 public boolean getXmlStandalone() { 2039 return xmlStandalone; 2040 } 2041 setXmlStandalone(boolean xmlStandalone)2042 public void setXmlStandalone(boolean xmlStandalone) throws DOMException { 2043 this.xmlStandalone = xmlStandalone; 2044 } 2045 2046 private String xmlVersion; getXmlVersion()2047 public String getXmlVersion() { 2048 return xmlVersion; 2049 } 2050 setXmlVersion(String xmlVersion)2051 public void setXmlVersion(String xmlVersion) throws DOMException { 2052 this.xmlVersion = xmlVersion; 2053 } 2054 2055 2056 } 2057