com.partnersoft.data
Class PathLib

java.lang.Object
  extended by com.partnersoft.data.PathLib
All Implemented Interfaces:
Lib

public class PathLib
extends java.lang.Object
implements Lib

Library methods for dealing with Paths and string representations of Paths.

Copyright 2007 Partner Software, Inc.

Version:
$Id: PathLib.java 1012 2007-11-24 18:30:02Z paul $
Author:
Paul Reavis

Constructor Summary
PathLib()
           
 
Method Summary
static java.lang.String fileDecode(java.lang.String string)
          Decodes a String representing the name of a node in the path.
static java.lang.String fileEncode(java.lang.String string)
          Encodes a String representing the name of a node in the path, so that e.g.
static java.lang.String fileEncodeAndJoin(java.lang.String[] parts)
          Encodes each part to deal with embedded slashes and other problems, then joins them together into a single slash-separated String.
static java.lang.String[] fileSplitAndDecode(java.lang.String pathString)
          Splits the given Path String, decodes each part and returns it as a String array.
static java.lang.String urlDecode(java.lang.String string)
          Decodes a String representing the name of a node in the path.
static java.lang.String urlEncode(java.lang.String string)
          Encodes a String representing the name of a node in the path, so that e.g.
static java.lang.String urlEncodeAndJoin(java.lang.String[] parts)
          Encodes each part to deal with embedded slashes and other problems, then joins them together into a single slash-separated String.
static java.lang.String[] urlSplitAndDecode(java.lang.String pathString)
          Splits the given Path String, decodes each part and returns it as a String array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PathLib

public PathLib()
Method Detail

urlEncode

public static java.lang.String urlEncode(java.lang.String string)
Encodes a String representing the name of a node in the path, so that e.g. embedded slashes don't confuse the path string parser. Uses URLEncoder.

Parameters:
string - input name
Returns:
encoded name

urlDecode

public static java.lang.String urlDecode(java.lang.String string)
Decodes a String representing the name of a node in the path. Uses URLDecoder.

Parameters:
string - input name
Returns:
decoded name

urlSplitAndDecode

public static java.lang.String[] urlSplitAndDecode(java.lang.String pathString)
Splits the given Path String, decodes each part and returns it as a String array. Eliminates any empty parts, but otherwise makes no judgements about validity or canonicalization. Uses URLDecoder.

Parameters:
pathString - Path represented and encoded as a String.
Returns:
array of String node names

urlEncodeAndJoin

public static java.lang.String urlEncodeAndJoin(java.lang.String[] parts)
Encodes each part to deal with embedded slashes and other problems, then joins them together into a single slash-separated String. Does not put an initial slash (indicating absoluteness); you have to do that yourself it it's appropriate.

Parameters:
parts - parts to join
Returns:
encoded path string

fileEncode

public static java.lang.String fileEncode(java.lang.String string)
Encodes a String representing the name of a node in the path, so that e.g. embedded slashes don't confuse the path string parser. Uses the current operating system's native file path encoding (e.g. \ on Windows).

Parameters:
string - input name
Returns:
encoded name

fileDecode

public static java.lang.String fileDecode(java.lang.String string)
Decodes a String representing the name of a node in the path. Uses the current operating system's native file path encoding (e.g. \ on Windows).

Parameters:
string - input name
Returns:
decoded name

fileSplitAndDecode

public static java.lang.String[] fileSplitAndDecode(java.lang.String pathString)
Splits the given Path String, decodes each part and returns it as a String array. Eliminates any empty parts, but otherwise makes no judgements about validity or canonicalization. Uses the current operating system's native file path encoding (e.g. \ on Windows).

Parameters:
pathString - Path represented and encoded as a String.
Returns:
array of String node names

fileEncodeAndJoin

public static java.lang.String fileEncodeAndJoin(java.lang.String[] parts)
Encodes each part to deal with embedded slashes and other problems, then joins them together into a single slash-separated String. Does not put an initial slash (indicating absoluteness); you have to do that yourself it it's appropriate. Uses the current operating system's native file path encoding (e.g. \ on Windows).

Parameters:
parts - parts to join
Returns:
encoded path string