The Node interface provides shared behaviors such as siblings and children, both for consistancy and so that the most common tree operations may be performed without constantly having to downcast to specific node types. When there is no obvious mapping for one of these queries, it will respond with null. Note that the default behavior is that children are forbidden. To permit them, the subclass ParentNode overrides several methods.
NodeImpl also implements NodeList, so it can return itself in response to the getChildNodes() query. This eliminiates the need for a separate ChildNodeList object. Note that this is an IMPLEMENTATION DETAIL; applications should _never_ assume that this identity exists.
All nodes in a single document must originate in that document. (Note that this is much tighter than "must be same implementation") Nodes are all aware of their ownerDocument, and attempts to mismatch will throw WRONG_DOCUMENT_ERR.
However, to save memory not all nodes always have a direct reference to their ownerDocument. When a node is owned by another node it relies on its owner to store its ownerDocument. Parent nodes always store it though, so there is never more than one level of indirection. And when a node doesn't have an owner, ownerNode refers to its ownerDocument.
This class doesn't directly support mutation events, however, it still implements the EventTarget interface and forward all related calls to the document so that the document class do so.
| Modifier and Type | Field and Description |
|---|---|
| public static final short | |
| public static final short | |
| public static final short | |
| public static final short | |
| public static final short | |
| public static final short | |
| public static final short | ELEMENT_DEFINITION_NODE
Element definition node type. |
| protected static final short | |
| protected short | |
| protected static final short | |
| protected static final short | |
| protected static final short | |
| protected static final short | |
| protected static final short | |
| protected NodeImpl | |
| protected static final short | |
| pack-priv static final long | serialVersionUID
Serialization version. |
| protected static final short | |
| protected static final short | |
| protected static final short | |
| public static final short | TREE_POSITION_ANCESTOR
The node is an ancestor of the reference node. |
| public static final short | TREE_POSITION_DESCENDANT
The node is a descendant of the reference node. |
| public static final short | TREE_POSITION_DISCONNECTED
The two nodes are disconnected, they do not have any common ancestor. |
| public static final short | TREE_POSITION_EQUIVALENT
The two nodes have an equivalent position. |
| public static final short | TREE_POSITION_FOLLOWING
The node follows the reference node. |
| public static final short | TREE_POSITION_PRECEDING
The node precedes the reference node. |
| public static final short | TREE_POSITION_SAME_NODE
The two nodes are the same. |
| Access | Constructor and Description |
|---|---|
| protected | NodeImpl(CoreDocumentImpl ownerDocument)
No public constructor; only subclasses of Node should be instantiated, and those normally via a Document's factory methods Every Node knows what Document it belongs to. |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addEventListener(String
The event type for which the user is registering type, EventListener The listener, boolean listener parameter takes an interface
implemented by the user which contains the methods to be called
when the event occurs.If true, useCapture)useCapture indicates that the
user wishes to initiate capture. After initiating capture, all
events of the specified type will be dispatched to the registered
EventListener before being dispatched to any
EventTargets beneath them in the tree. Events which
are bubbling upward through the tree will not trigger an
EventListener designated to use capture.Implements org. |
| public Node | Returns: newChild, in its new state (relocated, or emptied in the case of DocumentNode.)The node to add.If it is a
newChild)DocumentFragment object, the entire contents of the
document fragment are moved into the child list of this nodeImplements org. |
| protected void | |
| protected int | |
| public Node | cloneNode(boolean
If deep)true, recursively clone the subtree under
the specified node; if false, clone only the node
itself (and its attributes, if it is an Element).Implements org. |
| public short | Returns: Returns how the given node is positioned relatively to this node.The node to compare against this node. other)Implements org. |
| public short | Returns: Returns how the given node is positioned relatively to this node.The node to compare against this node. other)
Deprecated
Compares a node with this node with regard to their position in the
tree and according to the document order.
|
| public boolean | dispatchEvent(Event
Specifies the event type, behavior, and contextual
information to be used in processing the event. event)Implements org. |
| public NamedNodeMap | getAttributes()
Implements org. |
| public String | getBaseURI()
Implements org. null if undefined.
|
| public NodeList | getChildNodes()
Implements org. |
| protected Node | |
| pack-priv Node | |
| public Object | getFeature(String
The name of the feature requested. Note that any plus
sign "+" prepended to the name of the feature will be ignored since
it is not significant in the context of this method. feature, String This is the version number of the feature to test. version)Implements org. |
| public Node | getFirstChild()
Implements org. |
| public Node | getLastChild()
Implements org. |
| public int | Returns: intImplements org. By default we do not have any children, ParentNode overrides this. |
| public String | |
| public String | |
| public Node | getNextSibling()
Implements org. |
| public abstract String | |
| protected int | |
| public abstract short | getNodeType()
Redeclares org. |
| public String | |
| public Document | getOwnerDocument()
Implements org. |
| public Node | getParentNode()
Implements org. |
| public String | |
| public Node | getPreviousSibling()
Implements org. |
| public boolean | |
| public String | getTextContent()
Implements org. |
| pack-priv void | |
| public Object | Returns: Returns theDOMObject associated to the given key
on this node, or null if there was none.The key the object is associated to. key)Implements org. |
| public Object | |
| protected Hashtable | |
| public boolean | Returns: true if this node has any attributes,
false otherwise.Implements org. |
| public boolean | |
| pack-priv final boolean | |
| pack-priv final void | |
| public Node | Returns: newChild, in its new state (relocated, or emptied in the case of DocumentNode.)The Node to be moved to our subtree. As a
convenience feature, inserting a DocumentNode will instead insert
all its children. newChild, Node Current child which newChild should be placed
immediately before. If refChild is null, the insertion occurs
after all existing Nodes, like appendChild(). refChild)Implements org. |
| pack-priv final boolean | |
| public boolean | Returns: true if the specified namespaceURI
is the default namespace, false otherwise.The namespace URI to look for. namespaceURI)Implements org. namespaceURI is the
default namespace or not.
|
| public boolean | Returns: If the nodes, and possibly subtrees are equal,true otherwise false.The node to compare equality with. arg)Implements org. |
| pack-priv final boolean | |
| pack-priv final void | |
| pack-priv final boolean | |
| pack-priv final void | |
| pack-priv final void | |
| pack-priv final boolean | |
| pack-priv final void | |
| pack-priv final boolean | |
| pack-priv final void | |
| pack-priv final boolean | |
| pack-priv final void | |
| public boolean | Returns: Returnstrue if the nodes are the same,
false otherwise.The node to test against. other)Implements org. |
| pack-priv final boolean | |
| pack-priv final void | |
| public boolean | Returns: boolean Returns true if this node defines a subtree within which the specified feature is supported, false otherwise.The package name of the feature to test. This is the same
name as what can be passed to the method hasFeature on
DOMImplementation. feature, String This is the version number of the package name to
test. In Level 2, version 1, this is the string "2.0". If the version is
not specified, supporting any version of the feature will cause the
method to return true. version)Implements org. |
| public Node | Returns: org.w3c.dom.Nodeint index)Implements org. |
| pack-priv String | |
| public String | Returns: the URI for the namespaceImplements org. |
| public String | Returns: the prefix for the namespaceImplements org. |
| pack-priv final boolean | |
| public final void | |
| pack-priv final boolean | |
| pack-priv final void | |
| public void | normalize()
Implements org. Text nodes in the full depth of the sub-tree
underneath this Node, including attribute nodes, into a
"normal" form where only markup (e.g., tags, comments, processing
instructions, CDATA sections, and entity references) separates
Text nodes, i.e., there are no adjacent Text
nodes.
|
| pack-priv CoreDocumentImpl | ownerDocument()
same as above but returns internal type and this one is not overridden by CoreDocumentImpl to return null |
| pack-priv NodeImpl | |
| pack-priv ChildNode | |
| public Node | Returns: oldChild, in its new state (removed).The node being removed. oldChild)Implements org. |
| public void | removeEventListener(String
Specifies the event type of the type, EventListener EventListener
being removed.The listener, boolean EventListener parameter indicates the
EventListener to be removed.Specifies whether the useCapture)EventListener
being removed was registered as a capturing listener or not. If a
listener was registered twice, one with capture and one without,
each must be removed separately. Removal of a capturing listener
does not affect a non-capturing version of the same listener, and
vice versa.Implements org. |
| public Node | Returns: oldChild, in its new state (removed).The new node to put in the child list. newChild, Node The node being replaced in the list. oldChild)Implements org. |
| public void | |
| protected void | |
| public void | |
| public void | setReadOnly(boolean
True or false as desired. readOnly, boolean If true, children are also toggled. Note that this will
not change the state of an EntityReference or its children,
which are always read-only. deep)NON-DOM: PR-DOM-Level-1-19980818 mentions readonly nodes in conjunction with Entities, but provides no API to support this. |
| public void | setTextContent(String textContent)
Implements org. |
| public Object | Returns: Returns theDOMObject previously associated to
the given key on this node, or null if there was none.The key to associate the object to. key, Object The object to associate to the given key, or
data, UserDataHandler null to remove any existing association to that key.The handler to associate to that key, or
handler)null.Implements org. |
| public void | setUserData(Object
the object to store or null to remove any existing reference data)NON-DOM: As an alternative to subclassing the DOM, this implementation has been extended with the ability to attach an object to each node. |
| protected void | |
| public String | |
| private void |