Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
16.26. Path Interface
A portion of the Path interface is shown here:
@Immutable
public interface Path extends Comparable<Path>, Iterable<Path.Segment>, Serializable, Readable {
/**
* Return the number of segments in this path.
* @return the number of path segments
*/
public int size();
/**
* Return whether this path represents the root path.
* @return true if this path is the root path, or false otherwise
*/
public boolean isRoot();
/**
* {@inheritDoc}
*/
public Iterator<Path.Segment> iterator();
/**
* Obtain a copy of the segments in this path. None of the segments are encoded.
* @return the array of segments as a copy
*/
public Path.Segment[] getSegmentsArray();
/**
* Get an unmodifiable list of the path segments.
* @return the unmodifiable list of path segments; never null
*/
public List<Path.Segment> getSegmentsList();
/**
* Get the last segment in this path.
* @return the last segment, or null if the path is empty
*/
public Path.Segment getLastSegment();
/**
* Get the segment at the supplied index.
* @param index the index
* @return the segment
* @throws IndexOutOfBoundsException if the index is out of bounds
*/
public Path.Segment getSegment( int index );
/**
* Return an iterator that walks the paths from the root path down to this path. This method
* always returns at least one path (the root returns an iterator containing itself).
* @return the path iterator; never null
*/
public Iterator<Path> pathsFromRoot();
/**
* Return a new path consisting of the segments starting at beginIndex index (inclusive).
* This is equivalent to calling path.subpath(beginIndex,path.size()-1).
* @param beginIndex the beginning index, inclusive.
* @return the specified subpath
* @exception IndexOutOfBoundsException if the beginIndex is negative or larger
* than the length of this Path object
*/
public Path subpath( int beginIndex );
/**
* Return a new path consisting of the segments between the beginIndex index (inclusive)
* and the endIndex index (exclusive).
* @param beginIndex the beginning index, inclusive.
* @param endIndex the ending index, exclusive.
* @return the specified subpath
* @exception IndexOutOfBoundsException if the beginIndex is negative, or
* endIndex is larger than the length of this Path
* object, or beginIndex is larger than endIndex.
*/
public Path subpath( int beginIndex, int endIndex );
...
}
@Immutable
public interface Path extends Comparable<Path>, Iterable<Path.Segment>, Serializable, Readable {
/**
* Return the number of segments in this path.
* @return the number of path segments
*/
public int size();
/**
* Return whether this path represents the root path.
* @return true if this path is the root path, or false otherwise
*/
public boolean isRoot();
/**
* {@inheritDoc}
*/
public Iterator<Path.Segment> iterator();
/**
* Obtain a copy of the segments in this path. None of the segments are encoded.
* @return the array of segments as a copy
*/
public Path.Segment[] getSegmentsArray();
/**
* Get an unmodifiable list of the path segments.
* @return the unmodifiable list of path segments; never null
*/
public List<Path.Segment> getSegmentsList();
/**
* Get the last segment in this path.
* @return the last segment, or null if the path is empty
*/
public Path.Segment getLastSegment();
/**
* Get the segment at the supplied index.
* @param index the index
* @return the segment
* @throws IndexOutOfBoundsException if the index is out of bounds
*/
public Path.Segment getSegment( int index );
/**
* Return an iterator that walks the paths from the root path down to this path. This method
* always returns at least one path (the root returns an iterator containing itself).
* @return the path iterator; never null
*/
public Iterator<Path> pathsFromRoot();
/**
* Return a new path consisting of the segments starting at beginIndex index (inclusive).
* This is equivalent to calling path.subpath(beginIndex,path.size()-1).
* @param beginIndex the beginning index, inclusive.
* @return the specified subpath
* @exception IndexOutOfBoundsException if the beginIndex is negative or larger
* than the length of this Path object
*/
public Path subpath( int beginIndex );
/**
* Return a new path consisting of the segments between the beginIndex index (inclusive)
* and the endIndex index (exclusive).
* @param beginIndex the beginning index, inclusive.
* @param endIndex the ending index, exclusive.
* @return the specified subpath
* @exception IndexOutOfBoundsException if the beginIndex is negative, or
* endIndex is larger than the length of this Path
* object, or beginIndex is larger than endIndex.
*/
public Path subpath( int beginIndex, int endIndex );
...
}
There are actually quite a few methods (not shown above) for obtaining related paths: the path of the parent, the path of an ancestor, resolving a path relative to this path, normalizing a path (by removing "." and ".." segments), finding the lowest common ancestor shared with another path, etc. There are also a number of methods that compare the path with others, including determining whether a path is above, equal to, or below this path.