public abstract class Path extends Object implements Comparable<Path>
In string notation, the steps are separated by "/" slashes. The syntax supported is in fact a
small subset of XPath:
/" is an absolute location, otherwise, it is a relative location.
." (the self node) and ".." (the parent node).
/domain/customer/lastName is an absolute location.../customer/lastName is a relative location that starts at
the parent of the current node.
./customer/lastName and customer/lastName are both
relative locations that start at the current (self) node and are equivalent.| Modifier and Type | Field and Description |
|---|---|
static Path |
PARENT
Corresponds to the path "
..". |
static Path |
ROOT
Corresponds to the path "
/". |
static Path |
SELF
Corresponds to the path "
.". |
| Modifier and Type | Method and Description |
|---|---|
abstract Path |
add(Path aPath)
Concatenates this path instance with the path specified.
|
abstract Path |
add(Step aStep) |
abstract Path |
add(String aKey) |
abstract Path |
addIndex(int index)
Returns a path such that the last step is indexed with the specified number.
|
abstract Path |
addIndexedPath(Path aPath,
int index)
Concatenates this path instance with the specified indexed path.
|
abstract Path |
addIndexedStep(Step aStep,
int index)
Concatenates this path instance with the specified indexed step.
|
abstract String |
format()
Returns the canonical string representation of this instance.
|
abstract Step |
getFirstStep()
Returns the first step of this path,
null for the root path. |
abstract Step |
getLastStep()
Returns the last step of this path,
null for the root path. |
abstract Path |
getPathWithoutLastStep()
Returns this path without its last step.
|
abstract int |
getSize()
Returns the number of steps in this path.
|
abstract Step |
getStep(int i)
Returns the step at the specified position in this path.
|
abstract Step[] |
getSteps()
Returns the array of steps for this path.
|
abstract Path |
getSubPath(int beginIndex)
Returns a new path that is a subpath of this path.
|
abstract Path |
getSubPath(int beginIndex,
int endIndex)
Returns a new path that is a subpath of this path.
|
boolean |
isIndexed()
Returns
true if this Path identifies a node in an aggregated list. |
abstract boolean |
isRelative()
Returns
true if this path begins with '.' (self) or '..' (parent). |
abstract boolean |
isRoot()
Returns
true if this is the root path (whose canonical notation is "/"). |
abstract boolean |
isSelf()
Returns
true if this is the self path (whose canonical notation is "."). |
static Path |
parse(String pathString)
Returns the path based on the string specified.
|
abstract Path |
resolveWith(Path aPath)
Resolves the path specified against this instance by considering that this instance is the
"current location".
|
boolean |
startsWith(Path aPath)
Tests whether this path starts with the specified prefix.
|
abstract boolean |
startsWith(Path aPath,
int offset)
Tests whether this path starts with the specified prefix beginning at specified index.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcompareTopublic static final Path ROOT
/".public static final Path SELF
.".public static final Path PARENT
..".public static Path parse(String pathString)
This method also performs path simplification whenever
possible, if the path includes "." or "..".
public abstract Path add(Path aPath)
." or "..".
Examples:
this |
aPath |
result |
| /a/b/c | /d/e | /a/b/c/d/e |
| /a/b/c | . | /a/b/c |
| /a/b/c | ./d/e | /a/b/c/d/e |
| /a/b/c | ../d/e | /a/b/d/e |
| /a/b/c | .. | /a/b |
| /a/b/c | ../.. | /a |
| /a/b/c | ../../.. | / |
| /a/b/c | ../../../.. | .. |
| /a/b/c | ../../../../d/e | ../d/e |
| /a/b/c | ../../.. | / |
| . | /a/b/c | ./a/b/c |
| . | .. | .. |
resolveWith(Path)public abstract Path addIndex(int index)
Returns a path such that the last step is indexed with the specified number.
For example, if this instance is /customer/address and it receives
addIndex(2), then the resulting path is /customer/address[2].
This notation is only allowed on aggregated lists, not on tables. Contrary to the XPath specification, the index starts at 0 instead of 1.
IllegalStateException - if the last step of this path is already indexed.IllegalArgumentException - if index is negative.addIndexedPath(Path, int),
addIndexedStep(Step, int)public abstract Path addIndexedStep(Step aStep, int index)
For example, if this instance is /customer and it receives
addIndexedStep(Step('address'),2), then the resulting path is
/customer/address[2].
This notation is only allowed on aggregated lists, not on tables. Contrary to the XPath specification, index starts at 0 instead of 1.
This method is equivalent to add(aStep).addIndex(index).
aStep is already indexed.IllegalArgumentException - if index is negative.isIndexed(),
addIndex(int),
addIndexedPath(Path, int)public abstract Path addIndexedPath(Path aPath, int index)
Concatenates this path instance with the specified indexed path.
For example, if this instance is /item and it receives
addIndexedPath(Path('/customer/address'),2), then the resulting path is
/item/customer/address[2].
This notation is only allowed on aggregated lists, not on tables. Contrary to the XPath specification, index starts at 0 instead of 1.
This method is equivalent to add(aPath).addIndex(index).
aPath is already indexed.IllegalArgumentException - if index is negative.isIndexed(),
addIndexedStep(Step, int),
addIndex(int)public abstract Step getFirstStep()
null for the root path.public abstract Path resolveWith(Path aPath)
aPath is absolute then it returns aPath (no relative
resolution); if aPath is relative then it returns
this.add(aPath)add(Path)public abstract Step getStep(int i)
public abstract Step[] getSteps()
public abstract Step getLastStep()
null for the root path.public abstract Path getPathWithoutLastStep()
Examples and special cases:
/a/b/c, it returns /a/b/, it returns null., it returns /.., it returns /public abstract Path getSubPath(int beginIndex)
public abstract Path getSubPath(int beginIndex, int endIndex)
beginIndex key and continues to the key at index endIndex - 1.
Thus, the size of the subpath is endIndex - beginIndex.public boolean startsWith(Path aPath)
public abstract boolean startsWith(Path aPath, int offset)
public abstract int getSize()
A relative notation with SELF always counts SELF as the first
step. For example, for the notation a/b/c, this method returns '4' since the path is
interpreted as ./a/b/c.
public final boolean isIndexed()
true if this Path identifies a node in an aggregated list.
For example, the path element/item[0]/label or element/item/label[0]
identifies a node under an aggregated list.
Step.isIndexed(),
Step.getIndex()public abstract boolean isRelative()
true if this path begins with '.' (self) or '..' (parent).public abstract boolean isRoot()
true if this is the root path (whose canonical notation is "/").public abstract boolean isSelf()
true if this is the self path (whose canonical notation is ".").public abstract String format()
Examples: /a/b/c is an absolute path notation, ./a/b/c is the
notation for a relative path starting with the self node, ../a/b/c is the notation for
a relative path starting with the parent node.
parse(String)