Class BaseNode

  • Direct Known Subclasses:
    BaseAttribute, BaseDocument, BaseElement, TextNode

    @JsType(isNative=true,
            name="Node",
            namespace="<global>")
    public abstract class BaseNode
    extends BaseEventTarget
    A object from which various types of DOM objects inherit, allowing those types to be treated similarly.
    Author:
    Andrea "Stock" Stocchero
    • Constructor Detail

      • BaseNode

        protected BaseNode()
        To avoid any instantiation
    • Method Detail

      • getChildNodes

        @JsProperty
        public final NodeList<BaseNode> getChildNodes()
        Returns a list containing all the children of this node.
        Returns:
        a list containing all the children of this node
      • getFirstChild

        @JsProperty
        public final BaseNode getFirstChild()
        Returns a node representing the first direct child node of the node, or null if the node has no child.
        Returns:
        a node representing the first direct child node of the node, or null if the node has no child
      • getLastChild

        @JsProperty
        public final BaseNode getLastChild()
        Returns a node representing the last direct child node of the node, or null if the node has no child.
        Returns:
        a node representing the last direct child node of the node, or null if the node has no child
      • getNextSibling

        @JsProperty
        public final BaseNode getNextSibling()
        Returns a node representing the next node in the tree, or null if there isn't such node.
        Returns:
        a node representing the next node in the tree, or null if there isn't such node
      • getNodeName

        @JsProperty
        public final String getNodeName()
        Returns a string containing the name of the node.
        The structure of the name will differ with the node type.
        Returns:
        a string containing the name of the node
      • getNodeType

        @JsOverlay
        public final NodeType getNodeType()
        Returns the type of the node.
        Returns:
        the type of the node
      • getNodeValue

        @JsProperty
        public final String getNodeValue()
        Returns the value of the current node.
        Returns:
        the value of the current node
      • setNodeValue

        @JsProperty
        public final void setNodeValue​(String nodeValue)
        Sets the value of the current node.
        Parameters:
        nodeValue - the value of the current node
      • getOwnerDocument

        @JsProperty
        public final BaseDocument getOwnerDocument()
        Returns the document that this node belongs to.
        If the node is itself a document, returns null.
        Returns:
        the document that this node belongs to
      • getParentNode

        @JsProperty
        public final BaseNode getParentNode()
        Returns a node that is the parent of this node.
        If there is no such node, returns null.
        Returns:
        a node that is the parent of this node
      • getParentElement

        @JsProperty
        public BaseElement getParentElement()
        Returns an element that is the parent of this node.
        If the node has no parent, or if that parent is not an element, returns null.
        Returns:
        an element that is the parent of this node
      • getPreviousSibling

        @JsProperty
        public final BaseNode getPreviousSibling()
        Returns a node representing the previous node in the tree, or null if there isn't such node.
        Returns:
        a node representing the previous node in the tree, or null if there isn't such node
      • getTextContent

        @JsProperty
        public final String getTextContent()
        Returns the textual content of an element and all its descendants.
        Returns:
        the textual content of an element and all its descendants
      • setTextContent

        @JsProperty
        public final void setTextContent​(String textContent)
        Sets the textual content of an element and all its descendants.
        Parameters:
        textContent - the textual content of an element and all its descendants
      • appendChild

        @JsMethod
        public final BaseNode appendChild​(BaseNode newChild)
        Adds a node to the end of the list of children of a specified parent node.
        If the given child is a reference to an existing node in the document, it moves it from its current position to the new position (there is no requirement to remove the node from its parent node before appending it to some other node).
        Parameters:
        newChild - the node to append to the given parent node (commonly an element)
        Returns:
        the appended child
      • cloneNode

        @JsMethod
        public final BaseNode cloneNode​(boolean deep)
        Clone the node, and optionally, all of its contents.
        Parameters:
        deep - If true, then node and its whole subtree including text.
        If false, only node will be cloned.
        It has no effect on empty elements
        Returns:
        the new node, cloned from this.
        The new clone has no parent and is not part of the document
      • hasChildNodes

        @JsMethod
        public final boolean hasChildNodes()
        Returns a boolean indicating whether or not the element has any child nodes.
        Returns:
        a boolean indicating whether or not the element has any child nodes
      • insertBefore

        @JsMethod
        public final BaseNode insertBefore​(BaseNode newChild,
                                           BaseNode refChild)
        Inserts a node before the reference node as a child of a specified parent node.
        Parameters:
        newChild - the node to be inserted.
        refChild - the node before which new node is inserted.
        If this is null, then new node is inserted at the end of child nodes.
        Returns:
        the added node
      • removeChild

        @JsMethod
        public final BaseNode removeChild​(BaseNode oldChild)
        Removes a child node from the current element, which must be a child of the current node.
        Parameters:
        oldChild - is the child node to be removed from the DOM.
        Returns:
        a reference to the removed child node
      • removeAllChildren

        @JsOverlay
        public final void removeAllChildren()
        Remove all children of the node.