Class 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.

  • Constructor Details

    • InnerNodeImpl

      protected InnerNodeImpl​(DocumentImpl document)
  • Method Details

    • appendChild

      public Node appendChild​(Node newChild) throws DOMException
      Description copied from interface: Node
      Adds the node newChild to the end of the list of children of this node. If the newChild is already in the tree, it is first removed.
      Specified by:
      appendChild in interface Node
      Overrides:
      appendChild in class NodeImpl
      Parameters:
      newChild - The node to add.If it is a DocumentFragment object, 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 the newChild node, or if the node to append is one of this node's ancestors or this node itself, or if this node is of type Document and the DOM application attempts to append a second DocumentType or Element node.
      WRONG_DOCUMENT_ERR: Raised if newChild was 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 the newChild node is a child of the Document node, this exception might be raised if the DOM implementation doesn't support the removal of the DocumentType child or Element child.
    • getChildNodes

      public NodeList getChildNodes()
      Description copied from interface: Node
      A NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes.
      Specified by:
      getChildNodes in interface Node
      Overrides:
      getChildNodes in class NodeImpl
    • getFirstChild

      public Node getFirstChild()
      Description copied from interface: Node
      The first child of this node. If there is no such node, this returns null.
      Specified by:
      getFirstChild in interface Node
      Overrides:
      getFirstChild in class NodeImpl
    • getLastChild

      public Node getLastChild()
      Description copied from interface: Node
      The last child of this node. If there is no such node, this returns null.
      Specified by:
      getLastChild in interface Node
      Overrides:
      getLastChild in class NodeImpl
    • getNextSibling

      public Node getNextSibling()
      Description copied from interface: Node
      The node immediately following this node. If there is no such node, this returns null.
      Specified by:
      getNextSibling in interface Node
      Overrides:
      getNextSibling in class LeafNodeImpl
    • hasChildNodes

      public boolean hasChildNodes()
      Description copied from interface: Node
      Returns whether this node has any children.
      Specified by:
      hasChildNodes in interface Node
      Overrides:
      hasChildNodes in class NodeImpl
      Returns:
      Returns true if this node has any children, false otherwise.
    • insertBefore

      public Node insertBefore​(Node newChild, Node refChild) throws DOMException
      Description copied from interface: Node
      Inserts the node newChild before the existing child node refChild. If refChild is null, insert newChild at the end of the list of children.
      If newChild is a DocumentFragment object, all of its children are inserted, in the same order, before refChild. If the newChild is already in the tree, it is first removed.

      Note: Inserting a node before itself is implementation dependent.

      Specified by:
      insertBefore in interface Node
      Overrides:
      insertBefore in class NodeImpl
      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 the newChild node, or if the node to insert is one of this node's ancestors or this node itself, or if this node is of type Document and the DOM application attempts to insert a second DocumentType or Element node.
      WRONG_DOCUMENT_ERR: Raised if newChild was 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 if refChild is not a child of this node.
      NOT_SUPPORTED_ERR: if this node is of type Document, this exception might be raised if the DOM implementation doesn't support the insertion of a DocumentType or Element node.
    • isParentOf

      public boolean isParentOf​(Node node)
    • normalize

      public final void normalize()
      Normalize the text nodes within this subtree. Although named similarly, this method is unrelated to Document.normalize.
      Specified by:
      normalize in interface Node
      Overrides:
      normalize in class NodeImpl
    • removeChild

      public Node removeChild​(Node oldChild) throws DOMException
      Description copied from interface: Node
      Removes the child node indicated by oldChild from the list of children, and returns it.
      Specified by:
      removeChild in interface Node
      Overrides:
      removeChild in class NodeImpl
      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 if oldChild is not a child of this node.
      NOT_SUPPORTED_ERR: if this node is of type Document, this exception might be raised if the DOM implementation doesn't support the removal of the DocumentType child or the Element child.
    • replaceChild

      public Node replaceChild​(Node newChild, Node oldChild) throws DOMException
      Removes oldChild and adds newChild in its place. This is not atomic.
      Specified by:
      replaceChild in interface Node
      Overrides:
      replaceChild in class NodeImpl
      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 the newChild node, or if the node to put in is one of this node's ancestors or this node itself, or if this node is of type Document and the result of the replacement operation would add a second DocumentType or Element on the Document node.
      WRONG_DOCUMENT_ERR: Raised if newChild was 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 if oldChild is not a child of this node.
      NOT_SUPPORTED_ERR: if this node is of type Document, this exception might be raised if the DOM implementation doesn't support the replacement of the DocumentType child or Element child.
    • getTextContent

      public String getTextContent() throws DOMException
      Description copied from interface: Node
      This attribute returns the text content of this node and its descendants. When it is defined to be null, 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 or null, replaced by a single Text 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 and the returned string does not contain the white spaces in element content (see the attribute Text.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 textContent attribute 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 nodeValue
      DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE null
      Specified by:
      getTextContent in interface Node
      Overrides:
      getTextContent in class NodeImpl
      Throws:
      DOMException - DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a DOMString variable on the implementation platform.