|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.jackrabbit.name.Path
The Path utility class provides misc. methods to resolve and
nornalize JCR-style item paths.
isAbsolute():isNormalized():isCanonical():
path ::= properpath ['/']
properpath ::= abspath | relpath
abspath ::= '/' relpath
relpath ::= pathelement | relpath '/' pathelement
pathelement ::= name | name '[' number ']' | '..' | '.'
number ::= (* An integer > 0 *)
name ::= simplename | prefixedname
simplename ::= onecharsimplename |
twocharsimplename |
threeormorecharname
prefixedname ::= prefix ':' localname
localname ::= onecharlocalname |
twocharlocalname |
threeormorecharname
onecharsimplename ::= (* Any Unicode character except:
'.', '/', ':', '[', ']', '*',
''', '"', '|' or any whitespace
character *)
twocharsimplename ::= '.' onecharsimplename |
onecharsimplename '.' |
onecharsimplename onecharsimplename
onecharlocalname ::= nonspace
twocharlocalname ::= nonspace nonspace
threeormorecharname ::= nonspace string nonspace
prefix ::= (* Any valid XML Name *)
string ::= char | string char
char ::= nonspace | ' '
nonspace ::= (* Any Unicode character except:
'/', ':', '[', ']', '*',
''', '"', '|' or any whitespace
character *)
| Nested Class Summary | |
static class |
Path.CurrentElement
|
static class |
Path.ParentElement
|
static class |
Path.PathBuilder
Internal helper class used to build a path from pre-parsed path elements. |
static class |
Path.PathElement
Object representation of a single JCR path element. |
static class |
Path.RootElement
|
| Field Summary | |
static Path |
ROOT
the root path |
| Method Summary | |
static void |
checkFormat(String jcrPath)
Checks if jcrPath is a valid JCR-style absolute or relative
path. |
Path |
computeRelativePath(Path other)
Computes the relative path from this absolute path to
other. |
static Path |
create(Path parent,
Path relPath,
boolean normalize)
Creates a new Path out of the given parent |
static Path |
create(Path parent,
QName name,
boolean normalize)
Creates a new Path out of the given parent |
static Path |
create(Path parent,
QName name,
int index,
boolean normalize)
Creates a new Path out of the given parent |
static Path |
create(Path parent,
String relJCRPath,
NamespaceResolver resolver,
boolean canonicalize)
Creates a new Path out of the given parent path
and a relative path string. |
static Path |
create(QName name,
int index)
Creates a relative path based on a QName and an index. |
static Path |
create(String jcrPath,
NamespaceResolver resolver,
boolean normalize)
Creates a new Path from the given jcrPath
string. |
boolean |
denotesRoot()
Tests whether this path represents the root path, i.e. |
boolean |
equals(Object obj)
Compares the specified object with this path for equality. |
Path |
getAncestor(int degree)
Returns the ancestor path of the specified relative degree. |
int |
getAncestorCount()
Returns the number of ancestors of this path. |
Path |
getCanonicalPath()
Returns the canonical path representation of this path. |
int |
getDepth()
Returns the depth of this path. |
Path.PathElement[] |
getElements()
Returns the elements of this path. |
int |
getLength()
Returns the length of this path, i.e. |
Path.PathElement |
getNameElement()
Returns the name element (i.e. |
Path |
getNormalizedPath()
Returns the normalized path representation of this path. |
int |
hashCode()
Returns a hash code value for this path. |
boolean |
isAbsolute()
Tests whether this path is absolute, i.e. |
boolean |
isAncestorOf(Path other)
Determines if this path is an ancestor of the specified path, based on their (absolute or relative) hierarchy level as returned by . |
boolean |
isCanonical()
Tests whether this path is canonical, i.e. |
boolean |
isDescendantOf(Path other)
Determines if this path is a descendant of the specified path, based on their (absolute or relative) hierarchy level as returned by . |
boolean |
isNormalized()
Tests whether this path is normalized, i.e. |
String |
toJCRPath(NamespaceResolver resolver)
Returns a string representation of this Path in the
JCR path format. |
String |
toString()
Returns the internal string representation of this Path. |
static Path |
valueOf(String s)
Returns a Path holding the value of the specified
string. |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
public static final Path ROOT
| Method Detail |
public static Path create(String jcrPath,
NamespaceResolver resolver,
boolean normalize)
throws MalformedPathException
Path from the given jcrPath
string. If normalize is true, the returned
path will be normalized (or canonicalized if absolute).
jcrPath - resolver - normalize -
MalformedPathException
public static Path create(Path parent,
String relJCRPath,
NamespaceResolver resolver,
boolean canonicalize)
throws MalformedPathException
Path out of the given parent path
and a relative path string. If canonicalize is
true, the returned path will be canonicalized.
parent - relJCRPath - resolver - canonicalize -
MalformedPathException
public static Path create(Path parent,
Path relPath,
boolean normalize)
throws MalformedPathException
Path out of the given parent path
string and the given relative path string. If normalize is
true, the returned path will be normalized (or
canonicalized, if the parent path is absolute).
- Parameters:
parent - relPath - normalize -
- Returns:
-
- Throws:
MalformedPathException
public static Path create(Path parent,
QName name,
boolean normalize)
throws MalformedPathException
Path out of the given parent path
string and the give name. If normalize is true,
the returned path will be normalized (or canonicalized, if the parent
path is absolute).
- Parameters:
parent - name - normalize -
- Returns:
-
- Throws:
MalformedPathException
public static Path create(Path parent,
QName name,
int index,
boolean normalize)
throws MalformedPathException
Path out of the given parent path
and the give name and index. If normalize is
true, the returned path will be normalized
(or canonicalized, if the parent path is absolute).
- Parameters:
parent - name - index - normalize -
- Returns:
-
- Throws:
MalformedPathException
public static Path create(QName name,
int index)
throws IllegalArgumentException
QName and an index.
name - single QName for this relative path.index - index of the sinlge name element.
name.
IllegalArgumentException - if index is negative.
public static void checkFormat(String jcrPath)
throws MalformedPathException
jcrPath is a valid JCR-style absolute or relative
path.
jcrPath - the path to be checked
MalformedPathException - If jcrPath is not a valid
JCR-style path.public boolean denotesRoot()
public boolean isAbsolute()
public boolean isCanonical()
isAbsolute()public boolean isNormalized()
getNormalizedPath()
public Path getNormalizedPath()
throws MalformedPathException
MalformedPathException - if the path cannot be normalized.isNormalized()
public Path getCanonicalPath()
throws MalformedPathException
MalformedPathException - if this path can not be canonicalized
(e.g. if it is relative)
public Path computeRelativePath(Path other)
throws MalformedPathException
this absolute path to
other.
other - an absolute path
this path to
other path
MalformedPathException - if either this or
other path is not absolute
public Path getAncestor(int degree)
throws IllegalArgumentException,
PathNotFoundException
degree - the relative degree of the requested ancestor.
PathNotFoundException - if there is no ancestor of the specified
degree
IllegalArgumentException - if degree is negativepublic int getAncestorCount()
getDepth() - 1.
Note that the returned value might be negative if this path is not
canonical, e.g. the depth of "../../a" is -1, its ancestor count is
therefore -2.
getDepth(),
getLength(),
isCanonical()public int getLength()
getDepth().
getDepth(),
getAncestorCount()public int getDepth()
getLength(),
getAncestorCount()
public boolean isAncestorOf(Path other)
throws MalformedPathException
getDepth().
true if other is a descendant;
otherwise false
MalformedPathException - if not both paths are either absolute or
relative.getDepth()
public boolean isDescendantOf(Path other)
throws MalformedPathException
getDepth().
true if other is an ancestor;
otherwise false
MalformedPathException - if not both paths are either absolute or
relative.getDepth()public Path.PathElement getNameElement()
public Path.PathElement[] getElements()
public String toJCRPath(NamespaceResolver resolver)
throws NoPrefixDeclaredException
Path in the
JCR path format.
resolver - namespace resolver
NoPrefixDeclaredException - if a namespace can not be resolvedpublic String toString()
Path.
Note that the returned string is not a valid JCR path, i.e. the
namespace URI's of the individual path elements are not replaced with
their mapped prefixes. Call
toJCRPath(NamespaceResolver)
for a JCR path representation.
Path.
public static Path valueOf(String s)
throws IllegalArgumentException
Path holding the value of the specified
string. The string must be in the format returned by the
Path.toString() method.
s - a String containing the Path
representation to be parsed.
Path represented by the argument
IllegalArgumentException - if the specified string can not be parsed
as a Path.toString()public int hashCode()
Object.hashCode()public boolean equals(Object obj)
obj - the object to be compared for equality with this path.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||