com.stellent.cis.common.util
Class PathHelper

java.lang.Object
  extended by com.stellent.cis.common.util.PathHelper

public class PathHelper
extends java.lang.Object


Field Summary
static java.lang.String BACKWARD_SLASH_STRING
           
protected static char CHAR_QUOTE
           
protected static char CHAR_SPACE
           
protected static char FORWARD_SLASH
           
static java.lang.String FORWARD_SLASH_STRING
           
protected static java.lang.String PATH_CHARS
           
static java.lang.String PROTOCOL_MARK
           
protected static java.lang.String STR_QUOTE
           
 
Constructor Summary
PathHelper()
           
 
Method Summary
static java.lang.String appendPath(java.lang.String dirName, java.lang.String filePath)
           
static java.lang.String ensureForwardSlashes(java.lang.String path)
          Changes backward slashes to forward slashes.
static java.lang.String ensureNoProtocolInPath(java.lang.String path)
          Ensure the path does not start with a protocol specification
For example: aaa --> aaa file:/aaa --> aaa file:/aaa/bbb/ccc --> aaa/bbb/ccc /aaa/bbb/ccc --> aaa/bbb/ccc / --> / null --> null
static java.lang.String ensureStartingSlash(java.lang.String path)
          Ensure the path starts with a slash
For example: aaa --> /aaa aaa/ --> /aaa/ aaa/bbb/ccc --> /aaa/bbb/ccc /aaa/bbb/ccc --> /aaa/bbb/ccc / --> / null --> null
static java.lang.String ensureTrailingSlash(java.lang.String path)
          Ensure the path ends with a slash
For example: aaa --> aaa/ /aaa --> /aaa/ aaa/bbb/ccc --> /aaa/bbb/ccc/ /aaa/bbb/ccc --> /aaa/bbb/ccc/ / --> / null --> null
static java.lang.String getDirectoryPath(java.lang.String filepath)
          Returns folder path for a file location
static java.lang.String getFirstPathSegment(java.lang.String path)
          Parse first segment out of a path
For example: aaa/bbb/ccc --> aaa /aaa/bbb/ccc --> aaa / --> null null --> null
static java.lang.String getFirstPathSegment(java.lang.String path, char separator)
           
static java.lang.String getLastPathSegment(java.lang.String path)
          Parse last segment out of a path
For example: aaa/bbb/ccc --> ccc aaa/bbb/ccc/ --> ccc / --> null null --> null
static java.lang.String getPathSegment(java.lang.String path, int segment, boolean fromStart)
          Returns the specified path segment.
static boolean hasProtocolInPath(java.lang.String path)
          Checks whether the path has a protocol specification
static boolean isLongFileName(java.lang.String fileName)
          Checks wether given file name is long file name.
static boolean isPathAbsolute(java.lang.String path)
          Determines if the given path is absolute or relative.
static java.lang.String justFileName(java.lang.String fullFilePath)
          Returns just file name from the specified full file path
static java.util.ArrayList makeMaskList(java.util.ArrayList folderList, java.lang.String extension)
           
static java.lang.String normalizePath(java.lang.String filePath)
           
static java.lang.String quotePath(java.lang.String filePath)
           
static java.lang.String removeStartingSlash(java.lang.String path)
          Remove the beginning slash from the given path.
static java.lang.String removeTrailingSlash(java.lang.String path)
          Remove the ending slash from the given path.
static java.lang.String setFileExt(java.lang.String filepath, java.lang.String extencion)
          Replaces current filepath extencion
static java.lang.String stripFirstSegment(java.lang.String path)
          Strip first segment out of a path
For example: aaa --> null aaa/ --> null aaa/bbb/ccc --> bbb/ccc aaa/bbb/ccc/ --> /bbb/ccc/ / --> null null --> null
static java.lang.String stripFirstSegment(java.lang.String path, char separator)
           
static java.lang.String stripLastSegment(java.lang.String path)
          Strip last segment out of a path
For example: aaa --> null aaa/ --> null aaa/bbb/ccc --> aaa/bbb/ /aaa/bbb/ccc --> /aaa/bbb/ / --> null null --> null
static java.lang.String stripLastSegment(java.lang.String path, char separator)
           
static java.lang.String stripPath(java.lang.String path)
          Ensure the path does not start or end with slash
For example: aaa --> aaa /aaa --> aaa aaa/bbb/ccc --> aaa/bbb/ccc /aaa/bbb/ccc --> aaa/bbb/ccc / --> null null --> null
static java.lang.String stripPath(java.lang.String path, char separator)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROTOCOL_MARK

public static final java.lang.String PROTOCOL_MARK
See Also:
Constant Field Values

FORWARD_SLASH_STRING

public static final java.lang.String FORWARD_SLASH_STRING
See Also:
Constant Field Values

BACKWARD_SLASH_STRING

public static final java.lang.String BACKWARD_SLASH_STRING
See Also:
Constant Field Values

FORWARD_SLASH

protected static final char FORWARD_SLASH
See Also:
Constant Field Values

CHAR_SPACE

