|
BEA Systems, Inc. | |||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||||
java.lang.Objectweblogic.apache.xerces.dom.NodeImpl
weblogic.apache.xerces.dom.ChildNode
weblogic.apache.xerces.dom.ParentNode
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!
| Field Summary | |
protected ChildNode |
firstChild
Deprecated. First child. |
protected weblogic.apache.xerces.dom.NodeListCache |
fNodeListCache
Deprecated. NodeList cache |
protected CoreDocumentImpl |
ownerDocument
Deprecated. Owner document. |
| Fields inherited from class weblogic.apache.xerces.dom.ChildNode |
nextSibling, previousSibling |
| Fields inherited from class weblogic.apache.xerces.dom.NodeImpl |
ELEMENT_DEFINITION_NODE, FIRSTCHILD, flags, HASSTRING, IDATTRIBUTE, IGNORABLEWS, OWNED, ownerNode, READONLY, SPECIFIED, SYNCCHILDREN, SYNCDATA, TREE_POSITION_ANCESTOR, TREE_POSITION_DESCENDANT, TREE_POSITION_DISCONNECTED, TREE_POSITION_EQUIVALENT, TREE_POSITION_FOLLOWING, TREE_POSITION_PRECEDING, TREE_POSITION_SAME_NODE, UNNORMALIZED |
| Constructor Summary | |
|
ParentNode()
Deprecated. Constructor for serialization. |
protected |
ParentNode(CoreDocumentImpl ownerDocument)
Deprecated. No public constructor; only subclasses of ParentNode should be instantiated, and those normally via a Document's factory methods |
| Method Summary | |
Node |
cloneNode(boolean deep)
Deprecated. Returns a duplicate of a given node. |
NodeList |
getChildNodes()
Deprecated. Obtain a NodeList enumerating all children of this node. |
protected NodeList |
getChildNodesUnoptimized()
Deprecated. Create a NodeList to access children that is use by subclass elements that have methods named getLength() or item(int). |
Node |
getFirstChild()
Deprecated. The first child of this Node, or null if none. |
Node |
getLastChild()
Deprecated. The last child of this Node, or null if none. |
int |
getLength()
Deprecated. NodeList method: Count the immediate children of this node |
Document |
getOwnerDocument()
Deprecated. Find the Document that this Node belongs to (the document in whose context the Node was created). |
String |
getTextContent()
Deprecated. This attribute returns the text content of this node and its descendants. |
boolean |
hasChildNodes()
Deprecated. Test whether this node has any children. |
Node |
insertBefore(Node newChild,
Node refChild)
Deprecated. Move one or more node(s) to our list of children. |
boolean |
isEqualNode(Node arg)
Deprecated. DOM Level 3 WD- Experimental. |
Node |
item(int index)
Deprecated. NodeList method: Return the Nth immediate child of this node, or null if the index is out of bounds. |
void |
normalize()
Deprecated. Override default behavior to call normalize() on this Node's children. |
Node |
removeChild(Node oldChild)
Deprecated. Remove a child from this Node. |
Node |
replaceChild(Node newChild,
Node oldChild)
Deprecated. Make newChild occupy the location that oldChild used to have. |
void |
setReadOnly(boolean readOnly,
boolean deep)
Deprecated. Override default behavior so that if deep is true, children are also toggled. |
void |
setTextContent(String textContent)
Deprecated. This attribute returns the text content of this node and its descendants. |
protected void |
synchronizeChildren()
Deprecated. Override this method in subclass to hook in efficient internal data structure. |
| Methods inherited from class weblogic.apache.xerces.dom.ChildNode |
getNextSibling, getParentNode, getPreviousSibling |
| Methods inherited from class weblogic.apache.xerces.dom.NodeImpl |
addEventListener, appendChild, changed, changes, compareTreePosition, dispatchEvent, getAttributes, getBaseURI, getInterface, getLocalName, getNamespaceURI, getNodeName, getNodeType, getNodeValue, getPrefix, getReadOnly, getUserData, getUserData, hasAttributes, isDefaultNamespace, isSameNode, isSupported, lookupNamespacePrefix, lookupNamespaceURI, needsSyncChildren, removeEventListener, setNodeValue, setPrefix, setUserData, setUserData, synchronizeData, toString |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface org.w3c.dom.Node |
compareDocumentPosition, getFeature, lookupPrefix, setUserData |
| Field Detail |
protected ChildNode firstChild
protected transient weblogic.apache.xerces.dom.NodeListCache fNodeListCache
protected CoreDocumentImpl ownerDocument
| Constructor Detail |
public ParentNode()
protected ParentNode(CoreDocumentImpl ownerDocument)
| Method Detail |
public Node cloneNode(boolean deep)
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.
cloneNode in interface NodecloneNode in class ChildNode
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.
public NodeList getChildNodes()
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.
getChildNodes in interface NodegetChildNodes in class NodeImplprotected final NodeList getChildNodesUnoptimized()
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.
public Node getFirstChild()
getFirstChild in interface NodegetFirstChild in class NodeImplParentNodepublic Node getLastChild()
getLastChild in interface NodegetLastChild in class NodeImplParentNodepublic int getLength()
getLength in interface NodeListgetLength in class NodeImplParentNodepublic Document getOwnerDocument()
getOwnerDocument in interface NodegetOwnerDocument in class NodeImpl
public String getTextContent()
throws DOMException
NodeImplText node containing the string
this attribute is set to. On getting, no serialization is performed,
the returned string does not contain any markup. No whitespace
normalization is performed, the returned string does not contain the
element content whitespaces . Similarly, on setting, no parsing is
performed either, the input string is taken as pure textual content.
| Node type | Content |
|---|---|
| ELEMENT_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 |
| ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE |
nodeValue |
| DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE | null |
getTextContent in interface NodegetTextContent in class NodeImplDOMException - DOMSTRING_SIZE_ERR: Raised when it would return more characters than
fit in a DOMString variable on the implementation
platform.public boolean hasChildNodes()
hasChildNodes in interface NodehasChildNodes in class NodeImplParentNode
public Node insertBefore(Node newChild,
Node refChild)
throws DOMException
insertBefore in interface NodeinsertBefore in class NodeImplnewChild - The Node to be moved to our subtree. As a
convenience feature, inserting a DocumentNode will instead insert
all its children.refChild - Current child which newChild should be placed
immediately before. If refChild is null, the insertion occurs
after all existing Nodes, like appendChild().
DOMException(HIERARCHY_REQUEST_ERR) - if newChild is of a
type that shouldn't be a child of this node, or if newChild is an
ancestor of this node.
DOMException(WRONG_DOCUMENT_ERR) - if newChild has a
different owner document than we do.
DOMException(NOT_FOUND_ERR) - if refChild is not a child of
this node.
DOMException(NO_MODIFICATION_ALLOWED_ERR) - if this node is
read-only.
DOMExceptionParentNodepublic boolean isEqualNode(Node arg)
isEqualNode in interface NodeisEqualNode in class NodeImplarg - The node to compare equality with.
true otherwise false.public Node item(int index)
item in interface NodeListitem in class NodeImplindex - int
ParentNodepublic void normalize()
normalize in interface Nodenormalize in class NodeImpl
public Node removeChild(Node oldChild)
throws DOMException
removeChild in interface NoderemoveChild in class NodeImplDOMException(NOT_FOUND_ERR) - if oldChild is not a child of
this node.
DOMException(NO_MODIFICATION_ALLOWED_ERR) - if this node is
read-only.
DOMExceptionParentNode
public Node replaceChild(Node newChild,
Node oldChild)
throws DOMException
replaceChild in interface NodereplaceChild in class NodeImplDOMException(HIERARCHY_REQUEST_ERR) - if newChild is of a
type that shouldn't be a child of this node, or if newChild is
one of our ancestors.
DOMException(WRONG_DOCUMENT_ERR) - if newChild has a
different owner document than we do.
DOMException(NOT_FOUND_ERR) - if oldChild is not a child of
this node.
DOMException(NO_MODIFICATION_ALLOWED_ERR) - if this node is
read-only.
DOMExceptionParentNode
public void setReadOnly(boolean readOnly,
boolean deep)
setReadOnly in class NodeImplreadOnly - True or false as desired.deep - 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.
Note: this will not change the state of an EntityReference or its
children, which are always read-only.
public void setTextContent(String textContent)
throws DOMException
NodeImplText node containing the string
this attribute is set to. On getting, no serialization is performed,
the returned string does not contain any markup. No whitespace
normalization is performed, the returned string does not contain the
element content whitespaces . Similarly, on setting, no parsing is
performed either, the input string is taken as pure textual content.
| Node type | Content |
|---|---|
| ELEMENT_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 |
| ATTRIBUTE_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE |
nodeValue |
| DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE | null |
setTextContent in interface NodesetTextContent in class NodeImplDOMException - DOMSTRING_SIZE_ERR: Raised when it would return more characters than
fit in a DOMString variable on the implementation
platform.protected void synchronizeChildren()
|
Documentation is available at http://download.oracle.com/docs/cd/E13222_01/wls/docs90 Copyright 2005 BEA Systems Inc. |
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||