|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jboss.dna.graph.properties.basic.BasicPath
@Immutable public class BasicPath
A basic implementation of Path
.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.jboss.dna.graph.properties.Path |
---|
Path.Segment |
Field Summary | |
---|---|
static Path |
EMPTY_RELATIVE
|
static Path |
ROOT
|
static Path |
SELF_PATH
|
Fields inherited from interface org.jboss.dna.graph.properties.Path |
---|
DEFAULT_DECODER, DEFAULT_ENCODER, DELIMITER, DELIMITER_STR, JSR283_DECODER, JSR283_ENCODER, NO_INDEX, NO_OP_DECODER, NO_OP_ENCODER, PARENT, PARENT_NAME, PARENT_SEGMENT, SELF, SELF_NAME, SELF_SEGMENT, URL_DECODER, URL_ENCODER |
Constructor Summary | |
---|---|
BasicPath(List<Path.Segment> segments,
boolean absolute)
|
Method Summary | |
---|---|
int |
compareTo(Path that)
|
boolean |
equals(Object obj)
|
Path |
getAncestor(int degree)
Return the path to the ancestor of the supplied degree. |
Path |
getCanonicalPath()
Get the canonical form of this path. |
Path |
getCommonAncestor(Path that)
Find the lowest common ancestor of this path and the supplied path. |
Path.Segment |
getLastSegment()
Get the last segment in this path. |
Path |
getNormalizedPath()
Get a normalized path with as many ".." segments and all "." resolved. |
Path |
getParent()
Return the path to the parent, or this path if it is the root . |
Path.Segment |
getSegment(int index)
Get the segment at the supplied index. |
Path.Segment[] |
getSegmentsArray()
Obtain a copy of the segments in this path. |
List<Path.Segment> |
getSegmentsList()
Get an unmodifiable list of the path segments. |
String |
getString()
Get the string form of the path. |
String |
getString(NamespaceRegistry namespaceRegistry)
Get the string form of the path, using the supplied namespace registry to convert the names' namespace URIs to prefixes. |
String |
getString(NamespaceRegistry namespaceRegistry,
TextEncoder encoder)
Get the encoded string form of the path, using the supplied namespace registry to convert the names' namespace URIs to prefixes and the supplied encoder to encode characters in each of the path segments. |
String |
getString(NamespaceRegistry namespaceRegistry,
TextEncoder encoder,
TextEncoder delimiterEncoder)
Get the encoded string form of the path, using the supplied namespace registry to convert the names' namespace URIs to prefixes and the supplied encoder to encode characters in each of the path segments. |
String |
getString(TextEncoder encoder)
Get the encoded string form of the path, using the supplied encoder to encode characters in each of the path segments. |
int |
hashCode()
|
boolean |
hasSameAncestor(Path that)
Determine whether this path and the supplied path have the same immediate ancestor. |
boolean |
isAbsolute()
Return whether this path is an absolute path. |
boolean |
isAncestorOf(Path decendant)
Determine whether this path is an ancestor of the supplied path. |
boolean |
isAtOrAbove(Path other)
Determine whether this path is the same as to or a ancestor of the
supplied path. |
boolean |
isAtOrBelow(Path other)
Determine whether this path is the same as to or a decendant of the
supplied path. |
boolean |
isDecendantOf(Path ancestor)
Determine whether this path is an decendant of the supplied path. |
boolean |
isNormalized()
Return whether this path is normalized and contains no "." segments and as few ".." segments as possible. |
boolean |
isRoot()
Return whether this path represents the root path. |
boolean |
isSameAs(Path other)
Determine whether this path represents the same as the supplied path. |
Iterator<Path.Segment> |
iterator()
|
Path |
relativeTo(Path startingPath)
Get a relative path from the supplied path to this path. |
Path |
resolve(Path relativePath)
Get the absolute path by resolving the supplied relative (non-absolute) path against this absolute path. |
Path |
resolveAgainst(Path absolutePath)
Get the absolute path by resolving this relative (non-absolute) path against the supplied absolute path. |
int |
size()
Return the number of segments in this path. |
Path |
subpath(int beginIndex)
Return a new path consisting of the segments starting at beginIndex index (inclusive). |
Path |
subpath(int beginIndex,
int endIndex)
Return a new path consisting of the segments between the beginIndex index (inclusive) and the endIndex
index (exclusive). |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final Path ROOT
public static final Path EMPTY_RELATIVE
public static final Path SELF_PATH
Constructor Detail |
---|
public BasicPath(List<Path.Segment> segments, boolean absolute)
segments
- the segmentsabsolute
- true if this path is absolute, or false otherwiseMethod Detail |
---|
public Path getParent()
root
. This is an efficient operation that does
not require copying any data.
getParent
in interface Path
public Path getAncestor(int degree)
x
is the path that is x
levels up along the path. For example, degree = 0
returns this path, while degree = 1
returns the parent of this path, degree = 2
returns the grandparent of this path, and so on. Note that the
result may be unexpected if this path is not normalized
, as a non-normalized path contains ".." and
"." segments.
getAncestor
in interface Path
public Path getCanonicalPath()
absolute
and Path.isNormalized()
.
getCanonicalPath
in interface Path
public Path getCommonAncestor(Path that)
getCommonAncestor
in interface Path
that
- the other path
public Path.Segment getLastSegment()
getLastSegment
in interface Path
public Path getNormalizedPath()
getNormalizedPath
in interface Path
public Path.Segment getSegment(int index)
getSegment
in interface Path
index
- the index
public Path.Segment[] getSegmentsArray()
getSegmentsArray
in interface Path
public List<Path.Segment> getSegmentsList()
getSegmentsList
in interface Path
public String getString()
default encoder
is used to encode characters in each of the
path segments.
getString
in interface Path
Path.getString(TextEncoder)
public String getString(TextEncoder encoder)
getString
in interface Path
encoder
- the encoder to use, or null if the default encoder
should be used
Path.getString()
public String getString(NamespaceRegistry namespaceRegistry)
default encoder
is used to encode characters in each of the path segments. The second encoder
is used to encode (or convert) the delimiter between the namespace prefix
and the
local part
.
getString
in interface Path
namespaceRegistry
- the namespace registry that should be used to obtain the prefix for the
namespace URIs
in the segment names
Path.getString(NamespaceRegistry,TextEncoder)
,
Path.getString(NamespaceRegistry, TextEncoder, TextEncoder)
public String getString(NamespaceRegistry namespaceRegistry, TextEncoder encoder)
getString
in interface Path
namespaceRegistry
- the namespace registry that should be used to obtain the prefix for the
namespace URIs
in the segment names
encoder
- the encoder to use for encoding the local part
and
namespace prefix
of each segment
, or null if the
default encoder
should be used
Path.getString(NamespaceRegistry)
,
Path.getString(NamespaceRegistry, TextEncoder, TextEncoder)
public String getString(NamespaceRegistry namespaceRegistry, TextEncoder encoder, TextEncoder delimiterEncoder)
getString
in interface Path
namespaceRegistry
- the namespace registry that should be used to obtain the prefix for the
namespace URIs
in the segment names
encoder
- the encoder to use for encoding the local part
and
namespace prefix
of each segment
, or null if the
default encoder
should be useddelimiterEncoder
- the encoder to use for encoding the delimiter between the local part
and namespace prefix
of each segment
, and for encoding
the path delimiter, or null if the standard delimiters should be used
Path.getString(org.jboss.dna.graph.properties.NamespaceRegistry,
org.jboss.dna.common.text.TextEncoder, org.jboss.dna.common.text.TextEncoder)
public boolean hasSameAncestor(Path that)
hasSameAncestor
in interface Path
that
- the other path
public boolean isAbsolute()
absolute
. An absolute path
starts with a "/".
isAbsolute
in interface Path
public boolean isAncestorOf(Path decendant)
isAncestorOf
in interface Path
decendant
- the path that may be the decendant; may be null
public boolean isAtOrBelow(Path other)
same as
to or a decendant of
the
supplied path. This method is equivalent to (but may be more efficient than) calling isSame(other) ||
isAncestor(other)
.
isAtOrBelow
in interface Path
other
- the other path to compare with this path; may be null
Path.isAtOrBelow(org.jboss.dna.graph.properties.Path)
public boolean isAtOrAbove(Path other)
same as
to or a ancestor of
the
supplied path. This method is equivalent to (but may be more efficient than) calling isSame(other) ||
isAncestor(other)
, and is a convenience method that is identical to calling other.isAtOrBelow(this)
.
isAtOrAbove
in interface Path
other
- the other path to compare with this path; may be null
Path.isAtOrAbove(org.jboss.dna.graph.properties.Path)
public boolean isDecendantOf(Path ancestor)
isDecendantOf
in interface Path
ancestor
- the path that may be the ancestor; may be null
public boolean isNormalized()
isNormalized
in interface Path
public boolean isRoot()
isRoot
in interface Path
public boolean isSameAs(Path other)
this.compareTo(other) == 0
.
isSameAs
in interface Path
other
- the other path to compare with this path; may be null
public Iterator<Path.Segment> iterator()
iterator
in interface Iterable<Path.Segment>
iterator
in interface Path
public Path relativeTo(Path startingPath)
relativeTo
in interface Path
startingPath
- the path specifying the starting point for the new relative path; may not be null
public Path resolve(Path relativePath)
resolve
in interface Path
relativePath
- the relative path that is to be resolved against this path
public Path resolveAgainst(Path absolutePath)
resolveAgainst
in interface Path
absolutePath
- the absolute path to which this relative path should be resolve
public int size()
size
in interface Path
public Path subpath(int beginIndex)
beginIndex
index (inclusive). This is equivalent to
calling path.subpath(beginIndex,path.size()-1)
.
subpath
in interface Path
beginIndex
- the beginning index, inclusive.
public Path subpath(int beginIndex, int endIndex)
beginIndex
index (inclusive) and the endIndex
index (exclusive).
subpath
in interface Path
beginIndex
- the beginning index, inclusive.endIndex
- the ending index, exclusive.
public int hashCode()
hashCode
in class Object
public boolean equals(Object obj)
equals
in class Object
public int compareTo(Path that)
compareTo
in interface Comparable<Path>
public String toString()
toString
in class Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |