public abstract class InnerNodeImpl extends LeafNodeImpl
Some of the fields may have package visibility, so other classes belonging to the DOM implementation can easily access them while maintaining the DOM tree structure.
This class represents a Node that has a parent Node as well as (potentially) a number of children.
Some code was adapted from Apache Xerces.
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE| Modifier | Constructor and Description |
|---|---|
protected |
InnerNodeImpl(DocumentImpl document) |
| Modifier and Type | Method and Description |
|---|---|
Node |
appendChild(Node newChild)
Adds the node
newChild to the end of the list of children
of this node. |
NodeList |
getChildNodes()
A
NodeList that contains all children of this node. |
Node |
getFirstChild()
The first child of this node.
|
Node |
getLastChild()
The last child of this node.
|
Node |
getNextSibling()
The node immediately following this node.
|
String |
getTextContent()
This attribute returns the text content of this node and its
descendants.
|
boolean |
hasChildNodes()
Returns whether this node has any children.
|
Node |
insertBefore(Node newChild,
Node refChild)
Inserts the node
newChild before the existing child node
refChild. |
boolean |
isParentOf(Node node) |
void |
normalize()
Normalize the text nodes within this subtree.
|
Node |
removeChild(Node oldChild)
Removes the child node indicated by
oldChild from the list
of children, and returns it. |
Node |
replaceChild(Node newChild,
Node oldChild)
Removes
oldChild and adds newChild in its place. |
getParentNode, getPreviousSiblingcloneNode, compareDocumentPosition, getAttributes, getBaseURI, getFeature, getLocalName, getNamespaceURI, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getPrefix, getUserData, hasAttributes, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, setNodeValue, setPrefix, setTextContent, setUserDataprotected InnerNodeImpl(DocumentImpl document)
public Node appendChild(Node newChild) throws DOMException
NodenewChild to the end of the list of children
of this node. If the newChild is already in the tree, it
is first removed.appendChild in interface NodeappendChild in class NodeImplnewChild - 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 nodeDOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild node, or if
the node to append is one of this node's ancestors or this node
itself, or if this node is of type Document and the
DOM application attempts to append a second
DocumentType or Element node.
newChild was created
from a different document than the one that created this node.
newChild node is a child
of the Document node, this exception might be raised
if the DOM implementation doesn't support the removal of the
DocumentType child or Element child.public NodeList getChildNodes()
NodeNodeList that contains all children of this node. If
there are no children, this is a NodeList containing no
nodes.getChildNodes in interface NodegetChildNodes in class NodeImplpublic Node getFirstChild()
Nodenull.getFirstChild in interface NodegetFirstChild in class NodeImplpublic Node getLastChild()
Nodenull.getLastChild in interface NodegetLastChild in class NodeImplpublic Node getNextSibling()
Nodenull.getNextSibling in interface NodegetNextSibling in class LeafNodeImplpublic boolean hasChildNodes()
NodehasChildNodes in interface NodehasChildNodes in class NodeImpltrue if this node has any children,
false otherwise.public Node insertBefore(Node newChild, Node refChild) throws DOMException
NodenewChild before the existing child node
refChild. If refChild is null,
insert newChild at the end of the list of children.
newChild is a DocumentFragment object,
all of its children are inserted, in the same order, before
refChild. If the newChild is already in the
tree, it is first removed.
Note: Inserting a node before itself is implementation dependent.
insertBefore in interface NodeinsertBefore in class NodeImplnewChild - The node to insert.refChild - The reference node, i.e., the node before which the
new node must be inserted.DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild node, or if
the node to insert is one of this node's ancestors or this node
itself, or if this node is of type Document and the
DOM application attempts to insert a second
DocumentType or Element node.
newChild was created
from a different document than the one that created this node.
refChild is not a child of
this node.
Document,
this exception might be raised if the DOM implementation doesn't
support the insertion of a DocumentType or
Element node.public boolean isParentOf(Node node)
public final void normalize()
public Node removeChild(Node oldChild) throws DOMException
NodeoldChild from the list
of children, and returns it.removeChild in interface NoderemoveChild in class NodeImploldChild - The node being removed.DOMException - NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
oldChild is not a child of
this node.
Document,
this exception might be raised if the DOM implementation doesn't
support the removal of the DocumentType child or the
Element child.public Node replaceChild(Node newChild, Node oldChild) throws DOMException
oldChild and adds newChild in its place. This
is not atomic.replaceChild in interface NodereplaceChild in class NodeImplnewChild - The new node to put in the child list.oldChild - The node being replaced in the list.DOMException - HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
allow children of the type of the newChild node, or if
the node to put in is one of this node's ancestors or this node
itself, or if this node is of type Document and the
result of the replacement operation would add a second
DocumentType or Element on the
Document node.
newChild was created
from a different document than the one that created this node.
oldChild is not a child of
this node.
Document,
this exception might be raised if the DOM implementation doesn't
support the replacement of the DocumentType child or
Element child.public String getTextContent() throws DOMException
Nodenull, setting it
has no effect. On setting, any possible children this node may have
are removed and, if it the new string is not empty or
null, replaced by a single Text node
containing the string this attribute is set to.
Text.isElementContentWhitespace). Similarly, on setting,
no parsing is performed either, the input string is taken as pure
textual content.
| Node type | Content |
|---|---|
| ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE | concatenation of the textContent
attribute value of every child node, excluding COMMENT_NODE and
PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the
node has no children. |
| TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE | nodeValue |
| DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE | null |
getTextContent in interface NodegetTextContent in class NodeImplDOMException - DOMSTRING_SIZE_ERR: Raised when it would return more characters than
fit in a DOMString variable on the implementation
platform.