protected static final char CHAR_SPACE
See Also:
Constant Field Values

CHAR_QUOTE

protected static final char CHAR_QUOTE
See Also:
Constant Field Values

STR_QUOTE

protected static final java.lang.String STR_QUOTE
See Also:
Constant Field Values

PATH_CHARS

protected static final java.lang.String PATH_CHARS
See Also:
Constant Field Values
Constructor Detail

PathHelper

public PathHelper()
Method Detail

getFirstPathSegment

public static java.lang.String getFirstPathSegment(java.lang.String path)
Parse first segment out of a path
For example:


getFirstPathSegment

public static java.lang.String getFirstPathSegment(java.lang.String path,
                                                   char separator)
Parameters:
path -
separator - is the sepataor
See Also:
getFirstPathSegment(java.lang.String)

getLastPathSegment

public static java.lang.String getLastPathSegment(java.lang.String path)
Parse last segment out of a path
For example:


getPathSegment

public static java.lang.String getPathSegment(java.lang.String path,
                                              int segment,
                                              boolean fromStart)
Returns the specified path segment. The first path segment has an index of 0.


stripFirstSegment

public static java.lang.String stripFirstSegment(java.lang.String path)
Strip first segment out of a path
For example:


stripFirstSegment

public static java.lang.String stripFirstSegment(java.lang.String path,
                                                 char separator)
See Also:
stripFirstSegment(java.lang.String)

stripLastSegment

public static java.lang.String stripLastSegment(java.lang.String path)
Strip last segment out of a path
For example:


stripLastSegment

public static java.lang.String stripLastSegment(java.lang.String path,
                                                char separator)
Parameters:
path -
separator - the sepatator of the path
See Also:
stripLastSegment(java.lang.String)

ensureStartingSlash

public static java.lang.String ensureStartingSlash(java.lang.String path)
Ensure the path starts with a slash
For example:


ensureTrailingSlash

public static java.lang.String ensureTrailingSlash(java.lang.String path)
Ensure the path ends with a slash
For example:


stripPath

public static java.lang.String stripPath(java.lang.String path)
Ensure the path does not start or end with slash
For example:


stripPath

public static java.lang.String stripPath(java.lang.String path,
                                         char separator)
Parameters:
path -
separator - is the separator
See Also:
stripPath(java.lang.String)

isPathAbsolute

public static boolean isPathAbsolute(java.lang.String path)
Determines if the given path is absolute or relative. The path is considered absolute if it begins with a slash (''')

Parameters:
path - the path to examine
Returns:
true if the path is absolute, false otherwise

removeStartingSlash

public static java.lang.String removeStartingSlash(java.lang.String path)
Remove the beginning slash from the given path. If the path does not start with a slash, then the path is returned

Parameters:
path - the path to examine
Returns:
the path without a starting slash

removeTrailingSlash

public static java.lang.String removeTrailingSlash(java.lang.String path)
Remove the ending slash from the given path. If the path does not end with a slash, then the path is returned

Parameters:
path - the path to examine
Returns:
the path without a ending slash

ensureNoProtocolInPath

public static java.lang.String ensureNoProtocolInPath(java.lang.String path)
Ensure the path does not start with a protocol specification
For example:


hasProtocolInPath

public static boolean hasProtocolInPath(java.lang.String path)
Checks whether the path has a protocol specification

Parameters:
path - Path to be searched for presence of s protocol specifier
Returns:
boolean True if there is protocol specifier in the Path For example:
  • aaa --> false
  • file:/aaa --> true
  • file:/aaa/bbb/ccc --> true
  • /aaa/bbb/ccc --> false
  • / --> false
  • null --> false

ensureForwardSlashes

public static java.lang.String ensureForwardSlashes(java.lang.String path)
Changes backward slashes to forward slashes. This is useful for all functions in this class that check for slashes, they assume forward slash.

Parameters:
path - string to modify
Returns:
all bachward slashed changes to forward

getDirectoryPath

public static java.lang.String getDirectoryPath(java.lang.String filepath)
Returns folder path for a file location

Parameters:
filepath - is path to a file
Returns:
folder path where file resides or null if file does not have a parent

setFileExt

public static java.lang.String setFileExt(java.lang.String filepath,
                                          java.lang.String extencion)
Replaces current filepath extencion

Parameters:
filepath - is path to a file
Returns:
new path with changed extencion

justFileName

public static java.lang.String justFileName(java.lang.String fullFilePath)
Returns just file name from the specified full file path


appendPath

public static java.lang.String appendPath(java.lang.String dirName,
                                          java.lang.String filePath)

normalizePath

public static java.lang.String normalizePath(java.lang.String filePath)
Parameters:
filePath -
Returns:

makeMaskList

public static java.util.ArrayList makeMaskList(java.util.ArrayList folderList,
                                               java.lang.String extension)

quotePath

public static java.lang.String quotePath(java.lang.String filePath)

isLongFileName

public static boolean isLongFileName(java.lang.String fileName)
Checks wether given file name is long file name. Uses very primitive and simple approach.

Parameters:
fileName -
Returns: