Class Tree

    • Constructor Detail

      • Tree

        public Tree()
        Creates a new root tree.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • Tree

        public Tree​(Object aValue)
        Creates a new root tree with given value.
        Parameters:
        aValue -
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • Tree

        public Tree​(Object aValue,
                    String anInfo)
        Creates a new root tree with given value and info
        Parameters:
        aValue -
        anInfo -
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • Tree

        public Tree​(Object aValue,
                    String anInfo,
                    boolean mayHaveChildren)
        Creates a new root tree with given value and info
        Parameters:
        aValue -
        anInfo -
        mayHaveChildren -
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
    • Method Detail

      • getParent

        public Tree getParent()
        Returns the parent node.
        Returns:
        the parent node.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getValue

        public Object getValue()
        Returns:
        The value of the tree node.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • setValue

        public void setValue​(Object newValue)
        Sewts the value of the tree node.
        Parameters:
        newValue -
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getInfo

        public String getInfo()
        Returns an info String.
        Returns:
        an info String.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • setInfo

        public void setInfo​(String newInfo)
        Sets a new info String.
        Parameters:
        newInfo -
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • setMayHaveChildren

        public void setMayHaveChildren​(boolean mayHaveChildren)
        Sets the flag if this tree node may have children or not.
        Parameters:
        mayHaveChildren - true if this node may have children, false if this node doesn't have any children.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getChildCount

        public int getChildCount()
        Returns the number of children of this node.
        Returns:
        the number of children of this node.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getChildAt

        public Tree getChildAt​(int index)
        Returns the child with given index.
        Parameters:
        index -
        Returns:
        The child at the given index or null when no child at the given index
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • removeChildAt

        public Tree removeChildAt​(int index)
        Removes a child with given index.
        Parameters:
        index -
        Returns:
        The removed child.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • removeFromParent

        public void removeFromParent()
        Removes the subtree rooted at this node from the tree, giving this node a null parent. Does nothing if this node is the root of its tree.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • remove

        public void remove​(Tree aChild)
        Removes aChild from this node's child array, giving it a null parent.
        Parameters:
        aChild - a child of this node to remove
        Throws:
        IllegalArgumentException - if aChild is null or is not a child of this node
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • removeAllChildren

        public void removeAllChildren()
        Removes all of this node's children, setting their parents to null. If this node has no children, this method does nothing.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • createChildren

        public List<Tree> createChildren​(List<?> values)
        Creates and adds new children.
        Parameters:
        values - a list of values for new children.
        Returns:
        A list with new Children.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • createChildren

        public List<Tree> createChildren​(List<?> values,
                                         String _info)
        Creates and adds new children.
        Parameters:
        values - a list of values for new children.
        _info - the info of the new children.
        Returns:
        A list with the new children.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • createChildren

        public List<Tree> createChildren​(List<?> values,
                                         List<String> infos)
        Creates and adds new children.
        Parameters:
        values - a list of values for new children.
        infos - the infos of the new children.
        Returns:
        A list with the new children.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • createChildren

        public List<Tree> createChildren​(List<?> values,
                                         List<String> infos,
                                         List<Boolean> mayHaveChildrenList)
        Creates and adds new children.
        Parameters:
        values - a list of values for new children.
        infos - the infos of the new children.
        mayHaveChildrenList - a list of flags indicateing if the associated tree node could have children.
        Returns:
        A list with the new children.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • createChildrenAt

        public List<Tree> createChildrenAt​(int index,
                                           List<?> values)
        Creates and adds new children.
        Parameters:
        index - Where to insert.
        values - a list of values for new children.
        Returns:
        A list with new Children.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • createChildrenAt

        public List<Tree> createChildrenAt​(int index,
                                           List<?> values,
                                           String _info)
        Creates and adds new children.
        Parameters:
        index - Where to insert.
        values - a list of values for new children.
        _info - the info of the new children.
        Returns:
        A list with the new children.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • createChildrenAt

        public List<Tree> createChildrenAt​(int index,
                                           List<?> values,
                                           List<String> infos)
        Creates and adds new children.
        Parameters:
        index - Where to insert.
        values - a list of values for new children.
        infos - the infos of the new children.
        Returns:
        A list with the new children.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • createChildrenAt

        public List<Tree> createChildrenAt​(int index,
                                           List<?> values,
                                           List<String> infos,
                                           List<Boolean> mayHaveChildrenList)
        Creates and adds new children.
        Parameters:
        index - Where to insert.
        values - a list of values for new children.
        infos - the infos of the new children.
        mayHaveChildrenList - a list of flags indicateing if the associated tree node could have children. Can be null.
        Returns:
        A list with the new children.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • createChild

        public Tree createChild​(Object newValue)
        Adds a child to this node.
        Parameters:
        newValue - The value of the new child.
        Returns:
        The new child.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • createChild

        public Tree createChild​(Object newValue,
                                String newInfo)
        Adds a child to this node.
        Parameters:
        newValue - The value of the new child.
        newInfo - the info of the new child
        Returns:
        The new child.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • createChildAt

        public Tree createChildAt​(int index,
                                  Object newValue,
                                  String newInfo)
        Inserts a child at the given position into this node. If the index is smaller than zero, the the new child is added at the beginning of the list. If the index is equal or bigger than the number of already existing children, the new child is inserted at the end.
        Parameters:
        index - The index of the new child
        newValue - The value of the new child.
        newInfo - The info of the new child
        Returns:
        The new child; never null
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • createChildAt

        public Tree createChildAt​(int index,
                                  Object newValue)
        Inserts a child into the childrenlist of this node.
        Parameters:
        index - The index of the new child
        newValue - The value of the new child.
        Returns:
        The new child.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • add

        public void add​(Tree child)
        Adds a new child to this tree.
        Parameters:
        child - A new child; if the parent of child is not null, this argument is cloned.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • addAt

        public void addAt​(int index,
                          Tree child)
        Adds a new child to this tree.
        Parameters:
        index -
        child - A new child; if the parent of child is not null, this argument is cloned.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • addAll

        public void addAll​(List<Tree> newChildren)
        Adds a new child to this tree.
        Parameters:
        newChildren - A list of new children; if the parent of a child is not null, the child is cloned.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • addAllAt

        public void addAllAt​(int index,
                             List<Tree> newChildren)
        Adds a new child to this tree.
        Parameters:
        index - Where to insert
        newChildren - A list of new children; if the parent of a child is not null, the child is cloned.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • clone

        public Tree clone()
        Clones this tree (shallow copy).
        Specified by:
        clone in interface IIvyDataObject
        Overrides:
        clone in class NestedObject
        Returns:
        A shallow of this object.
        See Also:
        Object.clone()
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • deepClone

        public Tree deepClone()
        Clones this Tree (deep copy).
        Specified by:
        deepClone in interface IIvyDataObject
        Overrides:
        deepClone in class NestedObject
        Returns:
        A deep of this object.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • indexOf

        public int indexOf​(Tree child)
        Returns the index in this tree of the first occurrence of the specified child element, or -1 if this treet does not contain this child element
        Parameters:
        child - the child node to search
        Returns:
        index of the first occurence or -1 if not found
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getChildren

        public List<Tree> getChildren()
        Gets the child nodes of this node.
        Returns:
        a list with child tree nodes
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getAllDeepChildren

        public List<Tree> getAllDeepChildren()
        Gets all child nodes and child nodes of child nodes ... of this node. All nodes are returned that have this node as ancestor.
        Returns:
        list with all child tree nodes.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getRoot

        public Tree getRoot()
        Returns the root element of this (sub)-tree.
        Returns:
        the root element
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • getPath

        public List<Tree> getPath()
        Returns a path for from the root node to this node.
        Returns:
        a path for from the root node to this node.
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.
      • treeValueChanged

        public void treeValueChanged()
        Informs the listeners that a tree value vas relpaced or changed.
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • getNextNode

        public Tree getNextNode()
        Returns the node that follows this node in a preorder traversal of this node's tree. Returns null if this node is the last node of the traversal. This is an inefficient way to traverse the entire tree; use an enumeration, instead.
        Returns:
        the node that follows this node in a preorder traversal, or null if this node is last
        API:
        This public API is available in IvyScript and Java. It has the visibility ADVANCED.
      • getPreviousNode

        public Tree getPreviousNode()
        Returns the node that precedes this node in a preorder traversal of this node's tree. Returns null if this node is the first node of the traversal -- the root of the tree. This is an inefficient way to traverse the entire tree; use an enumeration, instead.
        Returns:
        the node that precedes this node in a preorder traversal, or null if this node is the first
        API:
        This public API is available in IvyScript and Java. It has the visibility ADVANCED.
      • getNextSibling

        public Tree getNextSibling()
        Returns the next sibling of this node in the parent's children array. Returns null if this node has no parent or is the parent's last child. This method performs a linear search that is O(n) where n is the number of children; to traverse the entire array, use the parent's child enumeration instead.
        Returns:
        the sibling of this node that immediately follows this node
        See Also:
        fChildren
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • getPreviousSibling

        public Tree getPreviousSibling()
        Returns the previous sibling of this node in the parent's children array. Returns null if this node has no parent or is the parent's first child. This method performs a linear search that is O(n) where n is the number of children.
        Returns:
        the sibling of this node that immediately precedes this node
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • isNodeSibling

        public boolean isNodeSibling​(Tree anotherNode)
        Returns true if anotherNode is a sibling of (has the same parent as) this node. A node is its own sibling. If anotherNode is null, returns false.
        Parameters:
        anotherNode - node to test as sibling of this node
        Returns:
        true if anotherNode is a sibling of this node
        API:
        This public API is available in IvyScript and Java. It has the visibility EXPERT.
      • getChildBefore

        public Tree getChildBefore​(Tree aChild)
        Returns the child in this node's child array that immediately precedes aChild, which must be a child of this node. If aChild is the first child, returns null. This method performs a linear search of this node's children for aChild and is O(n) where n is the number of children.
        Parameters:
        aChild - the reference child
        Returns:
        the child of this node that immediately precedes aChild
        Throws:
        IllegalArgumentException - if aChild is null or is not a child of this node
        API:
        This public API is available in IvyScript and Java. It has the visibility ADVANCED.
      • getChildAfter

        public Tree getChildAfter​(Tree aChild)
        Returns the child in this node's child array that immediately follows aChild, which must be a child of this node. If aChild is the last child, returns null. This method performs a linear search of this node's children for aChild and is O(n) where n is the number of children; to traverse the entire array of children, use an enumeration instead.
        Parameters:
        aChild - the reference child
        Returns:
        the child of this node that immediately follows aChild
        Throws:
        IllegalArgumentException - if aChild is null or is not a child of this node
        See Also:
        fChildren
        API:
        This public API is available in IvyScript and Java. It has the visibility ADVANCED.
      • getIndex

        public int getIndex​(Tree aChild)
        Returns the index of the specified child in this node's child array. If the specified node is not a child of this node, returns -1. This method performs a linear search and is O(n) where n is the number of children.
        Parameters:
        aChild - the TreeNode to search for among this node's children
        Returns:
        an int giving the index of the node in this node's child array, or -1 if the specified node is a not a child of this node
        Throws:
        IllegalArgumentException - if aChild is null
        API:
        This public API is available in IvyScript and Java. It has the visibility ADVANCED.
      • isNodeChild

        public boolean isNodeChild​(Tree aNode)
        Returns true if aNode is a child of this node. If aNode is null, this method returns false.
        Parameters:
        aNode - the reference node
        Returns:
        true if aNode is a child of this node; false if aNode is null
        API:
        This public API is available in IvyScript and Java. It has the visibility ADVANCED.
      • getFirstLeaf

        public Tree getFirstLeaf()
        Finds and returns the first leaf that is a descendant of this node -- either this node or its first child's first leaf. Returns this node if it is a leaf.
        Returns:
        the first leaf in the subtree rooted at this node
        See Also:
        isLeaf()
        API:
        This public API is available in IvyScript and Java. It has the visibility ADVANCED.
      • getLastLeaf

        public Tree getLastLeaf()
        Finds and returns the last leaf that is a descendant of this node -- either this node or its last child's last leaf. Returns this node if it is a leaf.
        Returns:
        the last leaf in the subtree rooted at this node
        See Also:
        isLeaf()
        API:
        This public API is available in IvyScript and Java. It has the visibility ADVANCED.
      • getFirstChild

        public Tree getFirstChild()
        Returns this node's first child. If this node has no children, it returns null.
        Returns:
        the first child of this node, or null if the node doesn't have any child.
        API:
        This public API is available in IvyScript and Java. It has the visibility ADVANCED.
      • getLastChild

        public Tree getLastChild()
        Returns this node's last child. If this node has no children, it returns null.
        Returns:
        the last child of this node or null if the node has no children.
        API:
        This public API is available in IvyScript and Java. It has the visibility ADVANCED.
      • iterator

        public Iterator<Tree> iterator()
        Creates and returns an iterator that traverses the subtree rooted at this node in preorder. The first node returned by the enumeration's nextElement() method is this node.

        Modifying the tree by inserting, removing, or moving a node invalidates any enumerations created before the modification.

        Returns:
        the iterator
        API:
        This public API is available in IvyScript and Java. It has the visibility NOVICE.