org.modeshape.jcr.value.basic

## Class AbstractPath

- java.lang.Object
- - org.modeshape.jcr.value.basic.AbstractPath

- All Implemented Interfaces:
    Serializable, Comparable<Path>, Iterable<Path.Segment>, Path, Readable
  Direct Known Subclasses:
    BasicPath, ChildPath, IdentifierPath, RootPath

      @Immutable
      public abstract class AbstractPath
      extends Object
      implements Path

  An abstract foundation for different `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.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.modeshape.jcr.value.Path

      `Path.Segment`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static Iterator<Path.Segment>` | `EMPTY_PATH_ITERATOR`
    `static Path` | `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

    Constructors
    Constructor and Description
    `AbstractPath()`

  - ### Method Summary

    Methods
    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()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

    - ### Methods inherited from interface org.modeshape.jcr.value.Path

      `getAncestor, getSegmentsList, isAbsolute, isNormalized, isRoot, size`

- - ### Field Detail

    - #### SELF_PATH

          public static final Path SELF_PATH

    - #### EMPTY_PATH_ITERATOR

          protected static Iterator<Path.Segment> EMPTY_PATH_ITERATOR

  - ### Constructor Detail

    - #### AbstractPath

          public AbstractPath()

  - ### Method Detail

    - #### isNormalized

          protected boolean isNormalized(List<Path.Segment> segments)

    - #### isIdentifier

          public boolean isIdentifier()

      Description copied from interface: `Path`
      Returns whether this path represents an identifier path. An identifier path is absolute, and contains a single `identifier Segment` that contains an identifier in the name.
      Specified by:
        `isIdentifier` in interface `Path`
      Returns:
        true if this path is an identifier path, or false otherwise.

    - #### getCanonicalPath

          public Path getCanonicalPath()

      Description copied from interface: `Path`
      Get the canonical form of this path. A canonical path has is `absolute` and `Path.isNormalized()`.
      Specified by:
        `getCanonicalPath` in interface `Path`
      Returns:
        the canonical path, or this object if it is already in its canonical form

    - #### getCommonAncestor

          public Path getCommonAncestor(Path that)

      Description copied from interface: `Path`
      Find the lowest common ancestor of this path and the supplied path.
      Specified by:
        `getCommonAncestor` in interface `Path`
      Parameters:
        `that` - the other path
      Returns:
        the lowest common ancestor, which may be the root path if there is no other.

    - #### getLastSegment

          public Path.Segment getLastSegment()

      Description copied from interface: `Path`
      Get the last segment in this path.
      Specified by:
        `getLastSegment` in interface `Path`
      Returns:
        the last segment, or null if the path is empty

    - #### endsWith

          public boolean endsWith(Name nameOfLastSegment)

      Description copied from interface: `Path`
      Determine if the path's `Path.getLastSegment()` has the supplied name and no `SNS index`.
      Specified by:
        `endsWith` in interface `Path`
      Parameters:
        `nameOfLastSegment` - the name
      Returns:
        return true if the supplied name is the name in the path's last segment (and there is no SNS index), or false otherwise

    - #### endsWith

          public boolean endsWith(Name nameOfLastSegment,
                         int snsIndex)

      Description copied from interface: `Path`
      Determine if the path's `Path.getLastSegment()` has the supplied name and `SNS index`.
      Specified by:
        `endsWith` in interface `Path`
      Parameters:
        `nameOfLastSegment` - the name
        `snsIndex` - the SNS index
      Returns:
        return true if the path's last segment has the supplied name and SNS, or false otherwise

    - #### 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`
      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`
      Parameters:
        `index` - the index
      Returns:
        the segment

    - #### getSegmentsArray

          public Path.Segment[] getSegmentsArray()

      Description copied from interface: `Path`
      Obtain a copy of the segments in this path. None of the segments are encoded.
      Specified by:
        `getSegmentsArray` in interface `Path`
      Returns:
        the array of segments as a copy

    - #### getNormalizedPath

          public Path getNormalizedPath()

      Description copied from interface: `Path`
      Get a normalized path with as many ".." segments and all "." resolved. The relative path ".", however, will return itself as the normalized path, since it cannot be resolved any further.
      Specified by:
        `getNormalizedPath` in interface `Path`
      Returns:
        the normalized path, or this object if this path is already normalized

    - #### getString

          public String getString()

      Description copied from interface: `Readable`
      Get the string form of the object. A `default encoder` is used to encode characters.
      Specified by:
        `getString` in interface `Readable`
      Returns:
        the encoded string
      See Also:
        `Readable.getString(TextEncoder)`

    - #### getString

          public String getString(TextEncoder encoder)

      Description copied from interface: `Readable`
      Get the encoded string form of the object, using the supplied encoder to encode characters.
      Specified by:
        `getString` in interface `Readable`
      Parameters:
        `encoder` - the encoder to use, or null if the `default encoder` should be used
      Returns:
        the encoded string
      See Also:
        `Readable.getString()`

    - #### getString

          public String getString(NamespaceRegistry namespaceRegistry)

      Description copied from interface: `Readable`
      Get the string form of the object, using the supplied namespace registry to convert any namespace URIs to prefixes. A `default encoder` is used to encode characters.
      Specified by:
        `getString` in interface `Readable`
      Parameters:
        `namespaceRegistry` - the namespace registry that should be used to obtain the prefix for any namespace URIs
      Returns:
        the encoded string
      See Also:
        `Readable.getString(NamespaceRegistry,TextEncoder)`

    - #### getString

          public String getString(NamespaceRegistry namespaceRegistry,
                         TextEncoder encoder)

      Description copied from interface: `Readable`
      Get the encoded string form of the object, using the supplied namespace registry to convert the any namespace URIs to prefixes.
      Specified by:
        `getString` in interface `Readable`
      Parameters:
        `namespaceRegistry` - the namespace registry that should be used to obtain the prefix for the namespace URIs
        `encoder` - the encoder to use, or null if the `default encoder` should be used
      Returns:
        the encoded string
      See Also:
        `Readable.getString(NamespaceRegistry)`

    - #### getString

          public String getString(NamespaceRegistry namespaceRegistry,
                         TextEncoder encoder,
                         TextEncoder delimiterEncoder)

      Description copied from interface: `Readable`
      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.
      Specified by:
        `getString` in interface `Readable`
      Parameters:
        `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 used
        `delimiterEncoder` - 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 used
      Returns:
        the encoded string
      See Also:
        `Readable.getString(NamespaceRegistry)`, `Readable.getString(NamespaceRegistry, TextEncoder)`

    - #### doGetString

          protected String doGetString(NamespaceRegistry namespaceRegistry,
                           TextEncoder encoder,
                           TextEncoder delimiterEncoder)

      Method that creates the string representation. This method works two different ways depending upon whether the namespace registry is provided.
      Parameters:
        `namespaceRegistry` -
        `encoder` -
        `delimiterEncoder` -
      Returns:
        this path as a string

    - #### 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`
      Parameters:
        `that` - the other path
      Returns:
        true if this path and the supplied path have the same immediate ancestor.

    - #### isAncestorOf

          public boolean isAncestorOf(Path descendant)

      Description copied from interface: `Path`
      Determine whether this path is an ancestor of the supplied path. A path is considered an ancestor of another path if the the ancestor path appears in its entirety at the beginning of the descendant path, and where the descendant path contains at least one additional segment.
      Specified by:
        `isAncestorOf` in interface `Path`
      Parameters:
        `descendant` - the path that may be the descendant; may be null
      Returns:
        true if this path is an ancestor of the supplied path, 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`
      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

    - #### isAtOrAbove

          public boolean isAtOrAbove(Path other)

      Description copied from interface: `Path`
      Determine whether this path is the `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)`.
      Specified by:
        `isAtOrAbove` in interface `Path`
      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 an ancestor 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`
      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

    - #### isSameAs

          public boolean isSameAs(Path other)

      Description copied from interface: `Path`
      Determine whether this path represents the same as the supplied path. This is equivalent to calling `this.compareTo(other) == 0` .
      Specified by:
        `isSameAs` in interface `Path`
      Parameters:
        `other` - the other path to compare with this path; may be null
      Returns:
        true if the paths are equivalent, or false otherwise

    - #### iterator

          public Iterator<Path.Segment> iterator()

      Specified by:
        `iterator` in interface `Iterable<Path.Segment>`

    - #### pathsFromRoot

          public Iterator<Path> pathsFromRoot()

      Description copied from interface: `Path`
      Return an iterator that walks the paths from the root path down to this path. This method always returns at least one path (the root returns an iterator containing itself).
      Specified by:
        `pathsFromRoot` in interface `Path`
      Returns:
        the path iterator; never null

    - #### relativeToRoot

          public Path relativeToRoot()

      Description copied from interface: `Path`
      Obtain a path that is relative to the root node. This is equivalent to calling `Path.relativeTo(Path)` with the root path.
      Specified by:
        `relativeToRoot` in interface `Path`
      Returns:
        the relative path from the root node; never null

    - #### relativeTo

          public Path relativeTo(Path startingPath)

      Description copied from interface: `Path`
      Get a relative path from the supplied path to this path.
      Specified by:
        `relativeTo` in interface `Path`
      Parameters:
        `startingPath` - the path specifying the starting point for the new relative path; may not be null
      Returns:
        the relative path

    - #### resolve

          public Path resolve(Path relativePath)

      Description copied from interface: `Path`
      Get the absolute path by resolving the supplied relative (non-absolute) path against this absolute path.
      Specified by:
        `resolve` in interface `Path`
      Parameters:
        `relativePath` - the relative path that is to be resolved against this path
      Returns:
        the absolute and normalized path resolved from this path and the supplied absolute path

    - #### resolveAgainst

          public Path resolveAgainst(Path absolutePath)

      Description copied from interface: `Path`
      Get the absolute path by resolving this relative (non-absolute) path against the supplied absolute path.
      Specified by:
        `resolveAgainst` in interface `Path`
      Parameters:
        `absolutePath` - the absolute path to which this relative path should be resolve
      Returns:
        the absolute path resolved from this path and the supplied absolute path

    - #### subpath

          public Path subpath(int beginIndex)

      Description copied from interface: `Path`
      Return a new path consisting of the segments starting at `beginIndex` index (inclusive). This is equivalent to calling `path.subpath(beginIndex,path.size()-1)`.
      Specified by:
        `subpath` in interface `Path`
      Parameters:
        `beginIndex` - the beginning index, inclusive.
      Returns:
        the specified subpath

    - #### 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`
      Parameters:
        `beginIndex` - the beginning index, inclusive.
        `endIndex` - the ending index, exclusive.
      Returns:
        the specified subpath

    - #### createSegmentsSubList

          protected List<Path.Segment> createSegmentsSubList(int validBeginIndex,
                                                 int validEndIndex)

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### getSegmentsOfParent

          protected abstract Iterator<Path.Segment> getSegmentsOfParent()

      Method used by `equals(Object)` implementation to quickly get an Iterator over the segments in the parent.
      Returns:
        the iterator over the segments; never null, but may not have any elements

    - #### equals

          public boolean equals(Object obj)

      Overrides:
        `equals` in class `Object`

    - #### compareTo

          public int compareTo(Path that)

      Specified by:
        `compareTo` in interface `Comparable<Path>`

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

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