1 16 19 package com.sun.org.apache.xml.internal.utils; 20 21 import com.sun.org.apache.xml.internal.res.XMLErrorResources; 22 import com.sun.org.apache.xml.internal.res.XMLMessages; 23 24 import org.w3c.dom.Attr ; 25 import org.w3c.dom.CDATASection ; 26 import org.w3c.dom.Comment ; 27 import org.w3c.dom.DOMException ; 28 import org.w3c.dom.DOMImplementation ; 29 import org.w3c.dom.Document ; 30 import org.w3c.dom.DocumentFragment ; 31 import org.w3c.dom.DocumentType ; 32 import org.w3c.dom.Element ; 33 import org.w3c.dom.EntityReference ; 34 import org.w3c.dom.NamedNodeMap ; 35 import org.w3c.dom.Node ; 36 import org.w3c.dom.NodeList ; 37 import org.w3c.dom.ProcessingInstruction ; 38 import org.w3c.dom.Text ; 39 40 import org.w3c.dom.UserDataHandler ; 41 import org.w3c.dom.DOMConfiguration ; 42 import org.w3c.dom.TypeInfo ; 43 47 public class UnImplNode implements Node , Element , NodeList , Document 48 { 49 50 54 public UnImplNode(){} 55 56 61 public void error(String msg) 62 { 63 64 System.out.println("DOM ERROR! class: " + this.getClass().getName()); 65 66 throw new RuntimeException (XMLMessages.createXMLMessage(msg, null)); 67 } 68 69 75 public void error(String msg, Object [] args) 76 { 77 78 System.out.println("DOM ERROR! class: " + this.getClass().getName()); 79 80 throw new RuntimeException (XMLMessages.createXMLMessage(msg, args)); } 82 83 92 public Node appendChild(Node newChild) throws DOMException 93 { 94 95 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 97 return null; 98 } 99 100 105 public boolean hasChildNodes() 106 { 107 108 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 110 return false; 111 } 112 113 118 public short getNodeType() 119 { 120 121 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 123 return 0; 124 } 125 126 131 public Node getParentNode() 132 { 133 134 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 136 return null; 137 } 138 139 144 public NodeList getChildNodes() 145 { 146 147 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 149 return null; 150 } 151 152 157 public Node getFirstChild() 158 { 159 160 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 162 return null; 163 } 164 165 170 public Node getLastChild() 171 { 172 173 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 175 return null; 176 } 177 178 183 public Node getNextSibling() 184 { 185 186 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 188 return null; 189 } 190 191 196 public int getLength() 197 { 198 199 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 201 return 0; 202 } 204 211 public Node item(int index) 212 { 213 214 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 216 return null; 217 } 219 224 public Document getOwnerDocument() 225 { 226 227 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 229 return null; 230 } 231 232 237 public String getTagName() 238 { 239 240 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 242 return null; 243 } 244 245 250 public String getNodeName() 251 { 252 253 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 255 return null; 256 } 257 258 259 public void normalize() 260 { 261 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); } 263 264 271 public NodeList getElementsByTagName(String name) 272 { 273 274 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 276 return null; 277 } 278 279 288 public Attr removeAttributeNode(Attr oldAttr) throws DOMException 289 { 290 291 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 293 return null; 294 } 295 296 305 public Attr setAttributeNode(Attr newAttr) throws DOMException 306 { 307 308 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 310 return null; 311 } 312 313 321 public boolean hasAttribute(String name) 322 { 323 324 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 326 return false; 327 } 328 329 338 public boolean hasAttributeNS(String name, String x) 339 { 340 341 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 343 return false; 344 } 345 346 354 public Attr getAttributeNode(String name) 355 { 356 357 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 359 return null; 360 } 361 362 369 public void removeAttribute(String name) throws DOMException 370 { 371 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); } 373 374 382 public void setAttribute(String name, String value) throws DOMException 383 { 384 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); } 386 387 394 public String getAttribute(String name) 395 { 396 397 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 399 return null; 400 } 401 402 407 public boolean hasAttributes() 408 { 409 410 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 412 return false; 413 } 414 415 423 public NodeList getElementsByTagNameNS(String namespaceURI, 424 String localName) 425 { 426 427 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 429 return null; 430 } 431 432 441 public Attr setAttributeNodeNS(Attr newAttr) throws DOMException 442 { 443 444 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 446 return null; 447 } 448 449 457 public Attr getAttributeNodeNS(String namespaceURI, String localName) 458 { 459 460 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 462 return null; 463 } 464 465 473 public void removeAttributeNS(String namespaceURI, String localName) 474 throws DOMException 475 { 476 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); } 478 479 489 public void setAttributeNS( 490 String namespaceURI, String qualifiedName, String value) 491 throws DOMException 492 { 493 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); } 495 496 504 public String getAttributeNS(String namespaceURI, String localName) 505 { 506 507 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 509 return null; 510 } 511 512 517 public Node getPreviousSibling() 518 { 519 520 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 522 return null; 523 } 524 525 532 public Node cloneNode(boolean deep) 533 { 534 535 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 537 return null; 538 } 539 540 547 public String getNodeValue() throws DOMException 548 { 549 550 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 552 return null; 553 } 554 555 562 public void setNodeValue(String nodeValue) throws DOMException 563 { 564 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); } 566 567 576 577 583 590 public void setValue(String value) throws DOMException 591 { 592 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); } 594 595 600 601 606 611 public Element getOwnerElement() 612 { 613 614 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 616 return null; 617 } 618 619 624 public boolean getSpecified() 625 { 626 627 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 629 return false; 630 } 631 632 637 public NamedNodeMap getAttributes() 638 { 639 640 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 642 return null; 643 } 644 645 655 public Node insertBefore(Node newChild, Node refChild) throws DOMException 656 { 657 658 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 660 return null; 661 } 662 663 673 public Node replaceChild(Node newChild, Node oldChild) throws DOMException 674 { 675 676 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 678 return null; 679 } 680 681 690 public Node removeChild(Node oldChild) throws DOMException 691 { 692 693 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 695 return null; 696 } 697 698 714 public boolean isSupported(String feature, String version) 715 { 716 return false; 717 } 718 719 724 public String getNamespaceURI() 725 { 726 727 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 729 return null; 730 } 731 732 737 public String getPrefix() 738 { 739 740 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 742 return null; 743 } 744 745 752 public void setPrefix(String prefix) throws DOMException 753 { 754 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); } 756 757 762 public String getLocalName() 763 { 764 765 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 767 return null; 768 } 769 770 775 public DocumentType getDoctype() 776 { 777 778 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 779 780 return null; 781 } 782 783 788 public DOMImplementation getImplementation() 789 { 790 791 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 792 793 return null; 794 } 795 796 801 public Element getDocumentElement() 802 { 803 804 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 805 806 return null; 807 } 808 809 818 public Element createElement(String tagName) throws DOMException 819 { 820 821 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 822 823 return null; 824 } 825 826 831 public DocumentFragment createDocumentFragment() 832 { 833 834 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 835 836 return null; 837 } 838 839 846 public Text createTextNode(String data) 847 { 848 849 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 850 851 return null; 852 } 853 854 861 public Comment createComment(String data) 862 { 863 864 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 865 866 return null; 867 } 868 869 878 public CDATASection createCDATASection(String data) throws DOMException 879 { 880 881 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 882 883 return null; 884 } 885 886 896 public ProcessingInstruction createProcessingInstruction( 897 String target, String data) throws DOMException 898 { 899 900 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 901 902 return null; 903 } 904 905 914 public Attr createAttribute(String name) throws DOMException 915 { 916 917 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 918 919 return null; 920 } 921 922 931 public EntityReference createEntityReference(String name) 932 throws DOMException 933 { 934 935 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 936 937 return null; 938 } 939 940 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 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 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 1009 public Element getElementById(String elementId) 1010 { 1011 1012 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1013 1014 return null; 1015 } 1016 1017 1025 public void setData(String data) throws DOMException 1026 { 1027 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1028 } 1029 1030 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 1055 public void appendData(String arg) throws DOMException 1056 { 1057 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1058 } 1059 1060 1069 public void insertData(int offset, String arg) throws DOMException 1070 { 1071 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1072 } 1073 1074 1082 public void deleteData(int offset, int count) throws DOMException 1083 { 1084 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1085 } 1086 1087 1096 public void replaceData(int offset, int count, String arg) 1097 throws DOMException 1098 { 1099 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1100 } 1101 1102 1111 public Text splitText(int offset) throws DOMException 1112 { 1113 1114 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1115 1116 return null; 1117 } 1118 1119 1129 public Node adoptNode(Node source) throws DOMException 1130 { 1131 1132 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1133 1134 return null; 1135 } 1136 1137 1148 public String getInputEncoding() 1149 { 1150 1151 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1152 1153 return null; 1154 } 1155 1156 1167 public void setInputEncoding(String encoding) 1168 { 1169 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1170 } 1171 1172 1183 public boolean getStandalone() 1184 { 1185 1186 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1187 1188 return false; 1189 } 1190 1191 1202 public void setStandalone(boolean standalone) 1203 { 1204 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1205 } 1206 1207 1222 public boolean getStrictErrorChecking() 1223 { 1224 1225 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1226 1227 return false; 1228 } 1229 1230 1245 public void setStrictErrorChecking(boolean strictErrorChecking) 1246 { 1247 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1248 } 1249 1250 1261 public String getVersion() 1262 { 1263 1264 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1265 1266 return null; 1267 } 1268 1269 1280 public void setVersion(String version) 1281 { 1282 error(XMLErrorResources.ER_FUNCTION_NOT_SUPPORTED); 1283 } 1284 1285 1286 1287 1289 public Object setUserData(String key, 1290 Object data, 1291 UserDataHandler handler) { 1292 return getOwnerDocument().setUserData( key, data, handler); 1293 } 1294 1295 1304 public Object getUserData(String key) { 1305 return getOwnerDocument().getUserData( key); 1306 } 1307 1308 1328 public Object getFeature(String feature, String version) { 1329 return isSupported(feature, version) ? this : null; 1332 } 1333 1334 1376 public boolean isEqualNode(Node arg) { 1377 if (arg == this) { 1378 return true; 1379 } 1380 if (arg.getNodeType() != getNodeType()) { 1381 return false; 1382 } 1383 if (getNodeName() == null) { 1386 if (arg.getNodeName() != null) { 1387 return false; 1388 } 1389 } 1390 else if (!getNodeName().equals(arg.getNodeName())) { 1391 return false; 1392 } 1393 1394 if (getLocalName() == null) { 1395 if (arg.getLocalName() != null) { 1396 return false; 1397 } 1398 } 1399 else if (!getLocalName().equals(arg.getLocalName())) { 1400 return false; 1401 } 1402 1403 if (getNamespaceURI() == null) { 1404 if (arg.getNamespaceURI() != null) { 1405 return false; 1406 } 1407 } 1408 else if (!getNamespaceURI().equals(arg.getNamespaceURI())) { 1409 return false; 1410 } 1411 1412 if (getPrefix() == null) { 1413 if (arg.getPrefix() != null) { 1414 return false; 1415 } 1416 } 1417 else if (!getPrefix().equals(arg.getPrefix())) { 1418 return false; 1419 } 1420 1421 if (getNodeValue() == null) { 1422 if (arg.getNodeValue() != null) { 1423 return false; 1424 } 1425 } 1426 else if (!getNodeValue().equals(arg.getNodeValue())) { 1427 return false; 1428 } 1429 1439 1440 return true; 1441 } 1442 1443 1452 public String lookupNamespaceURI(String specifiedPrefix) { 1453 short type = this.getNodeType(); 1454 switch (type) { 1455 case Node.ELEMENT_NODE : { 1456 1457 String namespace = this.getNamespaceURI(); 1458 String prefix = this.getPrefix(); 1459 if (namespace !=null) { 1460 if (specifiedPrefix== null && prefix==specifiedPrefix) { 1462 return namespace; 1464 } else if (prefix != null && prefix.equals(specifiedPrefix)) { 1465 return namespace; 1467 } 1468 } 1469 if (this.hasAttributes()) { 1470 NamedNodeMap map = this.getAttributes(); 1471 int length = map.getLength(); 1472 for (int i=0;i<length;i++) { 1473 Node attr = map.item(i); 1474 String attrPrefix = attr.getPrefix(); 1475 String value = attr.getNodeValue(); 1476 namespace = attr.getNamespaceURI(); 1477 if (namespace !=null && namespace.equals("http://www.w3.org/2000/xmlns/")) { 1478 if (specifiedPrefix == null && 1480 attr.getNodeName().equals("xmlns")) { 1481 return value; 1483 } else if (attrPrefix !=null && 1484 attrPrefix.equals("xmlns") && 1485 attr.getLocalName().equals(specifiedPrefix)) { 1486 return value; 1488 } 1489 } 1490 } 1491 } 1492 1498 1499 return null; 1500 1501 1502 } 1503 1508 case Node.ENTITY_NODE : 1509 case Node.NOTATION_NODE: 1510 case Node.DOCUMENT_FRAGMENT_NODE: 1511 case Node.DOCUMENT_TYPE_NODE: 1512 return null; 1514 case Node.ATTRIBUTE_NODE:{ 1515 if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) { 1516 return getOwnerElement().lookupNamespaceURI(specifiedPrefix); 1517 1518 } 1519 return null; 1520 } 1521 default:{ 1522 1528 return null; 1529 } 1530 1531 } 1532 } 1533 1534 1535 1544 public boolean isDefaultNamespace(String namespaceURI){ 1545 1605 return false; 1606 1607 1608 } 1609 1610 1618 public String lookupPrefix(String namespaceURI){ 1619 1620 if (namespaceURI == null) { 1623 return null; 1624 } 1625 1626 short type = this.getNodeType(); 1627 1628 switch (type) { 1629 1640 case Node.ENTITY_NODE : 1641 case Node.NOTATION_NODE: 1642 case Node.DOCUMENT_FRAGMENT_NODE: 1643 case Node.DOCUMENT_TYPE_NODE: 1644 return null; 1646 case Node.ATTRIBUTE_NODE:{ 1647 if (this.getOwnerElement().getNodeType() == Node.ELEMENT_NODE) { 1648 return getOwnerElement().lookupPrefix(namespaceURI); 1649 1650 } 1651 return null; 1652 } 1653 default:{ 1654 1660 return null; 1661 } 1662 } 1663 } 1664 1665 1679 public boolean isSameNode(Node other) { 1680 return this == other; 1682 } 1683 1684 1729 public void setTextContent(String textContent) 1730 throws DOMException { 1731 setNodeValue(textContent); 1732 } 1733 1778 public String getTextContent() throws DOMException { 1779 return getNodeValue(); } 1781 1782 1790 public short compareDocumentPosition(Node other) throws DOMException { 1791 return 0; 1792 } 1793 1794 1818 public String getBaseURI() { 1819 return null; 1820 } 1821 1822 1826 public Node renameNode(Node n, 1827 String namespaceURI, 1828 String name) 1829 throws DOMException { 1830 return n; 1831 } 1832 1833 1834 1838 public void normalizeDocument(){ 1839 1840 } 1841 1846 public DOMConfiguration getDomConfig(){ 1847 return null; 1848 } 1849 1850 1851 1852 protected String fDocumentURI; 1853 1854 1857 public void setDocumentURI(String documentURI){ 1858 1859 fDocumentURI= documentURI; 1860 } 1861 1862 1870 public String getDocumentURI(){ 1871 return fDocumentURI; 1872 } 1873 1874 1875 protected String actualEncoding; 1876 1877 1885 public String getActualEncoding() { 1886 return actualEncoding; 1887 } 1888 1889 1897 public void setActualEncoding(String value) { 1898 actualEncoding = value; 1899 } 1900 1901 1904 public Text replaceWholeText(String content) 1905 throws DOMException { 1906 1948 return null; } 1950 1951 1957 public String getWholeText(){ 1958 1959 1973 return null; 1975 } 1976 1977 1982 public boolean isWhitespaceInElementContent(){ 1983 return false; 1984 } 1985 1986 1987 1988 1989 1994 public void setIdAttribute(boolean id){ 1995 } 1997 1998 2001 public void setIdAttribute(String name, boolean makeId) { 2002 } 2004 2005 2006 2009 public void setIdAttributeNode(Attr at, boolean makeId) { 2010 } 2012 2013 2016 public void setIdAttributeNS(String namespaceURI, String localName, 2017 boolean makeId) { 2018 } 2020 2024 public TypeInfo getSchemaTypeInfo(){ 2025 return null; } 2027 2028 public boolean isId() { 2029 return false; } 2031 2032 private String xmlEncoding; 2033 public String getXmlEncoding ( ) { 2034 return xmlEncoding; 2035 } 2036 public void setXmlEncoding ( String xmlEncoding ) { 2037 this.xmlEncoding = xmlEncoding; 2038 } 2039 2040 private boolean xmlStandalone; 2041 public boolean getXmlStandalone() { 2042 return xmlStandalone; 2043 } 2044 2045 public void setXmlStandalone(boolean xmlStandalone) throws DOMException { 2046 this.xmlStandalone = xmlStandalone; 2047 } 2048 2049 private String xmlVersion; 2050 public String getXmlVersion() { 2051 return xmlVersion; 2052 } 2053 2054 public void setXmlVersion(String xmlVersion) throws DOMException { 2055 this.xmlVersion = xmlVersion; 2056 } 2057 2058 2059} 2060 | Popular Tags |