Package org.eclipse.jface.viewers
Class TreePath
java.lang.Object
org.eclipse.jface.viewers.TreePath
A tree path denotes a model element in a tree viewer. Tree path objects have
value semantics. A model element is represented by a path of elements in the
tree from the root element to the leaf element.
Clients may instantiate this class. Not intended to be subclassed.
- Since:
- 3.2
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateChildPath
(Object newSegment) Returns a copy of this tree path with the given segment added at the end.boolean
boolean
equals
(TreePath otherPath, IElementComparer comparer) Returns whether this path is equivalent to the given path using the specified comparer to compare individual elements.Returns the first element in this path, ornull
if this path has no segments.Returns the last element in this path, ornull
if this path has no segments.Returns a copy of this tree path with one segment removed from the end, ornull
if this tree path has no segments.getSegment
(int index) Returns the element at the specified index in this path.int
Returns the number of elements in this path.int
hashCode()
int
hashCode
(IElementComparer comparer) Returns a hash code computed from the hash codes of the segments, using the given comparer to compute the hash codes of the segments.boolean
startsWith
(TreePath treePath, IElementComparer comparer) Returns whether this path starts with the same segments as the given path, using the given comparer to compare segments.
-
Field Details
-
EMPTY
Constant for representing an empty tree path.
-
-
Constructor Details
-
TreePath
Constructs a path identifying a leaf node in a tree.- Parameters:
segments
- path of elements to a leaf node in a tree, starting with the root element
-
-
Method Details
-
getSegment
Returns the element at the specified index in this path.- Parameters:
index
- index of element to return- Returns:
- element at the specified index
-
getSegmentCount
public int getSegmentCount()Returns the number of elements in this path.- Returns:
- the number of elements in this path
-
getFirstSegment
Returns the first element in this path, ornull
if this path has no segments.- Returns:
- the first element in this path
-
getLastSegment
Returns the last element in this path, ornull
if this path has no segments.- Returns:
- the last element in this path
-
equals
-
hashCode
public int hashCode() -
hashCode
Returns a hash code computed from the hash codes of the segments, using the given comparer to compute the hash codes of the segments.- Parameters:
comparer
- comparer to use ornull
if the segments' hash codes should be computed by calling their hashCode() methods.- Returns:
- the computed hash code
-
equals
Returns whether this path is equivalent to the given path using the specified comparer to compare individual elements.- Parameters:
otherPath
- tree path to compare tocomparer
- comparator to use ornull
if segments should be compared using equals()- Returns:
- whether the paths are equal
-
startsWith
Returns whether this path starts with the same segments as the given path, using the given comparer to compare segments.- Parameters:
treePath
- path to compare tocomparer
- the comparer to use, ornull
if equals() should be used to compare segments- Returns:
- whether the given path is a prefix of this path, or the same as this path
-
getParentPath
Returns a copy of this tree path with one segment removed from the end, ornull
if this tree path has no segments.- Returns:
- a tree path
-
createChildPath
Returns a copy of this tree path with the given segment added at the end.- Parameters:
newSegment
- the segment to be added- Returns:
- a tree path
-