@Immutable public abstract class AbstractPath extends Object implements Path
Path
implementations. This class does not manage any of the Path
's state,
but it does provide implementations for most of the methods based upon a few abstract methods. For example, any implementaton
that requires the path's segments
are written to use the iterator()
,
since that is likely more efficient for the majority of implementations.Path.Segment
Modifier and Type | Field and Description |
---|---|
protected static Iterator<Path.Segment> |
EMPTY_PATH_ITERATOR |
static Path |
SELF_PATH |
DEFAULT_DECODER, DEFAULT_ENCODER, DEFAULT_INDEX, DELIMITER, DELIMITER_STR, IDENTIFIER_LEADING_TERMINAL, IDENTIFIER_TRAILING_TERMINAL, JSR283_DECODER, JSR283_ENCODER, NO_OP_DECODER, NO_OP_ENCODER, PARENT, PARENT_NAME, PARENT_SEGMENT, ROOT_NAME, ROOT_PATH, SELF, SELF_NAME, SELF_SEGMENT, URL_DECODER, URL_ENCODER
Constructor and Description |
---|
AbstractPath() |
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Path that) |
protected List<Path.Segment> |
createSegmentsSubList(int validBeginIndex,
int validEndIndex) |
protected String |
doGetString(NamespaceRegistry namespaceRegistry,
TextEncoder encoder,
TextEncoder delimiterEncoder)
Method that creates the string representation.
|
boolean |
endsWith(Name nameOfLastSegment)
Determine if the path's
Path.getLastSegment() has the supplied name and no SNS index . |
boolean |
endsWith(Name nameOfLastSegment,
int snsIndex)
Determine if the path's
Path.getLastSegment() has the supplied name and SNS index . |
boolean |
equals(Object obj) |
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.
|
protected abstract Iterator<Path.Segment> |
getSegmentsOfParent()
Method used by
equals(Object) implementation to quickly get an Iterator over the segments in the
parent. |
String |
getString()
Get the string form of the object.
|
String |
getString(NamespaceRegistry namespaceRegistry)
Get the string form of the object, using the supplied namespace registry to convert any namespace URIs to prefixes.
|
String |
getString(NamespaceRegistry namespaceRegistry,
TextEncoder encoder)
Get the encoded string form of the object, using the supplied namespace registry to convert the any namespace URIs to
prefixes.
|
String |
getString(NamespaceRegistry namespaceRegistry,
TextEncoder encoder,
TextEncoder delimiterEncoder)
Get the encoded string form of the object, using the supplied namespace registry to convert the names' namespace URIs to
prefixes and the supplied encoder to encode characters, and using the second delimiter to encode (or convert) the delimiter
used between the namespace prefix and the local part of any names.
|
String |
getString(TextEncoder encoder)
Get the encoded string form of the object, using the supplied encoder to encode characters.
|
int |
hashCode() |
boolean |
hasSameAncestor(Path that)
Determine whether this path and the supplied path have the same immediate ancestor.
|
boolean |
isAncestorOf(Path descendant)
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 descendant of the
supplied path. |
boolean |
isDescendantOf(Path ancestor)
Determine whether this path is an descendant of the supplied path.
|
boolean |
isIdentifier()
Returns whether this path represents an identifier path.
|
protected boolean |
isNormalized(List<Path.Segment> segments) |
boolean |
isSameAs(Path other)
Determine whether this path represents the same as the supplied path.
|
Iterator<Path.Segment> |
iterator() |
Iterator<Path> |
pathsFromRoot()
Return an iterator that walks the paths from the root path down to this path.
|
Path |
relativeTo(Path startingPath)
Get a relative path from the supplied path to this path.
|
Path |
relativeToRoot()
Obtain a path that is relative to the root node.
|
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.
|
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() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getAncestor, getSegmentsList, isAbsolute, isNormalized, isRoot, size
forEach, spliterator
public static final Path SELF_PATH
protected static Iterator<Path.Segment> EMPTY_PATH_ITERATOR
protected boolean isNormalized(List<Path.Segment> segments)
public boolean isIdentifier()
Path
identifier Segment
that contains an identifier in the name.isIdentifier
in interface Path
public Path getCanonicalPath()
Path
absolute
and Path.isNormalized()
.getCanonicalPath
in interface Path
public Path getCommonAncestor(Path that)
Path
getCommonAncestor
in interface Path
that
- the other pathpublic Path.Segment getLastSegment()
Path
getLastSegment
in interface Path
public boolean endsWith(Name nameOfLastSegment)
Path
Path.getLastSegment()
has the supplied name and no SNS index
.public boolean endsWith(Name nameOfLastSegment, int snsIndex)
Path
Path.getLastSegment()
has the supplied name and SNS index
.public Path getParent()
Path
root
. This is an efficient operation that does
not require copying any data.public Path.Segment getSegment(int index)
Path
getSegment
in interface Path
index
- the indexpublic Path.Segment[] getSegmentsArray()
Path
getSegmentsArray
in interface Path
public Path getNormalizedPath()
Path
getNormalizedPath
in interface Path
public String getString()
Readable
default encoder
is used to encode characters.getString
in interface Readable
Readable.getString(TextEncoder)
public String getString(TextEncoder encoder)
Readable
getString
in interface Readable
encoder
- the encoder to use, or null if the default encoder
should be usedReadable.getString()
public String getString(NamespaceRegistry namespaceRegistry)
Readable
default encoder
is used to encode characters.getString
in interface Readable
namespaceRegistry
- the namespace registry that should be used to obtain the prefix for any namespace URIsReadable.getString(NamespaceRegistry,TextEncoder)
public String getString(NamespaceRegistry namespaceRegistry, TextEncoder encoder)
Readable
getString
in interface Readable
namespaceRegistry
- the namespace registry that should be used to obtain the prefix for the namespace URIsencoder
- the encoder to use, or null if the default encoder
should be usedReadable.getString(NamespaceRegistry)
public String getString(NamespaceRegistry namespaceRegistry, TextEncoder encoder, TextEncoder delimiterEncoder)
Readable
getString
in interface Readable
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 any names, 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 any
names, or null if the standard delimiter should be usedReadable.getString(NamespaceRegistry)
,
Readable.getString(NamespaceRegistry, TextEncoder)
protected String doGetString(NamespaceRegistry namespaceRegistry, TextEncoder encoder, TextEncoder delimiterEncoder)
namespaceRegistry
- encoder
- delimiterEncoder
- public boolean hasSameAncestor(Path that)
Path
hasSameAncestor
in interface Path
that
- the other pathpublic boolean isAncestorOf(Path descendant)
Path
isAncestorOf
in interface Path
descendant
- the path that may be the descendant; may be nullpublic boolean isAtOrBelow(Path other)
Path
same as
to or a descendant 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 nullpublic boolean isAtOrAbove(Path other)
Path
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 nullpublic boolean isDescendantOf(Path ancestor)
Path
isDescendantOf
in interface Path
ancestor
- the path that may be the ancestor; may be nullpublic boolean isSameAs(Path other)
Path
this.compareTo(other) == 0
.public Iterator<Path.Segment> iterator()
iterator
in interface Iterable<Path.Segment>
public Iterator<Path> pathsFromRoot()
Path
pathsFromRoot
in interface Path
public Path relativeToRoot()
Path
Path.relativeTo(Path)
with the root
path.relativeToRoot
in interface Path
public Path relativeTo(Path startingPath)
Path
relativeTo
in interface Path
startingPath
- the path specifying the starting point for the new relative path; may not be nullpublic Path resolve(Path relativePath)
Path
public Path resolveAgainst(Path absolutePath)
Path
resolveAgainst
in interface Path
absolutePath
- the absolute path to which this relative path should be resolvepublic Path subpath(int beginIndex)
Path
beginIndex
index (inclusive). This is equivalent to
calling path.subpath(beginIndex,path.size()-1)
.public Path subpath(int beginIndex, int endIndex)
Path
beginIndex
index (inclusive) and the endIndex
index (exclusive).protected List<Path.Segment> createSegmentsSubList(int validBeginIndex, int validEndIndex)
protected abstract Iterator<Path.Segment> getSegmentsOfParent()
equals(Object)
implementation to quickly get an Iterator over the segments in the
parent.public int compareTo(Path that)
compareTo
in interface Comparable<Path>
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.