org.modeshape.graph.property.basic
Class BasicPath

java.lang.Object
  extended by org.modeshape.graph.property.basic.AbstractPath
      extended by org.modeshape.graph.property.basic.BasicPath
All Implemented Interfaces:
Serializable, Comparable<Path>, Iterable<Path.Segment>, Path, Readable

@Immutable
public class BasicPath
extends AbstractPath

A basic implementation of Path.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.modeshape.graph.property.basic.AbstractPath
AbstractPath.SingleIterator<T>
 
Nested classes/interfaces inherited from interface org.modeshape.graph.property.Path
Path.Segment
 
Field Summary
static Path EMPTY_RELATIVE
           
static Path PARENT_PATH
           
static Path SELF_PATH
           
 
Fields inherited from class org.modeshape.graph.property.basic.AbstractPath
EMPTY_PATH_ITERATOR
 
Fields inherited from interface org.modeshape.graph.property.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, SELF, SELF_NAME, SELF_SEGMENT, URL_DECODER, URL_ENCODER
 
Constructor Summary
BasicPath(List<Path.Segment> segments, boolean absolute)
           
 
Method Summary
 Path getAncestor(int degree)
          Return the path to the ancestor of the supplied degree.
 List<Path.Segment> getSegmentsList()
          Get an unmodifiable list of the path segments.
protected  Iterator<Path.Segment> getSegmentsOfParent()
          Method used by AbstractPath.equals(Object) implementation to quickly get an Iterator over the segments in the parent.
 boolean isAbsolute()
          Return whether this path is an absolute path.
 boolean isNormalized()
          Return whether this path is normalized and contains no unnecessary "." segments and as few ".." segments as possible.
 boolean isRoot()
          Return whether this path represents the root path.
 int size()
          Return the number of segments in this path.
 
Methods inherited from class org.modeshape.graph.property.basic.AbstractPath
compareTo, createSegmentsSubList, doGetString, endsWith, endsWith, equals, getCanonicalPath, getCommonAncestor, getLastSegment, getNormalizedPath, getParent, getSegment, getSegmentsArray, getString, getString, getString, getString, getString, hashCode, hasSameAncestor, isAncestorOf, isAtOrAbove, isAtOrBelow, isDecendantOf, isIdentifier, isNormalized, isSameAs, iterator, pathsFromRoot, relativeTo, relativeToRoot, resolve, resolveAgainst, subpath, subpath, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY_RELATIVE

public static final Path EMPTY_RELATIVE

SELF_PATH

public static final Path SELF_PATH

PARENT_PATH

public static final Path PARENT_PATH
Constructor Detail

BasicPath

public BasicPath(List<Path.Segment> segments,
                 boolean absolute)
Parameters:
segments - the segments
absolute - true if this path is absolute, or false otherwise
Method Detail

getAncestor

public Path getAncestor(int degree)
Return the path to the ancestor of the supplied degree. An ancestor of 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.

Returns:
the ancestor of the supplied degree

getSegmentsOfParent

protected Iterator<Path.Segment> getSegmentsOfParent()
Method used by AbstractPath.equals(Object) implementation to quickly get an Iterator over the segments in the parent.

Specified by:
getSegmentsOfParent in class AbstractPath
Returns:
the iterator over the segments; never null, but may not have any elements
See Also:
AbstractPath.getSegmentsOfParent()

getSegmentsList

public List<Path.Segment> getSegmentsList()
Get an unmodifiable list of the path segments.

Returns:
the unmodifiable list of path segments; never null

isAbsolute

public boolean isAbsolute()
Return whether this path is an absolute path. A path is either relative or absolute. An absolute path starts with a "/".

Returns:
true if the path is absolute, or false otherwise

isNormalized

public boolean isNormalized()
Return whether this path is normalized and contains no unnecessary "." segments and as few ".." segments as possible. For example, the path "../a" is normalized, while "/a/b/c/../d" is not normalized.

Returns:
true if this path is normalized, or false otherwise

isRoot

public boolean isRoot()
Return whether this path represents the root path.

Returns:
true if this path is the root path, or false otherwise

size

public int size()
Return the number of segments in this path.

Returns:
the number of path segments


Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.