public class Path extends Object implements Serializable, Cloneable
The Path object is used to standard used to standardize the creation of mutation of path-like structures. For: example /foo/bar/index.html.
Below are the rules for how the constructor interprets literal paths.
NOTE the addSegment(String) interprets string
pathes in a somewhat different manner.
| Literal Path | Interpretation | /foo/bar/index.html | foo and bar will be considered directory
segments while index.html will be considered a file segment.
This means that the baseName will be set to index and
the fileExtension will be set to .html |
|---|---|
| /foo/bar/, /foo/bar, foo/bar/ foo/bar |
I cases where a file has no extension you must use the
|
| Modifier and Type | Field and Description |
|---|---|
static String |
PATH_SEPERATOR |
| Modifier and Type | Method and Description |
|---|---|
Path |
addSegment(String segment)
Adds this segment to the end of the path but before the current file
segment, if one exists.
|
boolean |
equals(Object obj) |
String |
getBaseName() |
Path |
getChild(Path childPath) |
Path |
getChild(String childPath) |
String |
getFileExtension() |
String |
getFileName() |
String |
getQueryString() |
String |
getSegment(int i)
Returns the segement of the path at the specified index
i. |
Path |
getSubPath(int beginAtSegment) |
Path |
getSubPath(int beginAtSegment,
int endSegment) |
int |
hashCode() |
int |
length() |
Path |
removeLastPathSegment()
Removes the last directory segment in this path.
|
String |
toString() |
public static final String PATH_SEPERATOR
public Path()
public Path(String path)
public String getSegment(int i)
i.i - index containing the segment to return.iArrayIndexOutOfBoundsException - if the index is not within the bounds of this Path.public Path addSegment(String segment)
Adds this segment to the end of the path but before the current file segment, if one exists. For consistency Segments added via this method are ALWAYS considered directories even when matching a standrad file pattern i.e. index.html
If you need to set the file segment, please use the setFileSegment() method.
segment - public Path getSubPath(int beginAtSegment)
public Path getSubPath(int beginAtSegment, int endSegment)
public String getBaseName()
public String getFileExtension()
public String getFileName()
public String getQueryString()
public int length()
public Path removeLastPathSegment()
Copyright © 1999–2015 The Apache Software Foundation. All rights reserved.