1 57 58 package org.enhydra.apache.xerces.dom; 59 60 import java.io.IOException ; 61 import java.io.ObjectOutputStream ; 62 import java.io.Serializable ; 63 64 import org.w3c.dom.DOMException ; 65 import org.w3c.dom.Document ; 66 import org.w3c.dom.NamedNodeMap ; 67 import org.w3c.dom.Node ; 68 import org.w3c.dom.NodeList ; 69 import org.w3c.dom.UserDataHandler ; 70 import org.w3c.dom.events.Event ; 71 import org.w3c.dom.events.EventListener ; 72 import org.w3c.dom.events.EventTarget ; 73 74 117 public abstract class NodeImpl 118 implements Node , NodeList , EventTarget , Cloneable , Serializable { 119 120 124 125 static final long serialVersionUID = -6316591992167219696L; 126 127 129 130 public static final short ELEMENT_DEFINITION_NODE = -1; 131 132 136 138 protected NodeImpl ownerNode; 140 142 protected short flags; 143 144 protected final static short READONLY = 0x1<<0; 145 protected final static short SYNCDATA = 0x1<<1; 146 protected final static short SYNCCHILDREN = 0x1<<2; 147 protected final static short OWNED = 0x1<<3; 148 protected final static short FIRSTCHILD = 0x1<<4; 149 protected final static short SPECIFIED = 0x1<<5; 150 protected final static short IGNORABLEWS = 0x1<<6; 151 protected final static short HASSTRING = 0x1<<7; 152 protected final static short UNNORMALIZED = 0x1<<8; 153 154 158 164 protected NodeImpl(CoreDocumentImpl ownerDocument) { 165 ownerNode = ownerDocument; 167 } 169 170 public NodeImpl() {} 171 172 176 180 public abstract short getNodeType(); 181 182 185 public abstract String getNodeName(); 186 187 190 public String getNodeValue() { 191 return null; } 193 194 198 public void setNodeValue(String x) 199 throws DOMException { 200 } 202 203 223 public Node appendChild(Node newChild) throws DOMException { 224 return insertBefore(newChild, null); 225 } 226 227 250 public Node cloneNode(boolean deep) { 251 252 if (needsSyncData()) { 253 synchronizeData(); 254 } 255 256 NodeImpl newnode; 257 try { 258 newnode = (NodeImpl)clone(); 259 } 260 catch (CloneNotSupportedException e) { 261 return null; 264 } 265 266 newnode.ownerNode = ownerDocument(); 268 newnode.isOwned(false); 269 270 newnode.isReadOnly(false); 272 273 return newnode; 274 275 } 277 282 public Document getOwnerDocument() { 283 if (isOwned()) { 286 return ownerNode.ownerDocument(); 287 } else { 288 return (Document ) ownerNode; 289 } 290 } 291 292 296 CoreDocumentImpl ownerDocument() { 297 if (isOwned()) { 300 return ownerNode.ownerDocument(); 301 } else { 302 return (CoreDocumentImpl) ownerNode; 303 } 304 } 305 306 310 void setOwnerDocument(CoreDocumentImpl doc) { 311 if (needsSyncData()) { 312 synchronizeData(); 313 } 314 if (!isOwned()) { 317 ownerNode = doc; 318 } 319 } 320 321 327 public Node getParentNode() { 328 return null; } 330 331 334 NodeImpl parentNode() { 335 return null; 336 } 337 338 339 public Node getNextSibling() { 340 return null; } 342 343 344 public Node getPreviousSibling() { 345 return null; } 347 348 ChildNode previousSibling() { 349 return null; } 351 352 359 public NamedNodeMap getAttributes() { 360 return null; } 362 363 370 public boolean hasAttributes() { 371 return false; } 373 374 381 public boolean hasChildNodes() { 382 return false; 383 } 384 385 398 public NodeList getChildNodes() { 399 return this; 400 } 401 402 407 public Node getFirstChild() { 408 return null; 409 } 410 411 416 public Node getLastChild() { 417 return null; 418 } 419 420 451 public Node insertBefore(Node newChild, Node refChild) 452 throws DOMException { 453 throw new DOMException (DOMException.HIERARCHY_REQUEST_ERR, 454 "DOM006 Hierarchy request error"); 455 } 456 457 472 public Node removeChild(Node oldChild) 473 throws DOMException { 474 throw new DOMException (DOMException.NOT_FOUND_ERR, 475 "DOM008 Not found"); 476 } 477 478 502 public Node replaceChild(Node newChild, Node oldChild) 503 throws DOMException { 504 throw new DOMException (DOMException.HIERARCHY_REQUEST_ERR, 505 "DOM006 Hierarchy request error"); 506 } 507 508 512 520 public int getLength() { 521 return 0; 522 } 523 524 534 public Node item(int index) { 535 return null; 536 } 537 538 542 560 public void normalize() { 561 563 } 564 565 580 public boolean isSupported(String feature, String version) 581 { 582 return ownerDocument().getImplementation().hasFeature(feature, 583 version); 584 } 585 586 603 public String getNamespaceURI() 604 { 605 return null; 606 } 607 608 622 public String getPrefix() 623 { 624 return null; 625 } 626 627 648 public void setPrefix(String prefix) 649 throws DOMException 650 { 651 throw new DOMException (DOMException.NAMESPACE_ERR, 652 "DOM003 Namespace error"); 653 } 654 655 667 public String getLocalName() 668 { 669 return null; 670 } 671 672 676 public void addEventListener(String type, EventListener listener, 677 boolean useCapture) { 678 ownerDocument().addEventListener(this, type, listener, useCapture); 680 } 681 682 public void removeEventListener(String type, EventListener listener, 683 boolean useCapture) { 684 ownerDocument().removeEventListener(this, type, listener, useCapture); 686 } 687 688 public boolean dispatchEvent(Event event) { 689 return ownerDocument().dispatchEvent(this, event); 691 } 692 693 697 715 public void setReadOnly(boolean readOnly, boolean deep) { 716 717 if (needsSyncData()) { 718 synchronizeData(); 719 } 720 isReadOnly(readOnly); 721 722 } 724 728 public boolean getReadOnly() { 729 730 if (needsSyncData()) { 731 synchronizeData(); 732 } 733 return isReadOnly(); 734 735 } 737 749 public void setUserData(Object data) { 750 ownerDocument().setUserData(this, data); 751 } 752 753 757 public Object getUserData() { 758 return ownerDocument().getUserData(this); 759 } 760 761 765 768 protected void changed() { 769 ownerDocument().changed(); 773 } 774 775 778 protected int changes() { 779 return ownerDocument().changes(); 783 } 784 785 789 protected void synchronizeData() { 790 needsSyncData(false); 792 } 793 794 795 798 799 final boolean isReadOnly() { 800 return (flags & READONLY) != 0; 801 } 802 803 final void isReadOnly(boolean value) { 804 flags = (short) (value ? flags | READONLY : flags & ~READONLY); 805 } 806 807 final boolean needsSyncData() { 808 return (flags & SYNCDATA) != 0; 809 } 810 811 final void needsSyncData(boolean value) { 812 flags = (short) (value ? flags | SYNCDATA : flags & ~SYNCDATA); 813 } 814 815 final boolean needsSyncChildren() { 816 return (flags & SYNCCHILDREN) != 0; 817 } 818 819 final void needsSyncChildren(boolean value) { 820 flags = (short) (value ? flags | SYNCCHILDREN : flags & ~SYNCCHILDREN); 821 } 822 823 final boolean isOwned() { 824 return (flags & OWNED) != 0; 825 } 826 827 final void isOwned(boolean value) { 828 flags = (short) (value ? flags | OWNED : flags & ~OWNED); 829 } 830 831 final boolean isFirstChild() { 832 return (flags & FIRSTCHILD) != 0; 833 } 834 835 final void isFirstChild(boolean value) { 836 flags = (short) (value ? flags | FIRSTCHILD : flags & ~FIRSTCHILD); 837 } 838 839 final boolean isSpecified() { 840 return (flags & SPECIFIED) != 0; 841 } 842 843 final void isSpecified(boolean value) { 844 flags = (short) (value ? flags | SPECIFIED : flags & ~SPECIFIED); 845 } 846 847 final boolean internalIsIgnorableWhitespace() { 849 return (flags & IGNORABLEWS) != 0; 850 } 851 852 final void isIgnorableWhitespace(boolean value) { 853 flags = (short) (value ? flags | IGNORABLEWS : flags & ~IGNORABLEWS); 854 } 855 856 final boolean hasStringValue() { 857 return (flags & HASSTRING) != 0; 858 } 859 860 final void hasStringValue(boolean value) { 861 flags = (short) (value ? flags | HASSTRING : flags & ~HASSTRING); 862 } 863 864 final boolean isNormalized() { 865 return (flags & UNNORMALIZED) == 0; 866 } 867 868 final void isNormalized(boolean value) { 869 if (!value && isNormalized() && ownerNode != null) { 871 ownerNode.isNormalized(false); 872 } 873 flags = (short) (value ? flags & ~UNNORMALIZED : flags | UNNORMALIZED); 874 } 875 876 880 881 public String toString() { 882 return "["+getNodeName()+": "+getNodeValue()+"]"; 883 } 884 885 889 890 private void writeObject(ObjectOutputStream out) throws IOException { 891 892 if (needsSyncData()) { 894 synchronizeData(); 895 } 896 out.defaultWriteObject(); 898 899 } 901 902 905 public short compareDocumentPosition(Node arg0) throws DOMException { 906 return 0; 908 } 909 912 public String getBaseURI() { 913 return null; 915 } 916 919 public Object getFeature(String arg0, String arg1) { 920 return null; 922 } 923 926 public String getTextContent() throws DOMException { 927 return null; 929 } 930 933 public Object getUserData(String arg0) { 934 return null; 936 } 937 940 public boolean isDefaultNamespace(String arg0) { 941 return false; 943 } 944 947 public boolean isEqualNode(Node arg0) { 948 return false; 950 } 951 954 public boolean isSameNode(Node arg0) { 955 return false; 957 } 958 961 public String lookupNamespaceURI(String arg0) { 962 return null; 964 } 965 968 public String lookupPrefix(String arg0) { 969 return null; 971 } 972 975 public void setTextContent(String arg0) throws DOMException { 976 978 } 979 982 public Object setUserData(String arg0, Object arg1, UserDataHandler arg2) { 983 return null; 985 } 986 987 } | Popular Tags |