| java.lang.Object org.apache.xerces.dom.NodeImpl org.apache.xerces.dom.ChildNode org.apache.xerces.dom.ParentNode
All known Subclasses: org.apache.xerces.dom.ElementDefinitionImpl, org.apache.xerces.dom.DocumentFragmentImpl, org.apache.xerces.dom.EntityImpl, org.apache.xerces.dom.ElementImpl, org.apache.xerces.dom.DocumentTypeImpl, org.apache.xerces.dom.CoreDocumentImpl, org.apache.xerces.dom.EntityReferenceImpl,
ParentNode | abstract public class ParentNode extends ChildNode (Code) | | ParentNode inherits from ChildNode and adds the capability of having child
nodes. Not every node in the DOM can have children, so only nodes that can
should inherit from this class and pay the price for it.
ParentNode, just like 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. On the other hand, subclasses may need to override
this, in case of conflicting names. This is the case for the classes
HTMLSelectElementImpl and HTMLFormElementImpl of the HTML DOM.
While we have a direct reference to the first child, the last child is
stored as the previous sibling of the first child. First child nodes are
marked as being so, and getNextSibling hides this fact.
Note: Not all parent nodes actually need to also be a child. At some
point we used to have ParentNode inheriting from NodeImpl and another class
called ChildAndParentNode that inherited from ChildNode. But due to the lack
of multiple inheritance a lot of code had to be duplicated which led to a
maintenance nightmare. At the same time only a few nodes (Document,
DocumentFragment, Entity, and Attribute) cannot be a child so the gain in
memory wasn't really worth it. The only type for which this would be the
case is Attribute, but we deal with there in another special way, so this is
not applicable.
This class doesn't directly support mutation events, however, it notifies
the document when mutations are performed so that the document class do so.
WARNING: Some of the code here is partially duplicated in
AttrImpl, be careful to keep these two classes in sync!
author: Arnaud Le Hors, IBM author: Joe Kesselman, IBM author: Andy Clark, IBM |
Method Summary | |
void | checkNormalizationAfterInsert(ChildNode insertedChild) Checks the normalized state of this node after inserting a child. | void | checkNormalizationAfterRemove(ChildNode previousSibling) Checks the normalized of this node after removing a child. | public Node | cloneNode(boolean deep) Returns a duplicate of a given node. | public NodeList | getChildNodes() Obtain a NodeList enumerating all children of this node. | final protected NodeList | getChildNodesUnoptimized() Create a NodeList to access children that is use by subclass elements
that have methods named getLength() or item(int). | public Node | getFirstChild() The first child of this Node, or null if none. | public Node | getLastChild() The last child of this Node, or null if none. | public int | getLength() | public Document | getOwnerDocument() Find the Document that this Node belongs to (the document in
whose context the Node was created). | public boolean | hasChildNodes() Test whether this node has any children. | public Node | insertBefore(Node newChild, Node refChild) Move one or more node(s) to our list of children. | Node | internalInsertBefore(Node newChild, Node refChild, boolean replace) NON-DOM INTERNAL: Within DOM actions,we sometimes need to be able
to control which mutation events are spawned. | Node | internalRemoveChild(Node oldChild, boolean replace) NON-DOM INTERNAL: Within DOM actions,we sometimes need to be able
to control which mutation events are spawned. | public Node | item(int index) NodeList method: Return the Nth immediate child of this node, or
null if the index is out of bounds. | final ChildNode | lastChild() | final void | lastChild(ChildNode node) | public void | normalize() Override default behavior to call normalize() on this Node's
children. | CoreDocumentImpl | ownerDocument() | public Node | removeChild(Node oldChild) Remove a child from this Node. | public Node | replaceChild(Node newChild, Node oldChild) Make newChild occupy the location that oldChild used to
have. | void | setOwnerDocument(CoreDocumentImpl doc) | public void | setReadOnly(boolean readOnly, boolean deep) Override default behavior so that if deep is true, children are also
toggled. | protected void | synchronizeChildren() Override this method in subclass to hook in efficient
internal data structure. |
fCachedChild | protected transient ChildNode fCachedChild(Code) | | Last requested node.
|
fCachedChildIndex | protected transient int fCachedChildIndex(Code) | | Last requested node index.
|
fCachedLength | protected transient int fCachedLength(Code) | | Cached node list length.
|
serialVersionUID | final static long serialVersionUID(Code) | | Serialization version.
|
ParentNode | protected ParentNode(CoreDocumentImpl ownerDocument)(Code) | | No public constructor; only subclasses of ParentNode should be
instantiated, and those normally via a Document's factory methods
|
ParentNode | public ParentNode()(Code) | | Constructor for serialization.
|
checkNormalizationAfterInsert | void checkNormalizationAfterInsert(ChildNode insertedChild)(Code) | | Checks the normalized state of this node after inserting a child.
If the inserted child causes this node to be unnormalized, then this
node is flagged accordingly.
The conditions for changing the normalized state are:
- The inserted child is a text node and one of its adjacent siblings
is also a text node.
- The inserted child is is itself unnormalized.
Parameters: insertedChild - the child node that was inserted into this node throws: NullPointerException - if the inserted child is null |
checkNormalizationAfterRemove | void checkNormalizationAfterRemove(ChildNode previousSibling)(Code) | | Checks the normalized of this node after removing a child.
If the removed child causes this node to be unnormalized, then this
node is flagged accordingly.
The conditions for changing the normalized state are:
- The removed child had two adjacent siblings that were text nodes.
Parameters: previousSibling - the previous sibling of the removed child, ornull |
cloneNode | public Node cloneNode(boolean deep)(Code) | | Returns a duplicate of a given node. You can consider this a
generic "copy constructor" for nodes. The newly returned object should
be completely independent of the source object's subtree, so changes
in one after the clone has been made will not affect the other.
Example: Cloning a Text node will copy both the node and the text it
contains.
Example: Cloning something that has children -- Element or Attr, for
example -- will _not_ clone those children unless a "deep clone"
has been requested. A shallow clone of an Attr node will yield an
empty Attr of the same name.
NOTE: Clones will always be read/write, even if the node being cloned
is read-only, to permit applications using only the DOM API to obtain
editable copies of locked portions of the tree.
|
getChildNodes | public NodeList getChildNodes()(Code) | | Obtain a NodeList enumerating all children of this node. If there
are none, an (initially) empty NodeList is returned.
NodeLists are "live"; as children are added/removed the NodeList
will immediately reflect those changes. Also, the NodeList refers
to the actual nodes, so changes to those nodes made via the DOM tree
will be reflected in the NodeList and vice versa.
In this implementation, Nodes implement the NodeList interface and
provide their own getChildNodes() support. Other DOMs may solve this
differently.
|
getChildNodesUnoptimized | final protected NodeList getChildNodesUnoptimized()(Code) | | Create a NodeList to access children that is use by subclass elements
that have methods named getLength() or item(int). ChildAndParentNode
optimizes getChildNodes() by implementing NodeList itself. However if
a subclass Element implements methods with the same name as the NodeList
methods, they will override the actually methods in this class.
To use this method, the subclass should implement getChildNodes() and
have it call this method. The resulting NodeList instance maybe
shared and cached in a transient field, but the cached value must be
cleared if the node is cloned.
|
getFirstChild | public Node getFirstChild()(Code) | | The first child of this Node, or null if none.
|
getLastChild | public Node getLastChild()(Code) | | The last child of this Node, or null if none.
|
getLength | public int getLength()(Code) | | NodeList method: Count the immediate children of this node
int |
getOwnerDocument | public Document getOwnerDocument()(Code) | | Find the Document that this Node belongs to (the document in
whose context the Node was created). The Node may or may not
currently be part of that Document's actual contents.
|
hasChildNodes | public boolean hasChildNodes()(Code) | | Test whether this node has any children. Convenience shorthand
for (Node.getFirstChild()!=null)
|
insertBefore | public Node insertBefore(Node newChild, Node refChild) throws DOMException(Code) | | Move one or more node(s) to our list of children. Note that this
implicitly removes them from their previous parent.
Parameters: newChild - The Node to be moved to our subtree. As aconvenience feature, inserting a DocumentNode will instead insertall its children. Parameters: refChild - Current child which newChild should be placedimmediately before. If refChild is null, the insertion occursafter all existing Nodes, like appendChild(). throws: DOMException - (HIERARCHY_REQUEST_ERR) if newChild is of atype that shouldn't be a child of this node, or if newChild is anancestor of this node. throws: DOMException - (WRONG_DOCUMENT_ERR) if newChild has adifferent owner document than we do. throws: DOMException - (NOT_FOUND_ERR) if refChild is not a child ofthis node. throws: DOMException - (NO_MODIFICATION_ALLOWED_ERR) if this node isread-only. |
internalInsertBefore | Node internalInsertBefore(Node newChild, Node refChild, boolean replace) throws DOMException(Code) | | NON-DOM INTERNAL: Within DOM actions,we sometimes need to be able
to control which mutation events are spawned. This version of the
insertBefore operation allows us to do so. It is not intended
for use by application programs.
|
internalRemoveChild | Node internalRemoveChild(Node oldChild, boolean replace) throws DOMException(Code) | | NON-DOM INTERNAL: Within DOM actions,we sometimes need to be able
to control which mutation events are spawned. This version of the
removeChild operation allows us to do so. It is not intended
for use by application programs.
|
item | public Node item(int index)(Code) | | NodeList method: Return the Nth immediate child of this node, or
null if the index is out of bounds.
org.w3c.dom.Node Parameters: index - int |
normalize | public void normalize()(Code) | | Override default behavior to call normalize() on this Node's
children. It is up to implementors or Node to override normalize()
to take action.
|
ownerDocument | CoreDocumentImpl ownerDocument()(Code) | | same as above but returns internal type and this one is not overridden
by CoreDocumentImpl to return null
|
removeChild | public Node removeChild(Node oldChild) throws DOMException(Code) | | Remove a child from this Node. The removed child's subtree
remains intact so it may be re-inserted elsewhere.
oldChild, in its new state (removed). throws: DOMException - (NOT_FOUND_ERR) if oldChild is not a child ofthis node. throws: DOMException - (NO_MODIFICATION_ALLOWED_ERR) if this node isread-only. |
replaceChild | public Node replaceChild(Node newChild, Node oldChild) throws DOMException(Code) | | Make newChild occupy the location that oldChild used to
have. Note that newChild will first be removed from its previous
parent, if any. Equivalent to inserting newChild before oldChild,
then removing oldChild.
throws: DOMException - (HIERARCHY_REQUEST_ERR) if newChild is of atype that shouldn't be a child of this node, or if newChild isone of our ancestors. throws: DOMException - (WRONG_DOCUMENT_ERR) if newChild has adifferent owner document than we do. throws: DOMException - (NOT_FOUND_ERR) if oldChild is not a child ofthis node. throws: DOMException - (NO_MODIFICATION_ALLOWED_ERR) if this node isread-only. |
setOwnerDocument | void setOwnerDocument(CoreDocumentImpl doc)(Code) | | NON-DOM
set the ownerDocument of this node and its children
|
setReadOnly | public void setReadOnly(boolean readOnly, boolean deep)(Code) | | Override default behavior so that if deep is true, children are also
toggled.
See Also: Node See Also: See Also: Note: this will not change the state of an EntityReference or its See Also: children, which are always read-only.
|
synchronizeChildren | protected void synchronizeChildren()(Code) | | Override this method in subclass to hook in efficient
internal data structure.
|
|
|