ModeShape Distribution 3.0.0.Beta4

org.modeshape.jcr.value.basic
Class ChildPath

java.lang.Object
  extended by org.modeshape.jcr.value.basic.AbstractPath
      extended by org.modeshape.jcr.value.basic.ChildPath
All Implemented Interfaces:
Serializable, Comparable<Path>, Iterable<Path.Segment>, Path, Readable

@Immutable
public class ChildPath
extends AbstractPath

Implementation of a Path that has the information for the last segment but that points to another Path for the parent information.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface org.modeshape.jcr.value.Path
Path.Segment
 
Field Summary
 
Fields inherited from class org.modeshape.jcr.value.basic.AbstractPath
EMPTY_PATH_ITERATOR, SELF_PATH
 
Fields inherited from interface org.modeshape.jcr.value.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 Summary
ChildPath(Path parent, Path.Segment child)
           
 
Method Summary
 Path getAncestor(int degree)
          Return the path to the ancestor of the supplied degree.
 Path.Segment getLastSegment()
          Get the last segment in this path.
 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.
 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 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 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 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.
 Iterator<Path.Segment> iterator()
           
 int size()
          Return the number of segments in this path.
 Path subpath(int beginIndex, int endIndex)
          Return a new path consisting of the segments between the beginIndex index (inclusive) and the endIndex index (exclusive).
 
Methods inherited from class org.modeshape.jcr.value.basic.AbstractPath
compareTo, createSegmentsSubList, doGetString, endsWith, endsWith, equals, getCanonicalPath, getCommonAncestor, getNormalizedPath, getSegmentsArray, getString, getString, getString, getString, getString, hashCode, isAncestorOf, isAtOrAbove, isIdentifier, isNormalized, isSameAs, pathsFromRoot, relativeTo, relativeToRoot, resolve, resolveAgainst, subpath, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChildPath

public ChildPath(Path parent,
                 Path.Segment child)
Method Detail

getAncestor

public Path getAncestor(int degree)
Description copied from interface: Path
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()
Description copied from class: AbstractPath
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

getLastSegment

public Path.Segment getLastSegment()
Description copied from interface: Path
Get the last segment in this path.

Specified by:
getLastSegment in interface Path
Overrides:
getLastSegment in class AbstractPath
Returns:
the last segment, or null if the path is empty

getParent

public Path getParent()
Description copied from interface: Path
Return the path to the parent, or this path if it is the root. This is an efficient operation that does not require copying any data.

Specified by:
getParent in interface Path
Overrides:
getParent in class AbstractPath
Returns:
the parent path, or this null if it is already the root

getSegment

public Path.Segment getSegment(int index)
Description copied from interface: Path
Get the segment at the supplied index.

Specified by:
getSegment in interface Path
Overrides:
getSegment in class AbstractPath
Parameters:
index - the index
Returns:
the segment

getSegmentsList

public List<Path.Segment> getSegmentsList()
Description copied from interface: Path
Get an unmodifiable list of the path segments.

Returns:
the unmodifiable list of path segments; never null

hasSameAncestor

public boolean hasSameAncestor(Path that)
Description copied from interface: Path
Determine whether this path and the supplied path have the same immediate ancestor. In other words, this method determines whether the node represented by this path is a sibling of the node represented by the supplied path.

Specified by:
hasSameAncestor in interface Path
Overrides:
hasSameAncestor in class AbstractPath
Parameters:
that - the other path
Returns:
true if this path and the supplied path have the same immediate ancestor.

isAbsolute

public boolean isAbsolute()
Description copied from interface: Path
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

isAtOrBelow

public boolean isAtOrBelow(Path other)
Description copied from interface: Path
Determine whether this path is the 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).

Specified by:
isAtOrBelow in interface Path
Overrides:
isAtOrBelow in class AbstractPath
Parameters:
other - the other path to compare with this path; may be null
Returns:
true if the paths are equivalent or if this path is considered a descendant of the other path, or false otherwise

isDescendantOf

public boolean isDescendantOf(Path ancestor)
Description copied from interface: Path
Determine whether this path is an descendant of the supplied path. A path is considered a descendant of another path if the the descendant path starts exactly with the entire ancestor path but contains at least one additional segment.

Specified by:
isDescendantOf in interface Path
Overrides:
isDescendantOf in class AbstractPath
Parameters:
ancestor - the path that may be the ancestor; may be null
Returns:
true if this path is an descendant of the supplied path, or false otherwise

isNormalized

public boolean isNormalized()
Description copied from interface: Path
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()
Description copied from interface: Path
Return whether this path represents the root path.

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

iterator

public Iterator<Path.Segment> iterator()
Specified by:
iterator in interface Iterable<Path.Segment>
Overrides:
iterator in class AbstractPath

size

public int size()
Description copied from interface: Path
Return the number of segments in this path.

Returns:
the number of path segments

subpath

public Path subpath(int beginIndex,
                    int endIndex)
Description copied from interface: Path
Return a new path consisting of the segments between the beginIndex index (inclusive) and the endIndex index (exclusive).

Specified by:
subpath in interface Path
Overrides:
subpath in class AbstractPath
Parameters:
beginIndex - the beginning index, inclusive.
endIndex - the ending index, exclusive.
Returns:
the specified subpath

ModeShape Distribution 3.0.0.Beta4

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