Top Description Fields Constructors Methods
com.sun.org.apache.xerces.internal.dom

public abstract Class NodeImpl

extends Object
implements Node, NodeList, EventTarget, Cloneable, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.lang.Cloneable, org.w3c.dom.events.EventTarget, org.w3c.dom.NodeList, org.w3c.dom.Node
Known Direct Subclasses
com.sun.org.apache.xerces.internal.dom.NotationImpl, com.sun.org.apache.xerces.internal.dom.AttrImpl, com.sun.org.apache.xerces.internal.dom.ChildNode
Imports
java.io.IOException, .ObjectOutputStream, .Serializable, java.util.Map, org.w3c.dom.DOMException, .Document, .DocumentType, .Element, .NamedNodeMap, .Node, .NodeList, .UserDataHandler, org.w3c.dom.events.Event, .EventListener, .EventTarget

NodeImpl provides the basic structure of a DOM tree. It is never used directly, but instead is subclassed to add type and data information, and additional methods, appropriate to each node of the tree. Only its subclasses should be instantiated -- and those, with the exception of Document itself, only through a specific Document's factory methods.

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.

Authors
Arnaud Le Hors, IBM, Joe Kesselman, IBM
Since
PR-DOM-Level-1-19980818.

Field Summary

Modifier and TypeField 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.

Constructor Summary

AccessConstructor 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
NodeImpl()

Constructor for serialization.

Method Summary

Modifier and TypeMethod and Description
public void
addEventListener(String
The event type for which the user is registering
type
,
EventListener
The listener parameter takes an interface implemented by the user which contains the methods to be called when the event occurs.
listener
,
boolean
If true, 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.
useCapture
)

Implements org.w3c.dom.events.EventTarget.addEventListener.

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.)
appendChild
(Node
The node to add.If it is a DocumentFragment object, the entire contents of the document fragment are moved into the child list of this node
newChild
)

Implements org.w3c.dom.Node.appendChild.

Adds a child node to the end of the list of children for this node.

protected void
changed()

Denotes that this node has changed.

protected int
changes()

Returns the number of changes to this node.

public Node
cloneNode(boolean
If true, recursively clone the subtree under the specified node; if false, clone only the node itself (and its attributes, if it is an Element).
deep
)

Implements org.w3c.dom.Node.cloneNode.

Returns a duplicate of a given node.

public short

Returns:

Returns how the given node is positioned relatively to this node.
compareDocumentPosition
(Node
The node to compare against this node.
other
)

