org.eclipse.osgi.framework.adaptor
Class FilePath

java.lang.Object
  extended by org.eclipse.osgi.framework.adaptor.FilePath

public class FilePath
extends java.lang.Object

A utility class for manipulating file system paths.

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

Since:
3.1

Constructor Summary
FilePath(java.io.File location)
          Constructs a new file path from the given File object.
FilePath(java.lang.String original)
          Constructs a new file path from the given string path.
 
Method Summary
 java.lang.String getDevice()
          Returns the device for this file system path, or null if none exists.
 java.lang.String[] getSegments()
          Returns the segments in this path.
 boolean hasTrailingSlash()
          Returns whether this path ends with a slash.
 boolean isAbsolute()
          Returns whether this path is absolute (begins with a slash).
 java.lang.String makeRelative(FilePath base)
          Returns a string representing this path as a relative to the given base path.
 java.lang.String toString()
          Returns a string representation of this path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FilePath

public FilePath(java.io.File location)
Constructs a new file path from the given File object.

Parameters:
location -

FilePath

public FilePath(java.lang.String original)
Constructs a new file path from the given string path.

Parameters:
original -
Method Detail

getDevice

public java.lang.String getDevice()
Returns the device for this file system path, or null if none exists. The device string ends with a colon.

Returns:
the device string or null

getSegments

public java.lang.String[] getSegments()
Returns the segments in this path. If this path has no segments, returns an empty array.

Returns:
an array containing all segments for this path

hasTrailingSlash

public boolean hasTrailingSlash()
Returns whether this path ends with a slash.

Returns:
true if the path ends with a slash, false otherwise

isAbsolute

public boolean isAbsolute()
Returns whether this path is absolute (begins with a slash).

Returns:
true if this path is absolute, false otherwise

makeRelative

public java.lang.String makeRelative(FilePath base)
Returns a string representing this path as a relative to the given base path.

If this path and the given path do not use the same device letter, this path's string representation is returned as is.

Parameters:
base - the path this path should be made relative to
Returns:
a string representation for this path as relative to the given base path

toString

public java.lang.String toString()
Returns a string representation of this path.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this path