Class Node



  • public class Node
    extends Entry
    A class representing inner nodes within the file tree.
    • Constructor Detail

      • Node

        public Node(Node parent,
                    String name)
        Create a new Node that is a child of the denoted parent with the denoted name.
        Parameters:
        parent - the parent node this node is a child of.
        name - the name of this node.
    • Method Detail

      • setName

        public void setName(String name)
        Parameters:
        name - the name of this node.
      • getName

        public String getName()
        Returns:
        the name of this node.
      • addChildNode

        public Node addChildNode(String childname)
        Add a child node to this node with the denoted name.
        Parameters:
        childname - the name of the child.
        Returns:
        the newly created node.
      • getIndexOfChild

        public int getIndexOfChild(Object child)
        Get the index of the denoted child entry. Indices for leafs are biased by the number of child nodes.
        Parameters:
        child - the object to lookup.
        Returns:
        the index of the child or -1 if not contained or not a Node or Leaf instance.
      • toString

        public String toString()
      • getTotalNumberOfChilds

        public int getTotalNumberOfChilds()
        Returns:
        the number of children (nodes + leafs) within this node.
      • getChild

        public Entry getChild(int n)
        Get the n'th child of this node.
        Parameters:
        n - the index of the child.
        Returns:
        the n'th child entry.
      • hasChildNode

        public boolean hasChildNode(String childname)
        Find out whether this node has a child with the denoted name.
        Parameters:
        childname - the name of the child to find
        Returns:
        the index of a child with the denoted name.
      • getChildNode

        public Node getChildNode(String childname)
        Find the node with the denoted name.
        Parameters:
        childname - the name of the node to find.
        Returns:
        the child node or null
      • getChildEntry

        public Entry getChildEntry(String childname)
        Find the entry with the denoted name.
        Parameters:
        childname - the name of the entry to find.
        Returns:
        the child node or null
      • getLeafs

        public List<Leaf> getLeafs()
        Get the list of child leafs.
        Returns:
        a list of leafs.
      • getChilds

        public List<Node> getChilds()
        Get the list of child nodes.
        Returns:
        a list of nodes.
      • remove

        public int remove(Entry entry)
        Remove the denoted entry from the tree.
        Parameters:
        entry - the entry to remove.
        Returns:
        the index of the removed index or -1 on failure.