Implements org.w3c.dom.Node.compareDocumentPosition.

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.
compareTreePosition
(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.w3c.dom.events.EventTarget.dispatchEvent.

This method allows the dispatch of events into the implementations event model.

public NamedNodeMap
getAttributes()

Implements org.w3c.dom.Node.getAttributes.

Return the collection of attributes associated with this node, or null if none.

public String
getBaseURI()

Implements org.w3c.dom.Node.getBaseURI.

The absolute base URI of this node or null if undefined.

public NodeList
getChildNodes()

Implements org.w3c.dom.Node.getChildNodes.

Obtain a NodeList enumerating all children of this node.

protected Node
getContainer()

For non-child nodes, the node which "points" to this node.

pack-priv Node
getElementAncestor(Node currentNode)

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.w3c.dom.Node.getFeature.

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.w3c.dom.Node.getFirstChild.

The first child of this Node, or null if none.

public Node
getLastChild()

Implements org.w3c.dom.Node.getLastChild.

The first child of this Node, or null if none.

public int

Returns:

int
getLength
()

Implements org.w3c.dom.NodeList.getLength.

NodeList method: Count the immediate children of this node

By default we do not have any children, ParentNode overrides this.

public String
getLocalName()

Implements org.w3c.dom.Node.getLocalName.

Introduced in DOM Level 2.

public String
getNamespaceURI()

Implements org.w3c.dom.Node.getNamespaceURI.

Introduced in DOM Level 2.

public Node
getNextSibling()

Implements org.w3c.dom.Node.getNextSibling.

The next child of this node's parent, or null if none

public abstract String
getNodeName()

Redeclares org.w3c.dom.Node.getNodeName.

the name of this node.

protected int
getNodeNumber()

Returns the node number

public abstract short
getNodeType()

Redeclares org.w3c.dom.Node.getNodeType.

A short integer indicating what type of node this is.

public String
getNodeValue()

Implements org.w3c.dom.Node.getNodeValue.

Returns the node value.

public Document
getOwnerDocument()

Implements org.w3c.dom.Node.getOwnerDocument.

Find the Document that this Node belongs to (the document in whose context the Node was created).

public Node
getParentNode()

Implements org.w3c.dom.Node.getParentNode.

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
getPrefix()

Implements org.w3c.dom.Node.getPrefix.

Introduced in DOM Level 2.

public Node
getPreviousSibling()

Implements org.w3c.dom.Node.getPreviousSibling.

The previous child of this node's parent, or null if none

public boolean
getReadOnly()

NON-DOM: Returns true if this node is read-only.

public String
getTextContent()

Implements org.w3c.dom.Node.getTextContent.

This attribute returns the text content of this node and its descendants.

pack-priv void
public Object

Returns:

Returns the DOMObject associated to the given key on this node, or null if there was none.
getUserData
(String
The key the object is associated to.
key
)

Implements org.w3c.dom.Node.getUserData.

Retrieves the object associated to a key on a this node.

public Object
getUserData()

NON-DOM: Returns the user data associated to this node.

protected Map<String, ParentNode.UserDataRecord>
public boolean

Returns:

true if this node has any attributes, false otherwise.
hasAttributes
()

Implements org.w3c.dom.Node.hasAttributes.

Returns whether this node (if it is an element) has any attributes.

public boolean
hasChildNodes()

Implements org.w3c.dom.Node.hasChildNodes.

Test whether this node has any children.

pack-priv final boolean
pack-priv final void
hasStringValue(boolean value)

public Node

Returns:

newChild, in its new state (relocated, or emptied in the case of DocumentNode.)
insertBefore
(Node
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.w3c.dom.Node.insertBefore.

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.
isDefaultNamespace
(String
The namespace URI to look for.
namespaceURI
)

Implements org.w3c.dom.Node.isDefaultNamespace.

DOM Level 3: Experimental This method checks if the specified namespaceURI is the default namespace or not.

public boolean

Returns:

If the nodes, and possibly subtrees are equal, true otherwise false.
isEqualNode
(Node
The node to compare equality with.
arg
)

Implements org.w3c.dom.Node.isEqualNode.

Tests whether two nodes are equal.

pack-priv final boolean
pack-priv final void
isFirstChild(boolean value)

pack-priv final boolean
pack-priv final void
isIdAttribute(boolean value)

pack-priv final void
isIgnorableWhitespace(boolean value)

pack-priv final boolean
pack-priv final void
isNormalized(boolean value)

pack-priv final boolean
pack-priv final void
isOwned(boolean value)

pack-priv final boolean
pack-priv final void
isReadOnly(boolean value)

public boolean

Returns:

Returns true if the nodes are the same, false otherwise.
isSameNode
(Node
The node to test against.
other
)

Implements org.w3c.dom.Node.isSameNode.

Returns whether this node is the same node as the given one.

pack-priv final boolean
pack-priv final void
isSpecified(boolean value)

public boolean

Returns:

boolean Returns true if this node defines a subtree within which the specified feature is supported, false otherwise.
isSupported
(String
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.w3c.dom.Node.isSupported.

Introduced in DOM Level 2.

public Node

Returns:

org.w3c.dom.Node
item
(int
int
index
)

Implements org.w3c.dom.NodeList.item.

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 namespace
lookupNamespaceURI
(String specifiedPrefix)

Implements org.w3c.dom.Node.lookupNamespaceURI.

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 namespace
lookupPrefix
(String namespaceURI)

Implements org.w3c.dom.Node.lookupPrefix.

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
needsSyncChildren(boolean value)

pack-priv final boolean
pack-priv final void
needsSyncData(boolean value)

public void
normalize()

Implements org.w3c.dom.Node.normalize.

Puts all 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).
removeChild
(Node
The node being removed.
oldChild
)

Implements org.w3c.dom.Node.removeChild.

Remove a child from this Node.

public void
removeEventListener(String
Specifies the event type of the EventListener being removed.
type
,
EventListener
The EventListener parameter indicates the EventListener to be removed.
listener
,
boolean
Specifies whether the 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.
useCapture
)

Implements org.w3c.dom.events.EventTarget.removeEventListener.

This method allows the removal of event listeners from the event target.

public Node

Returns:

oldChild, in its new state (removed).
replaceChild
(Node
The new node to put in the child list.
newChild
,
Node
The node being replaced in the list.
oldChild
)

Implements org.w3c.dom.Node.replaceChild.

Make newChild occupy the location that oldChild used to have.

public void
setNodeValue(String x)

Implements org.w3c.dom.Node.setNodeValue.

Sets the node value.

protected void
setOwnerDocument(CoreDocumentImpl doc)

NON-DOM set the ownerDocument of this node

public void
setPrefix(String prefix)

Implements org.w3c.dom.Node.setPrefix.

Introduced in DOM Level 2.

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.w3c.dom.Node.setTextContent.

This attribute returns the text content of this node and its descendants.

public Object

Returns:

Returns the DOMObject previously associated to the given key on this node, or null if there was none.
setUserData
(String
The key to associate the object to.
key
,
Object
The object to associate to the given key, or null to remove any existing association to that key.
data
,
UserDataHandler
The handler to associate to that key, or null.
handler
)

Implements org.w3c.dom.Node.setUserData.

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
synchronizeData()

Override this method in subclass to hook in efficient internal data structure.

public String
toString()

Overrides java.lang.Object.toString.

NON-DOM method for debugging convenience.

private void
writeObject(ObjectOutputStream out)

Serialize object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait