Class Node


  • public class Node
    extends Object
    Model of XML node tree
    Author:
    Ly Minh Phuong - http://phuonglm.net
    • Constructor Detail

      • Node

        public Node()
    • Method Detail

      • getParentNode

        public Node getParentNode()
        Gets parent Node of current Node. If current Node is root, parent Node == null;
        Returns:
        parent node
      • setParentNode

        public void setParentNode​(Node parentNode)
        Sets the parent Node of currentNode
        Parameters:
        parentNode -
      • getTitle

        public String getTitle()
        Gets title of Node, node's title ak the tag name.
        Returns:
        the node title
      • setTitle

        public void setTitle​(String nodeTitle)
        Sets title of Node, node's title ak the tag name.
        Parameters:
        nodeTitle -
      • getAttributes

        public Attributes getAttributes()
        Returns Attributes of Node
        Returns:
        the attributes
      • setAttributes

        public void setAttributes​(Attributes attributes)
        Sets attributes of Node.
        Parameters:
        attributes -
      • getContent

        public String getContent()
        Gets the Content of Node, if Node have Content it mean that is text Node.
        Returns:
        the content node
      • setContent

        public void setContent​(String content)
        Sets the Content of Node, if Node have Content it mean that is text Node.
        Parameters:
        content -
      • getChildNodes

        public LinkedList<Node> getChildNodes()
        Gets the list child nodes of current Node.
        Returns:
        child nodes
      • setChildNodes

        public void setChildNodes​(LinkedList<Node> childNodes)
        Sets the list child nodes of current Node.
        Parameters:
        childNodes - the child nodes
      • addChildNode

        public void addChildNode​(Node childNode)
        Adds child Node to this Node.
        Parameters:
        childNode - the child node
      • addAttribute

        public void addAttribute​(String key,
                                 String value)
        Adds Attribute to current Node.
        Parameters:
        key - attribute key
        value - attribute value
      • isTextNode

        public boolean isTextNode()
        Check if node is TextNode
        Returns:
        Since:
        1.2.2
      • isRootNode

        public boolean isRootNode()
        Check if node is RootNode
        Returns:
        Since:
        1.2.2
      • isSelfClosedNode

        public boolean isSelfClosedNode()
        Check if node is SelfCloseNode
        Returns:
        Since:
        1.2.2
      • insertAfter

        public void insertAfter​(Node refNode,
                                Node nodeToInsert)
        insert Node to DOM tree after refNode
        Parameters:
        refNode -
        nodeToInsert -
        Since:
        1.2.2
      • insertAfter

        public void insertAfter​(int position,
                                Node node)
        Insert Node to DOM tree after the node at position
        Parameters:
        position -
        node -
        Since:
        1.2.2
      • toString

        public String toString()
        Convert Node to XML String including all sub-Node
        Overrides:
        toString in class Object
        Returns:
        XML String
      • convertToContent

        public void convertToContent()
        Converts this Tag Node to Content Node, add Close Tag at the end of child nodes and move all child Nodes of this Node to parent Node.