org.enhydra.shark.xpdl
Class Path

java.lang.Object
  extended by org.enhydra.shark.xpdl.Path

public class Path
extends java.lang.Object

Paths are always maintained in canonicalized form. That is, parent references (i.e., ../../) and duplicate separators are resolved. For example,

     new Path("/a/b").append("../foo/bar")
will yield the path
     /a/foo/bar

This class is not intended to be subclassed by clients but may be instantiated.


Field Summary
static char DEVICE_SEPARATOR
          Device separator character constant ":" used in paths.
static Path EMPTY
          Constant value containing the empty path with no device.
static Path ROOT
          Constant value containing the root path with no device.
static char SEPARATOR
          Path separator character constant "/" used in paths.
 
Constructor Summary
Path(java.lang.String fullPath)
          Constructs a new path from the given string path.
Path(java.lang.String device, java.lang.String path)
          Constructs a new path from the given device id and string path.
 
Method Summary
static java.lang.String getRelativePath(Path fullPath, Path fBasePath)
           
 boolean isAbsolute()
           
 int matchingFirstSegments(Path anotherPath)
           
 java.lang.String segment(int index)
           
 int segmentCount()
           
 java.lang.String[] segments()
           
 Path setDevice(java.lang.String value)
           
 java.lang.String toOSString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEPARATOR

public static final char SEPARATOR
Path separator character constant "/" used in paths.

See Also:
Constant Field Values

DEVICE_SEPARATOR

public static final char DEVICE_SEPARATOR
Device separator character constant ":" used in paths.

See Also:
Constant Field Values

ROOT

public static final Path ROOT
Constant value containing the root path with no device.


EMPTY

public static final Path EMPTY
Constant value containing the empty path with no device.

Constructor Detail

Path

public Path(java.lang.String fullPath)
Constructs a new path from the given string path. The given string path must be valid. The path is canonicalized and double slashes are removed except at the beginning. (to handle UNC paths) All backslashes ('\') are replaced with forward slashes. ('/')

Parameters:
fullPath - the string path

Path

public Path(java.lang.String device,
            java.lang.String path)
Constructs a new path from the given device id and string path. The given string path must be valid. The path is canonicalized and double slashes are removed except at the beginning (to handle UNC paths). All backslashes ('\') are replaced with forward slashes. ('/')

Parameters:
device - the device id
path - the string path
See Also:
setDevice(java.lang.String)
Method Detail

isAbsolute

public boolean isAbsolute()

matchingFirstSegments

public int matchingFirstSegments(Path anotherPath)

segment

public java.lang.String segment(int index)

segmentCount

public int segmentCount()

segments

public java.lang.String[] segments()

setDevice

public Path setDevice(java.lang.String value)

toOSString

public java.lang.String toOSString()

getRelativePath

public static java.lang.String getRelativePath(Path fullPath,
                                               Path fBasePath)