Class TreeNode

java.lang.Object
jadex.collection.TreeNode

public class TreeNode extends Object
Represents a node of a tree.
  • Field Details

    • data

      protected Object data
      The user node data.
    • children

      public List<TreeNode> children
      The children.
  • Constructor Details

    • TreeNode

      public TreeNode()
      Create a new node.
    • TreeNode

      public TreeNode(Object data)
      Create a new node.
  • Method Details

    • getChildren

      public List<TreeNode> getChildren()
      Return the children of node.
      Returns:
      The children of node.
    • setChildren

      public void setChildren(List<TreeNode> children)
      Sets the children of a Node object.
      Parameters:
      children - The list to set.
    • getNumberOfChildren

      public int getNumberOfChildren()
      Returns the number of immediate children of this node.
      Returns:
      the number of immediate children.
    • addChild

      public void addChild(TreeNode child)
      Adds a child to the list of children for this node.
      Parameters:
      child - a Node object to set.
    • insertChildAt

      public void insertChildAt(int index, TreeNode child) throws IndexOutOfBoundsException
      Inserts a node at the specified position in the child list. Will throw an ArrayIndexOutOfBoundsException if the index does not exist.
      Parameters:
      index - the position to insert at.
      child - the Node object to insert.
      Throws:
      IndexOutOfBoundsException - if thrown.
    • removeChildAt

      public void removeChildAt(int index) throws IndexOutOfBoundsException
      Remove the Node element at index index of the List.
      Parameters:
      index - the index of the element to delete.
      Throws:
      IndexOutOfBoundsException - if thrown.
    • getData

      public Object getData()
      Get the node data.
      Returns:
      The node data.
    • setData

      public void setData(Object data)
      Set the node data.
      Parameters:
      data - The node data.
    • toString

      public String toString()
      Get the string representation.
      Overrides:
      toString in class Object
      Returns:
      The string representation.