| 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.EntityReferenceImpl, org.apache.xerces.dom.DocumentTypeImpl, org.apache.xerces.dom.DocumentFragmentImpl, org.apache.xerces.dom.ElementDefinitionImpl, org.apache.xerces.dom.ElementImpl, org.apache.xerces.dom.CoreDocumentImpl, org.apache.xerces.dom.EntityImpl,
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 version: $Id: ParentNode.java 447266 2006-09-18 05:57:49Z mrglavas $ |
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 String | getTextContent() | void | getTextContent(StringBuffer buf) | public boolean | hasChildNodes() Test whether this node has any children. | final boolean | hasTextContent(Node child) | 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 boolean | isEqualNode(Node arg) DOM Level 3 WD- Experimental. | 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. | protected void | setOwnerDocument(CoreDocumentImpl doc) | public void | setReadOnly(boolean readOnly, boolean deep) Override default behavior so that if deep is true, children are also
toggled. | public void | setTextContent(String textContent) | protected void | synchronizeChildren() Override this method in subclass to hook in efficient
internal data structure. |
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)
|
hasTextContent | final boolean hasTextContent(Node child)(Code) | | |
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(). newChild, in its new state (relocated, or emptied in the case ofDocumentNode.) 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.
|
isEqualNode | public boolean isEqualNode(Node arg)(Code) | | DOM Level 3 WD- Experimental.
Override inherited behavior from NodeImpl to support deep equal.
|
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.
oldChild, in its new state (removed). 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 | protected 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.
|
Methods inherited from org.apache.xerces.dom.NodeImpl | public void addEventListener(String type, EventListener listener, boolean useCapture)(Code)(Java Doc) public Node appendChild(Node newChild) throws DOMException(Code)(Java Doc) protected void changed()(Code)(Java Doc) protected int changes()(Code)(Java Doc) public Node cloneNode(boolean deep)(Code)(Java Doc) public short compareDocumentPosition(Node other) throws DOMException(Code)(Java Doc) public short compareTreePosition(Node other)(Code)(Java Doc) public boolean dispatchEvent(Event event)(Code)(Java Doc) public NamedNodeMap getAttributes()(Code)(Java Doc) public String getBaseURI()(Code)(Java Doc) public NodeList getChildNodes()(Code)(Java Doc) protected Node getContainer()(Code)(Java Doc) Node getElementAncestor(Node currentNode)(Code)(Java Doc) public Object getFeature(String feature, String version)(Code)(Java Doc) public Node getFirstChild()(Code)(Java Doc) public Node getLastChild()(Code)(Java Doc) public int getLength()(Code)(Java Doc) public String getLocalName()(Code)(Java Doc) public String getNamespaceURI()(Code)(Java Doc) public Node getNextSibling()(Code)(Java Doc) abstract public String getNodeName()(Code)(Java Doc) protected int getNodeNumber()(Code)(Java Doc) abstract public short getNodeType()(Code)(Java Doc) public String getNodeValue() throws DOMException(Code)(Java Doc) public Document getOwnerDocument()(Code)(Java Doc) public Node getParentNode()(Code)(Java Doc) public String getPrefix()(Code)(Java Doc) public Node getPreviousSibling()(Code)(Java Doc) public boolean getReadOnly()(Code)(Java Doc) public String getTextContent() throws DOMException(Code)(Java Doc) void getTextContent(StringBuffer buf) throws DOMException(Code)(Java Doc) public Object getUserData(String key)(Code)(Java Doc) public Object getUserData()(Code)(Java Doc) protected Hashtable getUserDataRecord()(Code)(Java Doc) public boolean hasAttributes()(Code)(Java Doc) public boolean hasChildNodes()(Code)(Java Doc) final boolean hasStringValue()(Code)(Java Doc) final void hasStringValue(boolean value)(Code)(Java Doc) public Node insertBefore(Node newChild, Node refChild) throws DOMException(Code)(Java Doc) final boolean internalIsIgnorableWhitespace()(Code)(Java Doc) public boolean isDefaultNamespace(String namespaceURI)(Code)(Java Doc) public boolean isEqualNode(Node arg)(Code)(Java Doc) final boolean isFirstChild()(Code)(Java Doc) final void isFirstChild(boolean value)(Code)(Java Doc) final boolean isIdAttribute()(Code)(Java Doc) final void isIdAttribute(boolean value)(Code)(Java Doc) final void isIgnorableWhitespace(boolean value)(Code)(Java Doc) final boolean isNormalized()(Code)(Java Doc) final void isNormalized(boolean value)(Code)(Java Doc) final boolean isOwned()(Code)(Java Doc) final void isOwned(boolean value)(Code)(Java Doc) final boolean isReadOnly()(Code)(Java Doc) final void isReadOnly(boolean value)(Code)(Java Doc) public boolean isSameNode(Node other)(Code)(Java Doc) final boolean isSpecified()(Code)(Java Doc) final void isSpecified(boolean value)(Code)(Java Doc) public boolean isSupported(String feature, String version)(Code)(Java Doc) public Node item(int index)(Code)(Java Doc) String lookupNamespacePrefix(String namespaceURI, ElementImpl el)(Code)(Java Doc) public String lookupNamespaceURI(String specifiedPrefix)(Code)(Java Doc) public String lookupPrefix(String namespaceURI)(Code)(Java Doc) final boolean needsSyncChildren()(Code)(Java Doc) final public void needsSyncChildren(boolean value)(Code)(Java Doc) final boolean needsSyncData()(Code)(Java Doc) final void needsSyncData(boolean value)(Code)(Java Doc) public void normalize()(Code)(Java Doc) CoreDocumentImpl ownerDocument()(Code)(Java Doc) NodeImpl parentNode()(Code)(Java Doc) ChildNode previousSibling()(Code)(Java Doc) public Node removeChild(Node oldChild) throws DOMException(Code)(Java Doc) public void removeEventListener(String type, EventListener listener, boolean useCapture)(Code)(Java Doc) public Node replaceChild(Node newChild, Node oldChild) throws DOMException(Code)(Java Doc) public void setNodeValue(String x) throws DOMException(Code)(Java Doc) protected void setOwnerDocument(CoreDocumentImpl doc)(Code)(Java Doc) public void setPrefix(String prefix) throws DOMException(Code)(Java Doc) public void setReadOnly(boolean readOnly, boolean deep)(Code)(Java Doc) public void setTextContent(String textContent) throws DOMException(Code)(Java Doc) public Object setUserData(String key, Object data, UserDataHandler handler)(Code)(Java Doc) public void setUserData(Object data)(Code)(Java Doc) protected void synchronizeData()(Code)(Java Doc) public String toString()(Code)(Java Doc)
|
|
|