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!
Modifier and Type | Class and Description |
---|---|
pack-priv class |
Modifier and Type | Field and Description |
---|---|
protected ChildNode | firstChild
First child. |
protected transient NodeListCache | fNodeListCache
NodeList cache |
protected CoreDocumentImpl | ownerDocument
Owner document. |
pack-priv static final long | serialVersionUID
Hides com. |
Access | Constructor and Description |
---|---|
protected | ParentNode(CoreDocumentImpl ownerDocument)
No public constructor; only subclasses of ParentNode should be instantiated, and those normally via a Document's factory methods |
public |
Modifier and Type | Method and Description |
---|---|
pack-priv void | checkNormalizationAfterInsert(ChildNode
the child node that was inserted into this node insertedChild)Checks the normalized state of this node after inserting a child. |
pack-priv void | checkNormalizationAfterRemove(ChildNode
the previous sibling of the removed child, or
previousSibling)null Checks the normalized of this node after removing a child. |
public Node | cloneNode(boolean
If deep)true , recursively clone the subtree under
the specified node; if false , clone only the node
itself (and its attributes, if it is an Element ).Overrides com. Implements org. Returns a duplicate of a given node. |
public NodeList | getChildNodes()
Overrides com. Implements org. Obtain a NodeList enumerating all children of this node. |
protected final 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()
Overrides com. Implements org. The first child of this Node, or null if none. |
public Node | getLastChild()
Overrides com. Implements org. The last child of this Node, or null if none. |
public int | Returns: intOverrides com. Implements org. NodeList method: Count the immediate children of this node |
public Document | getOwnerDocument()
Overrides com. Implements org. Find the Document that this Node belongs to (the document in whose context the Node was created). |
public String | getTextContent()
Overrides com. Implements org. This attribute returns the text content of this node and its descendants. |
pack-priv void | |
public boolean | hasChildNodes()
Overrides com. Implements org. Test whether this node has any children. |
pack-priv final boolean | |
public Node | Returns: newChild, in its new state (relocated, or emptied in the case of DocumentNode.)The Node to be moved to our subtree. As a
convenience feature, inserting a DocumentNode will instead insert
all its children. newChild, Node Current child which newChild should be placed
immediately before. If refChild is null, the insertion occurs
after all existing Nodes, like appendChild(). refChild)Overrides com. Implements org. Move one or more node(s) to our list of children. |
pack-priv 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. |
pack-priv 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
The node to compare equality with. arg)Overrides com. Implements org. DOM Level 3 WD- Experimental. |
public Node | Returns: org.w3c.dom.Nodeint index)Overrides com. Implements org. NodeList method: Return the Nth immediate child of this node, or null if the index is out of bounds. |
pack-priv final ChildNode | |
pack-priv final void | |
private int | |
private Node | nodeListItem(int
int index)Return the Nth immediate child of this node, or null if the index is out of bounds. |
public void | normalize()
Overrides com. Implements org. Override default behavior to call normalize() on this Node's children. |
pack-priv CoreDocumentImpl | ownerDocument()
Overrides com. same as above but returns internal type and this one is not overridden by CoreDocumentImpl to return null |
private void | |
public Node | Returns: oldChild, in its new state (removed).The node being removed. oldChild)Overrides com. Implements org. Remove a child from this Node. |
public Node | Returns: oldChild, in its new state (removed).The new node to put in the child list. newChild, Node The node being replaced in the list. oldChild)Overrides com. Implements org. Make newChild occupy the location that oldChild used to have. |
protected void | setOwnerDocument(CoreDocumentImpl doc)
Overrides com. NON-DOM set the ownerDocument of this node and its children |
public void | setReadOnly(boolean
True or false as desired. readOnly, boolean If true, children are also toggled. Note that this will
not change the state of an EntityReference or its children,
which are always read-only. deep)Overrides com. Override default behavior so that if deep is true, children are also toggled. |
public void | setTextContent(String textContent)
Overrides com. Implements org. This attribute returns the text content of this node and its descendants. |
protected void | |
private void | writeObject(ObjectOutputStream out)
Hides com. Serialize object. |
firstChild | back to summary |
---|---|
protected ChildNode firstChild First child. |
fNodeListCache | back to summary |
---|---|
protected transient NodeListCache fNodeListCache NodeList cache |
ownerDocument | back to summary |
---|---|
protected CoreDocumentImpl ownerDocument Owner document. |
serialVersionUID | back to summary |
---|---|
pack-priv static final long serialVersionUID Hides com. Serialization version. |
ParentNode | back to summary |
---|---|
protected ParentNode(CoreDocumentImpl ownerDocument) No public constructor; only subclasses of ParentNode should be instantiated, and those normally via a Document's factory methods |
ParentNode | back to summary |
---|---|
public ParentNode() Constructor for serialization. |
checkNormalizationAfterInsert | back to summary |
---|---|
pack-priv void checkNormalizationAfterInsert(ChildNode insertedChild) 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:
|
checkNormalizationAfterRemove | back to summary |
---|---|
pack-priv void checkNormalizationAfterRemove(ChildNode previousSibling) 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:
|
cloneNode | back to summary |
---|---|
public Node cloneNode(boolean deep) Overrides com. Implements org. 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 | back to summary |
---|---|
public NodeList getChildNodes() Overrides com. Implements org. 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 | back to summary |
---|---|
protected final NodeList getChildNodesUnoptimized() 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 | back to summary |
---|---|
public Node getFirstChild() Overrides com. Implements org. The first child of this Node, or null if none. |
getLastChild | back to summary |
---|---|
public Node getLastChild() Overrides com. Implements org. The last child of this Node, or null if none. |
getLength | back to summary |
---|---|
public int getLength() Overrides com. Implements org. NodeList method: Count the immediate children of this node
|
getOwnerDocument | back to summary |
---|---|
public Document getOwnerDocument() Overrides com. Implements org. 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. |
getTextContent | back to summary | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
public String getTextContent() throws DOMException Overrides com. Implements org. Doc from com. This attribute returns the text content of this node and its
descendants. When it is defined to be null, setting it has no effect.
When set, any possible children this node may have are removed and
replaced by a single
com.sun.org.apache.xerces.internal.dom
back to summary
pack-priv Class ParentNode.UserDataRecord
implements Serializable Field Summary
Constructor Summary
Method SummaryField Detail
Constructor Detail
|