Class TreePath

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<java.lang.String>, java.util.Collection<java.lang.String>, java.util.List<java.lang.String>, java.util.RandomAccess

    public class TreePath
    extends java.util.ArrayList<java.lang.String>
    A path to a node in a Tree. The path is expressed as a list of strings.
    See Also:
    Serialized Form
    • Field Summary

      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      TreePath()
      Create an empty tree path.
      TreePath​(TreePath initialPath, java.lang.String... args)
      Create a tre path.
      TreePath​(java.lang.String initialPathEntry, java.lang.String... args)
      Create a tre path.
      TreePath​(java.util.List<java.lang.String> initialPathEntries)
      Create a tree path from a list.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isEmptyPath​(TreePath path)
      Determines if a path is empty.
      TreePath lastButOne()
      Retrieves the a sub-section of this path from the first element to the second to last element.
      TreePath subPath​(int start, int end)
      Retrieves a subsection of the path.
      java.lang.String toString()  
      • Methods inherited from class java.util.ArrayList

        add, add, addAll, addAll, clear, clone, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, removeRange, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
      • Methods inherited from class java.util.AbstractCollection

        containsAll
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream, toArray
      • Methods inherited from interface java.util.List

        containsAll
    • Constructor Detail

      • TreePath

        public TreePath()
        Create an empty tree path.
      • TreePath

        public TreePath​(TreePath initialPath,
                        java.lang.String... args)
        Create a tre path.
        Parameters:
        initialPath - Base tree path.
        args - Additional path elements to append to initialPath.
      • TreePath

        public TreePath​(java.lang.String initialPathEntry,
                        java.lang.String... args)
        Create a tre path.
        Parameters:
        initialPathEntry - The first entry in the path.
        args - Additional path entries.
      • TreePath

        public TreePath​(java.util.List<java.lang.String> initialPathEntries)
        Create a tree path from a list.
        Parameters:
        initialPathEntries - Entries in the path.
    • Method Detail

      • lastButOne

        public TreePath lastButOne()
        Retrieves the a sub-section of this path from the first element to the second to last element.
        Returns:
        a new TreePath that contains the entries in this path, excluding the final entry.
      • subPath

        public TreePath subPath​(int start,
                                int end)
        Retrieves a subsection of the path.
        Parameters:
        start - first index (inclusive) of the sub-path
        end - last index (exclusive) of the sub-path
        Returns:
        A new path made up of path elements between start and end.
      • isEmptyPath

        public static boolean isEmptyPath​(TreePath path)
        Determines if a path is empty.
        Parameters:
        path - Path to test.
        Returns:
        true if path contains no entries, path is null, or if the first entry of path is null or an empty string.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.util.AbstractCollection<java.lang.String>