Package org.apache.harmony.xml.dom
Class InnerNodeImpl
java.lang.Object
org.apache.harmony.xml.dom.NodeImpl
org.apache.harmony.xml.dom.LeafNodeImpl
org.apache.harmony.xml.dom.InnerNodeImpl
- All Implemented Interfaces:
Node
- Direct Known Subclasses:
DocumentFragmentImpl,DocumentImpl,ElementImpl
public abstract class InnerNodeImpl extends LeafNodeImpl
Provides a straightforward implementation of the corresponding W3C DOM
interface. The class is used internally only, thus only notable members that
are not in the original interface are documented (the W3C docs are quite
extensive).
Some of the fields may have package visibility, so other classes belonging to the DOM implementation can easily access them while maintaining the DOM tree structure.
This class represents a Node that has a parent Node as well as (potentially) a number of children.
Some code was adapted from Apache Xerces.
-
Field Summary
Fields inherited from interface org.w3c.dom.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 -
Constructor Summary
Constructors Modifier Constructor Description protectedInnerNodeImpl(DocumentImpl document) -
Method Summary
Modifier and Type Method Description NodeappendChild(Node newChild)Adds the nodenewChildto the end of the list of children of this node.NodeListgetChildNodes()ANodeListthat contains all children of this node.NodegetFirstChild()The first child of this node.NodegetLastChild()The last child of this node.NodegetNextSibling()The node immediately following this node.StringgetTextContent()This attribute returns the text content of this node and its descendants.booleanhasChildNodes()Returns whether this node has any children.NodeinsertBefore(Node newChild, Node refChild)Inserts the nodenewChildbefore the existing child noderefChild.booleanisParentOf(Node node)voidnormalize()Normalize the text nodes within this subtree.NoderemoveChild(Node oldChild)Removes the child node indicated byoldChildfrom the list of children, and returns it.NodereplaceChild(Node newChild, Node oldChild)RemovesoldChildand addsnewChildin its place.Methods inherited from class org.apache.harmony.xml.dom.LeafNodeImpl
getParentNode, getPreviousSiblingMethods inherited from class org.apache.harmony.xml.dom.NodeImpl
cloneNode, compareDocumentPosition, getAttributes, getBaseURI, getFeature, getLocalName, getNamespaceURI, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getPrefix, getUserData, hasAttributes, isDefaultNamespace, isEqualNode, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, setNodeValue, setPrefix, setTextContent, setUserData
-
Constructor Details
-
InnerNodeImpl
-
-
Method Details
-
appendChild
Description copied from interface:NodeAdds the nodenewChildto the end of the list of children of this node. If thenewChildis already in the tree, it is first removed.- Specified by:
appendChildin interfaceNode- Overrides:
appendChildin classNodeImpl- Parameters:
newChild- The node to add.If it is aDocumentFragmentobject, the entire contents of the document fragment are moved into the child list of this node- Returns:
- The node added.
- Throws:
DOMException- HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of thenewChildnode, or if the node to append is one of this node's ancestors or this node itself, or if this node is of typeDocumentand the DOM application attempts to append a secondDocumentTypeorElementnode.
WRONG_DOCUMENT_ERR: Raised ifnewChildwas created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the previous parent of the node being inserted is readonly.
NOT_SUPPORTED_ERR: if thenewChildnode is a child of theDocumentnode, this exception might be raised if the DOM implementation doesn't support the removal of theDocumentTypechild orElementchild.
-
getChildNodes
Description copied from interface:NodeANodeListthat contains all children of this node. If there are no children, this is aNodeListcontaining no nodes.- Specified by:
getChildNodesin interfaceNode- Overrides:
getChildNodesin classNodeImpl
-
getFirstChild
Description copied from interface:NodeThe first child of this node. If there is no such node, this returnsnull.- Specified by:
getFirstChildin interfaceNode- Overrides:
getFirstChildin classNodeImpl
-
getLastChild
Description copied from interface:NodeThe last child of this node. If there is no such node, this returnsnull.- Specified by:
getLastChildin interfaceNode- Overrides:
getLastChildin classNodeImpl
-
getNextSibling
Description copied from interface:NodeThe node immediately following this node. If there is no such node, this returnsnull.- Specified by:
getNextSiblingin interfaceNode- Overrides:
getNextSiblingin classLeafNodeImpl
-
hasChildNodes
public boolean hasChildNodes()Description copied from interface:NodeReturns whether this node has any children.- Specified by:
hasChildNodesin interfaceNode- Overrides:
hasChildNodesin classNodeImpl- Returns:
- Returns
trueif this node has any children,falseotherwise.
-
insertBefore
Description copied from interface:NodeInserts the nodenewChildbefore the existing child noderefChild. IfrefChildisnull, insertnewChildat the end of the list of children.
IfnewChildis aDocumentFragmentobject, all of its children are inserted, in the same order, beforerefChild. If thenewChildis already in the tree, it is first removed.Note: Inserting a node before itself is implementation dependent.
- Specified by:
insertBeforein interfaceNode- Overrides:
insertBeforein classNodeImpl- Parameters:
newChild- The node to insert.refChild- The reference node, i.e., the node before which the new node must be inserted.- Returns:
- The node being inserted.
- Throws:
DOMException- HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of thenewChildnode, or if the node to insert is one of this node's ancestors or this node itself, or if this node is of typeDocumentand the DOM application attempts to insert a secondDocumentTypeorElementnode.
WRONG_DOCUMENT_ERR: Raised ifnewChildwas created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the parent of the node being inserted is readonly.
NOT_FOUND_ERR: Raised ifrefChildis not a child of this node.
NOT_SUPPORTED_ERR: if this node is of typeDocument, this exception might be raised if the DOM implementation doesn't support the insertion of aDocumentTypeorElementnode.
-
isParentOf
-
normalize
public final void normalize()Normalize the text nodes within this subtree. Although named similarly, this method is unrelated to Document.normalize. -
removeChild
Description copied from interface:NodeRemoves the child node indicated byoldChildfrom the list of children, and returns it.- Specified by:
removeChildin interfaceNode- Overrides:
removeChildin classNodeImpl- Parameters:
oldChild- The node being removed.- Returns:
- The node removed.
- Throws:
DOMException- NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NOT_FOUND_ERR: Raised ifoldChildis not a child of this node.
NOT_SUPPORTED_ERR: if this node is of typeDocument, this exception might be raised if the DOM implementation doesn't support the removal of theDocumentTypechild or theElementchild.
-
replaceChild
RemovesoldChildand addsnewChildin its place. This is not atomic.- Specified by:
replaceChildin interfaceNode- Overrides:
replaceChildin classNodeImpl- Parameters:
newChild- The new node to put in the child list.oldChild- The node being replaced in the list.- Returns:
- The node replaced.
- Throws:
DOMException- HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of thenewChildnode, or if the node to put in is one of this node's ancestors or this node itself, or if this node is of typeDocumentand the result of the replacement operation would add a secondDocumentTypeorElementon theDocumentnode.
WRONG_DOCUMENT_ERR: Raised ifnewChildwas created from a different document than the one that created this node.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of the new node is readonly.
NOT_FOUND_ERR: Raised ifoldChildis not a child of this node.
NOT_SUPPORTED_ERR: if this node is of typeDocument, this exception might be raised if the DOM implementation doesn't support the replacement of theDocumentTypechild orElementchild.
-
getTextContent
Description copied from interface:NodeThis attribute returns the text content of this node and its descendants. When it is defined to benull, setting it has no effect. On setting, any possible children this node may have are removed and, if it the new string is not empty ornull, replaced by a singleTextnode 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 and the returned string does not contain the white spaces in element content (see the attributeText.isElementContentWhitespace). Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.
The string returned is made of the text content of this node depending on its type, as defined below:Node type Content ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE concatenation of the textContentattribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the node has no children.TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE nodeValueDOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null - Specified by:
getTextContentin interfaceNode- Overrides:
getTextContentin classNodeImpl- Throws:
DOMException- DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in aDOMStringvariable on the implementation platform.
-