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, getPreviousSibling
cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getFeature, getLocalName, getNamespaceURI, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getPrefix, getUserData, hasAttributes, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, setNodeValue, setPrefix, setTextContent, setUserData
protected InnerNodeImpl(DocumentImpl document)
public Node appendChild(Node newChild) throws DOMException
Node
newChild
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 Node
appendChild
in class NodeImpl
newChild
- 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()
Node
NodeList
that contains all children of this node. If
there are no children, this is a NodeList
containing no
nodes.getChildNodes
in interface Node
getChildNodes
in class NodeImpl
public Node getFirstChild()
Node
null
.getFirstChild
in interface Node
getFirstChild
in class NodeImpl
public Node getLastChild()
Node
null
.getLastChild
in interface Node
getLastChild
in class NodeImpl
public Node getNextSibling()
Node
null
.getNextSibling
in interface Node
getNextSibling
in class LeafNodeImpl
public boolean hasChildNodes()
Node
hasChildNodes
in interface Node
hasChildNodes
in class NodeImpl
true
if this node has any children,
false
otherwise.public Node insertBefore(Node newChild, Node refChild) throws DOMException
Node
newChild
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 Node
insertBefore
in class NodeImpl
newChild
- 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
Node
oldChild
from the list
of children, and returns it.removeChild
in interface Node
removeChild
in class NodeImpl
oldChild
- 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 Node
replaceChild
in class NodeImpl
newChild
- 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
Node
null
, 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 Node
getTextContent
in class NodeImpl
DOMException
- DOMSTRING_SIZE_ERR: Raised when it would return more characters than
fit in a DOMString
variable on the implementation
platform.