com.softwareag.mdm.schema
Class Path

java.lang.Object
  extended bycom.softwareag.mdm.schema.Path
All Implemented Interfaces:
Comparable

public abstract class Path
extends Object
implements Comparable

A path is used for locating a node in a tree structure. It consists of a sequence of steps, each step identifying a branch in the tree.

In the string notation, the steps are separated by "/" (slash). The syntax supported is indeed a small subset of XPath:

Examples :


Field Summary
static Path PARENT
          Corresponds to the path "..
static Path ROOT
          Corresponds to the path "/".
static Path SELF
          Corresponds to the path ".
 
Method Summary
abstract  Path add(Path aPath)
          Concatenates this path instance with the path specified.
abstract  Path add(Step aStep)
           
abstract  Path add(String aKey)
           
abstract  String format()
          Returns the canonical string representation of this instance.
abstract  Step getFirstStep()
          Returns the first step of this path, null for root path.
abstract  Step getLastStep()
          Returns the last step of this path, null for root path.
abstract  Path getPathWithoutLastStep()
          Returns this path minus its last step.
abstract  int getSize()
          Returns the number of steps in this path.
abstract  Step getStep(int i)
          Returns the step at the specified position in this path.
abstract  Step[] getSteps()
          Returns the steps array of this path.
abstract  Path getSubPath(int beginIndex)
          Returns a new path that is a subpath of this path.
abstract  Path getSubPath(int beginIndex, int endIndex)
          Returns a new path that is a subpath of this path.
abstract  boolean isRelative()
          Returns true if this path begins with '.'
abstract  boolean isRoot()
          Returns true if this is the root path (whose canonical notation is " / ").
abstract  boolean isSelf()
          Returns true if this is the self path (whose canonical notation is " .
static Path parse(String pathString)
          Returns the path from the string specified.
abstract  Path resolveWith(Path aPath)
          Resolves the path specified against this instance by considering that this instance is the "current location".
 boolean startsWith(Path aPath)
          Tests if this path starts with the specified prefix.
abstract  boolean startsWith(Path aPath, int offset)
          Tests if this path starts with the specified prefix beginning at specified index.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.lang.Comparable
compareTo
 

Field Detail

ROOT

public static final Path ROOT
Corresponds to the path "/".


SELF

public static final Path SELF
Corresponds to the path ".".


PARENT

public static final Path PARENT
Corresponds to the path "..".

Method Detail

parse

public static Path parse(String pathString)
Returns the path from the string specified.

See class comment for syntax description. This method also operates path simplification when possible if it includes . or ...


add

public abstract Path add(String aKey)
See Also:
add(Path)

add

public abstract Path add(Path aPath)
Concatenates this path instance with the path specified. This method also performs path simplfication if path specified begins with SELF and PARENT.

Examples:

this aPath result
/a/b/c /d/e /a/b/c/d/e
/a/b/c . /a/b/c
/a/b/c ./d/e /a/b/c/d/e
/a/b/c ../d/e /a/b/d/e
/a/b/c .. /a/b
/a/b/c ../.. /a
/a/b/c ../../.. /
/a/b/c ../../../.. ..
/a/b/c ../../../../d/e ../d/e
/a/b/c ../../.. /
. /a/b/c ./a/b/c
. .. ..

See Also:
resolveWith(Path)

add

public abstract Path add(Step aStep)
See Also:
add(Path)

getFirstStep

public abstract Step getFirstStep()
Returns the first step of this path, null for root path.


resolveWith

public abstract Path resolveWith(Path aPath)
Resolves the path specified against this instance by considering that this instance is the "current location".

Returns:
if aPath is absolute then it returns aPath (no relative resolution); if aPath is relative then it returns this.add(aPath)
See Also:
add(Path)

getStep

public abstract Step getStep(int i)
Returns the step at the specified position in this path.


getSteps

public abstract Step[] getSteps()
Returns the steps array of this path.


getLastStep

public abstract Step getLastStep()
Returns the last step of this path, null for root path.


getPathWithoutLastStep

public abstract Path getPathWithoutLastStep()
Returns this path minus its last step.

Example and special cases:


getSubPath

public abstract Path getSubPath(int beginIndex)
Returns a new path that is a subpath of this path. The subpath begins at the specified beginIndex key and extends to the end of this path.


getSubPath

public abstract Path getSubPath(int beginIndex,
                                int endIndex)
Returns a new path that is a subpath of this path. The subpath begins at the specified beginIndex key and extends to the key at index endIndex - 1. Thus the size of the subpath is endIndex-beginIndex.


startsWith

public boolean startsWith(Path aPath)
Tests if this path starts with the specified prefix.


startsWith

public abstract boolean startsWith(Path aPath,
                                   int offset)
Tests if this path starts with the specified prefix beginning at specified index.


getSize

public abstract int getSize()
Returns the number of steps in this path.

A relative notation with SELF always counts SELF as a first step. For example, for the notation a/b/c, this method returns 4 since it is viewed as ./a/b/c.


isRelative

public abstract boolean isRelative()
Returns true if this path begins with '.' (current) or '..' (parent).


isRoot

public abstract boolean isRoot()
Returns true if this is the root path (whose canonical notation is " / ").


isSelf

public abstract boolean isSelf()
Returns true if this is the self path (whose canonical notation is " . ").


format

public abstract String format()
Returns the canonical string representation of this instance.

Examples: /a/b/c is an absolute path notation, ./a/b/c is the notation for a relative path starting with self, ../a/b/c is the notation for a relative path starting with parent; .

See Also:
parse(String)


(report a bug)
webMethods MDM 4.2.8 [0558]
Copyright Software AG 2000-2007. All rights reserved.