Class Node

java.lang.Object
de.uka.ipd.sdq.tcfmoop.outputtree.Node
Direct Known Subclasses:
Tree

public class Node extends Object
Defines a Node of a tree.
  • Field Details

  • Constructor Details

    • Node

      protected Node(Node parent, String value, Node.NodeType type)
      Creates a new node
      Parameters:
      parent - The parent of the current node.
      value - The information that should be saved in the current node
      type - the type of the node. Can later be used by the representation in the GUI
  • Method Details

    • hasChildren

      public boolean hasChildren()
      Returns whether the current node has any children nodes
      Returns:
      true if the node has children, false otherwise
    • getChildren

      public List<Node> getChildren()
      Returns a list with the children of the node. The list might be empty if the node does not have any children.
      Returns:
      a list with all children.
    • isRoot

      public boolean isRoot()
      Returns whether the current node is a root of a tree.
      Returns:
      true if the node is root, false otherwise.
    • getParent

      public Node getParent()
      Returns the parent node of the current node. Null might be returned if the node is a root node
      Returns:
      the parent of the current node or null
    • getValue

      public String getValue()
      Returns the information saved in the current node.
      Returns:
      the information saved in the current string
    • addChild

      public Node addChild(String value, Node.NodeType type)
      Add a children node to the current node.
      Parameters:
      value - the information that will be stored in the child node
      type - the type of the child node
      Returns:
      the child node
    • clearChildren

      public void clearChildren()
      Clear the list of child nodes of the current node.
    • attachSubtree

      public void attachSubtree(Tree tree)
      Attach a sub tree to the current node
      Parameters:
      tree - the sub tree to be attached
    • updateValue

      public void updateValue(String newValue)
      Update the information saved in the current node
      Parameters:
      newValue - the new information to be saved in the node
    • getType

      public Node.NodeType getType()
      Returns the type of the node
      Returns:
      the type of the node
    • toString

      public String toString()
      ]
      Overrides:
      toString in class Object
    • subTreeToString

      public String subTreeToString(String treePrefix, int prefixOccurance)
      Builds a tree like String representation of the current node and its entire subtree by using a tree prefix to simulate tree levels
      Parameters:
      treePrefix - the prefix to use
      prefixOccurance - occurrence of the prefix on level 0 (root level). Usually 0
      Returns:
      the tree like String representation of the node and its subtree