Comparable<Path>
public class Path extends Object implements Comparable<Path>
Modifier and Type | Field | Description |
---|---|---|
protected String |
path |
|
static String |
SEPARATOR |
Modifier and Type | Method | Description |
---|---|---|
Path |
ancestor(int length) |
Returns the ancestor of length length of this path.
|
List<Path> |
ancestors() |
Returns all the ancestors to a path, starting with the closest.
|
Path |
child(String name) |
Returns a new path denoting a specified child element of the element denoted by this path.
|
int |
compareTo(Path that) |
|
Path |
descendant(Path endpath) |
|
Path |
endpath(int start) |
Returns an end path of this path.
|
boolean |
equals(Object o) |
|
boolean |
hasAncestor(Path ancestor) |
|
int |
hashCode() |
|
boolean |
hasParent() |
|
boolean |
isRoot() |
|
int |
length() |
|
Path |
parent() |
Returns a new path denoting the parent element of the element denoted by this path.
|
static Path |
parse(String path) |
Parses the path supplied as a string and returns a Path object representing the same path.
|
static Path |
root() |
|
String |
simpleName() |
Returns the simple name of the element denoted by this path.
|
String |
toString() |
public static final String SEPARATOR
protected final String path
protected Path(String path)
public static Path root()
public static Path parse(String path)
path
- path to parsePath
object representing the pathpublic int compareTo(Path that)
compareTo
in interface Comparable<Path>
public Path child(String name)
For instance, Path.parse("/an/example/").child("child") is equal to Path.parse("/an/example/child").
name
- The name of the child elementpublic Path parent()
For instance, Path.parse("/an/example/").parent() is equal to Path.parse("/an").
public List<Path> ancestors()
For instance, Path.parse("/an/example/path") will return a list containing the paths: "/an/example", "/an" and "/" in that order.
public String simpleName()
For instance, Path.parse("/an/example").simpleName() becomes "example".
public boolean isRoot()
public boolean hasParent()
public int length()
public Path ancestor(int length)
length
- ancestor lengthpublic Path endpath(int start)
start
- prefix lengthpublic Path descendant(Path endpath)
endpath
- path to append.public boolean hasAncestor(Path ancestor)
ancestor
- a potential ancestor that you want to evaluate.Copyright © 2021 Apptus Technologies AB. All rights reserved.