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 | 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. This method allows the registration of event listeners on the event target. |
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. Adds a child node to the end of the list of children for this node. |
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. Returns a duplicate of a given node. |
public short | Returns: Returns how the given node is positioned relatively to this node.The node to compare against this node. other)Implements org. Compares a node with this node with regard to their position in the document. |
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. This method allows the dispatch of events into the implementations event model. |
public NamedNodeMap | getAttributes()
Implements org. Return the collection of attributes associated with this node, or null if none. |
public String | getBaseURI()
Implements org. The absolute base URI of this node or |
public NodeList | getChildNodes()
Implements org. Obtain a NodeList enumerating all children of this node. |
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. This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in . |
public Node | getFirstChild()
Implements org. The first child of this Node, or null if none. |
public Node | getLastChild()
Implements org. The first child of this Node, or null if none. |
public int | Returns: intImplements org. NodeList method: Count the immediate children of this node By default we do not have any children, ParentNode overrides this. |
public String | |
public String | |
public Node | getNextSibling()
Implements org. The next child of this node's parent, or null if none |
public abstract String | |
protected int | |
public abstract short | getNodeType()
Redeclares org. A short integer indicating what type of node this is. |
public String | |
public Document | getOwnerDocument()
Implements org. Find the Document that this Node belongs to (the document in whose context the Node was created). |
public Node | getParentNode()
Implements org. Obtain the DOM-tree parent of this node, or null if it is not currently active in the DOM tree (perhaps because it has just been created or removed). |
public String | |
public Node | getPreviousSibling()
Implements org. The previous child of this node's parent, or null if none |
public boolean | |
public String | getTextContent()
Implements org. This attribute returns the text content of this node and its descendants. |
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. Retrieves the object associated to a key on a this node. |
public Object | |
protected Map | |
public boolean | Returns: true if this node has any attributes,
false otherwise.Implements org. Returns whether this node (if it is an element) has any attributes. |
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. Move one or more node(s) to our list of children. |
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. DOM Level 3: Experimental
This method checks if the specified |
public boolean | Returns: If the nodes, and possibly subtrees are equal,true otherwise false .The node to compare equality with. arg)Implements org. Tests whether two nodes are equal. |
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. Returns whether this node is the same node as the given one. |
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. Introduced in DOM Level 2. |
public Node | Returns: org.w3c.dom.Nodeint index)Implements org. NodeList method: Return the Nth immediate child of this node, or null if the index is out of bounds. |
pack-priv String | |
public String | Returns: the URI for the namespaceImplements org. DOM Level 3 - Experimental: Look up the namespace URI associated to the given prefix, starting from this node. |
public String | Returns: the prefix for the namespaceImplements org. DOM Level 3 - Experimental: Look up the prefix associated to the given namespace URI, starting from this node. |
pack-priv final boolean | |
public final void | |
pack-priv final boolean | |
pack-priv final void | |
public void | normalize()
Implements org. Puts all |
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. Remove a child from this Node. |
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. This method allows the removal of event listeners from the event target. |
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. Make newChild occupy the location that oldChild used to have. |
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. This attribute returns the text content of this node and its descendants. |
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. Associate an object to a key on this node. |
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 |