public abstract class ParentNodeImpl extends NodeImpl implements Node, Cloneable
NodeImpl
,
while nodes that support child elements are extended from ParentNodeImpl
containing the additional member variables required to
support child nodes.
This class is abstract. All derived classes must extend NodeImpl.getNodeType()
. In addition, derived classes might wish to extend Node.cloneNode(boolean)
, equals(java.lang.Object)
and Object.toString()
and othe methods as necessary. Many methods cannot be extended.
Node
,
NodeImpl
ATTLIST_DECL_NODE, ELEMENT_DECL_NODE, PARAM_ENTITY_NODE
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 |
ParentNodeImpl(DocumentImpl owner,
String name,
String value)
Hidden constructor creates a new node.
|
Modifier and Type | Method and Description |
---|---|
Node |
appendChild(Node newChild)
Insert newChild as the last child of this parent.
|
protected NodeImpl |
castNewChild(Node newChild)
Checks whether newChild can be added to this node as a child,
and if so, performs a necessary cast.
|
protected NodeImpl |
castOldChild(Node oldChild)
Checks whether oldChild is a direct child of this node, and
if so, performs a necessary cast.
|
protected void |
cloneInto(NodeImpl into,
boolean deep)
This clone method is called after a new node has been constructed to
copy the contents of this node into the new one.
|
protected org.w3c.dom.traversal.NodeIterator |
createNodeIterator(boolean tree,
int whatToShow,
org.w3c.dom.traversal.NodeFilter nodeFilter) |
boolean |
equals(Object other)
Returns true if this node and other are identical by content but
not context.
|
NodeList |
getChildNodes()
Returns a
NodeList object that can be used to traverse this
node's children. |
Node |
getFirstChild()
Returns the first child of the node.
|
Node |
getLastChild()
Returns the last child of the node.
|
boolean |
hasChildNodes()
Return true if there are any childern to this node.
|
Node |
insertBefore(Node newChild,
Node refChild)
Insert newChild in this parent, before the existing child
refChild.
|
void |
normalize() |
Node |
removeChild(Node oldChild)
Remove oldChild from this parent.
|
void |
removeInnerIterator(InnerIterator iterator) |
Node |
replaceChild(Node newChild,
Node oldChild)
Replace oldChild with newChild, adding the new child
and removing the old one.
|
getAttributes, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, isReadOnly, makeReadOnly, setNodeValue, setOwnerDocument, setPrefix, supports
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getFeature, getLocalName, getNamespaceURI, getNextSibling, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getParentNode, getPrefix, getPreviousSibling, getTextContent, getUserData, hasAttributes, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, setNodeValue, setPrefix, setTextContent, setUserData
protected ParentNodeImpl(DocumentImpl owner, String name, String value) throws DOMException
DocumentImpl
or DocumentTypeImpl
,
If checkName is true, the supplied named is assumed to be a valid XML name token, one that can contain any Unicode letters and digits, must start with a letter, and may also contain hyphen, underscore, digit or colon.
owner
- Document owner of this node, or nullname
- Name of nodevalue
- Initial value of node or nullDOMException
- INVALID_CHARACTER_ERR
Node name cannot contain whitespace or non-printable characterspublic final NodeList getChildNodes()
NodeImpl
NodeList
object that can be used to traverse this
node's children. The node list is live, so every change to this node
is reflected in it. If the node does not support children, returns
an empty node list.getChildNodes
in interface Node
getChildNodes
in class NodeImpl
NodeList
on this nodeNodeList
public final Node getFirstChild()
NodeImpl
getFirstChild
in interface Node
getFirstChild
in class NodeImpl
public final Node getLastChild()
NodeImpl
getLastChild
in interface Node
getLastChild
in class NodeImpl
public final boolean hasChildNodes()
NodeImpl
NodeImpl.getChildNodes()
.hasChildNodes
in interface Node
hasChildNodes
in class NodeImpl
public void normalize()
public final Node appendChild(Node newChild)
NodeImpl
If newChild is null, newChild is not a compatible type, or childern are not supported by this node type, an exception is thrown.
newChild is removed from its original parent before adding to
this parent. If newChild is a DocumentFragment
, all
its children are inserted one by one into this parent.
appendChild
in interface Node
appendChild
in class NodeImpl
newChild
- The new child to addpublic final Node insertBefore(Node newChild, Node refChild) throws DOMException
NodeImpl
NodeImpl.appendChild(org.w3c.dom.Node)
.
If newChild is null, newChild does not belong to this DOM, refChild is not a direct child of this node, or childern are not supported by this node type, an exception is thrown.
newChild is removed from its original parent before adding
to this parent. If newChild is a DocumentFragment
, all
its children are inserted one by one into this parent.
insertBefore
in interface Node
insertBefore
in class NodeImpl
newChild
- The new child to addrefChild
- Insert new child before this child, or insert at the end
if this child is nullDOMException
- NO_MODIFICATION_ALLOWED_ERR
Node is read-only and cannot be modifiedpublic final Node removeChild(Node oldChild) throws DOMException
NodeImpl
removeChild
in interface Node
removeChild
in class NodeImpl
oldChild
- The child to removeDOMException
- NO_MODIFICATION_ALLOWED_ERR
Node is read-only and cannot be modifiedpublic final Node replaceChild(Node newChild, Node oldChild) throws DOMException
NodeImpl
If newChild does not belong to this DOM, oldChild is not a direct child of this parent, or childern are not supported by this node type, an exception is thrown.
newChild is removed from its original parent before adding to
this parent. If newChild is a DocumentFragment
, all
its children are inserted one by one into this parent.
replaceChild
in interface Node
replaceChild
in class NodeImpl
newChild
- The new child to addoldChild
- The old child to take awayDOMException
- NO_MODIFICATION_ALLOWED_ERR
Node is read-only and cannot be modifiedprotected NodeImpl castNewChild(Node newChild) throws DOMException
The following rules govern the allowed newChild types:
Attr
, newChild must be
either a Text
or an EntityReference
DocumentType
, newChild must be
either an Entity
or a Notation
.
Element
, a CharacterData
derived type, a DocumentFragment
, an EntityReference
or a ProcessingInstruction
.
newChild
- New child nodeNodeImpl
DOMException
- HIERARCHY_REQUEST_ERR
newChild is null, does not belong to this DOM, or its node
type is not supported for this parentprotected final NodeImpl castOldChild(Node oldChild) throws DOMException
oldChild
- Old child nodeNodeImpl
DOMException
- NOT_FOUND_ERR
oldChild is null, or not a direct child of this nodeprotected org.w3c.dom.traversal.NodeIterator createNodeIterator(boolean tree, int whatToShow, org.w3c.dom.traversal.NodeFilter nodeFilter)
public void removeInnerIterator(InnerIterator iterator)
protected void cloneInto(NodeImpl into, boolean deep)
NodeImpl
NodeImpl.equals(java.lang.Object)
).
into must be a valid node of the exact same class as this one. deep is true if deep cloning (includes all children nodes) is to be performed. If deep is false, the clone might not pass the equality test.
Derived classes override and call this method to add per-class variable
copying. This method is called by Node.cloneNode(boolean)
and the default
Object.clone()
method.
Contents cloning duplicates the node's name and value, and its children. It does not duplicate it's context, that is, the node's parent or sibling. Initially a clone node has no parents or siblings. However, the node does belong to the same document, since all nodes must belong to some document. The cloned node is never read-only.
public boolean equals(Object other)
NodeImpl
NodeImpl.equals(java.lang.Object)
on each pair
Note that for large document roots, the equality operation can be very expensive.
Phantom® and NetPhantom® are registered trademarks of Mindus SARL.
© © Mindus SARL, 2024. All rights reserved.