Package gov.nasa.worldwind.util.tree
Class TreePath
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<java.lang.String>
-
- gov.nasa.worldwind.util.tree.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 aTree
. The path is expressed as a list of strings.- See Also:
- Serialized Form
-
-
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
-
-
-
-
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 toinitialPath
.
-
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-pathend
- last index (exclusive) of the sub-path- Returns:
- A new path made up of path elements between
start
andend
.
-
isEmptyPath
public static boolean isEmptyPath(TreePath path)
Determines if a path is empty.- Parameters:
path
- Path to test.- Returns:
true
ifpath
contains no entries,path
isnull
, or if the first entry ofpath
isnull
or an empty string.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractCollection<java.lang.String>
-
-