org.codehaus.plexus.util
Class PathTool

java.lang.Object
  extended byorg.codehaus.plexus.util.PathTool

public class PathTool
extends java.lang.Object

Path tool contains static methods to assist in determining path-related information such as relative paths.

Version:
$Id: PathTool.java 5958 2007-02-28 10:29:55Z olamy $
Author:
Pete Kazmier, Vincent Massol

Constructor Summary
PathTool()
           
 
Method Summary
static java.lang.String calculateLink(java.lang.String link, java.lang.String relativePath)
          Calculates the appropriate link given the preferred link and the relativePath of the document
static java.lang.String getDirectoryComponent(java.lang.String filename)
          Determines the directory component of a filename.
static java.lang.String getRelativePath(java.lang.String filename)
          Determines the relative path of a filename.
static java.lang.String getRelativePath(java.lang.String basedir, java.lang.String filename)
          Determines the relative path of a filename from a base directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathTool

public PathTool()
Method Detail

getRelativePath

public static final java.lang.String getRelativePath(java.lang.String basedir,
                                                     java.lang.String filename)
Determines the relative path of a filename from a base directory. This method is useful in building relative links within pages of a web site. It provides similar functionality to Anakia's $relativePath context variable. The arguments to this method may contain either forward or backward slashes as file separators. The relative path returned is formed using forward slashes as it is expected this path is to be used as a link in a web page (again mimicking Anakia's behavior).

This method is thread-safe.

Parameters:
basedir - The base directory.
filename - The filename that is relative to the base directory.
Returns:
The relative path of the filename from the base directory. This value is not terminated with a forward slash. A zero-length string is returned if: the filename is not relative to the base directory, basedir is null or zero-length, or filename is null or zero-length.

getRelativePath

public static final java.lang.String getRelativePath(java.lang.String filename)
Determines the relative path of a filename. This method is useful in building relative links within pages of a web site. It provides similar functionality to Anakia's $relativePath context variable. The argument to this method may contain either forward or backward slashes as file separators. The relative path returned is formed using forward slashes as it is expected this path is to be used as a link in a web page (again mimicking Anakia's behavior).

This method is thread-safe.

Parameters:
filename - The filename to be parsed.
Returns:
The relative path of the filename. This value is not terminated with a forward slash. A zero-length string is returned if: filename is null or zero-length.

getDirectoryComponent

public static final java.lang.String getDirectoryComponent(java.lang.String filename)
Determines the directory component of a filename. This is useful within DVSL templates when used in conjunction with the DVSL's $context.getAppValue("infilename") to get the current directory that is currently being processed.

This method is thread-safe.

Parameters:
filename - The filename to be parsed.
Returns:
The directory portion of the filename. If the filename does not contain a directory component, "." is returned.

calculateLink

public static final java.lang.String calculateLink(java.lang.String link,
                                                   java.lang.String relativePath)
Calculates the appropriate link given the preferred link and the relativePath of the document

Parameters:
link -
relativePath -
Returns:
String


Copyright © 2001-2007 Codehaus. All Rights Reserved.