|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.wsspi.kernel.service.utils.PathUtils
public class PathUtils
Nested Class Summary | |
---|---|
static class |
PathUtils.PathComparator
A Path Comparator that will sort paths in order. |
Field Summary | |
---|---|
static java.util.Comparator<java.lang.String> |
PATH_COMPARATOR
|
Constructor Summary | |
---|---|
PathUtils()
|
Method Summary | |
---|---|
static java.lang.String |
checkAndNormalizeRootPath(java.lang.String path)
This method will do the following to the path: |
static boolean |
checkCase(java.io.File file,
java.lang.String pathToTest)
This method will test that the case of the supplied existing File matches the case in the pathToTest. |
static boolean |
containsSymbol(java.lang.String s)
|
static java.lang.String |
getChildUnder(java.lang.String path,
java.lang.String parentPath)
Given a path, and a super path, return the immediate child of the super path in the path. |
static java.lang.String |
getFirstPathComponent(java.lang.String path)
Obtains the 1st component of a path |
static java.lang.String |
getName(java.lang.String pathAndName)
Gets the name from a path component |
static java.lang.String |
getParent(java.lang.String path)
Gets the parent section of a given path. |
static java.lang.String |
getSymbol(java.lang.String s)
|
static boolean |
isNormalizedPathAbsolute(java.lang.String nPath)
|
static boolean |
isSymbol(java.lang.String s)
|
static boolean |
isUnixStylePathAbsolute(java.lang.String unixStylePath)
This method ensures that the supplied path is not attempting to traverse up the directory structure from its current location by using the .. |
static java.lang.String |
normalize(java.lang.String path)
Strip "." and ".." elements from path. |
static java.lang.String |
normalizeDescendentPath(java.lang.String path)
Normalizes the path parameter; enforces descendant relative path. |
static java.lang.String |
normalizeRelative(java.lang.String relativePath)
Normalize the path; enforces a relative path. |
static java.lang.String |
normalizeUnixStylePath(java.lang.String unixStylePath)
|
static boolean |
pathIsAbsolute(java.lang.String normalizedPath)
Test if a path is absolute. |
static java.lang.String |
slashify(java.lang.String filePath)
Convert \ separators into /'s |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.util.Comparator<java.lang.String> PATH_COMPARATOR
Constructor Detail |
---|
public PathUtils()
Method Detail |
---|
public static java.lang.String slashify(java.lang.String filePath)
filePath
- path to process, must not be null.
public static java.lang.String normalizeDescendentPath(java.lang.String path)
path
-
MalformedLocationException
- if normalized path begins with "..", as that would navigate
to the parentnormalizeRelative(String)
public static java.lang.String normalizeRelative(java.lang.String relativePath)
relativePath
-
MalformedLocationException
- if path is not relative (is an absolute path, a file URI, or
starts with a symbol)public static boolean pathIsAbsolute(java.lang.String normalizedPath)
Returns true if the path is an absolute one.
Eg. c:/wibble/fish, /wibble/fish, ${wibble}/fish
normalizedPath
-
public static java.lang.String normalize(java.lang.String path)
path
-
public static boolean isSymbol(java.lang.String s)
public static boolean containsSymbol(java.lang.String s)
public static java.lang.String getSymbol(java.lang.String s)
public static java.lang.String getParent(java.lang.String path)
Eg, for /wibble/fish/monkey, will return /wibble/fish
for /wibble, will return /
for / will return null
path
- the path to be interpreted.
public static java.lang.String getName(java.lang.String pathAndName)
Eg.
for /wibble/fish returns fish
for /wibble returns wibble
for / returns /
for sheep returns sheep
Names ending in / are illegal, and will fail. Callee's Responsibility.
pathAndName
-
public static java.lang.String getFirstPathComponent(java.lang.String path)
Eg, for /wibble/fish will return wibble
for /we/like/pie will return we
for /fish will return fish
for sheep will return sheep
for sheep/like/pies will return sheep
for sheep/shearing will return sheep
for / will return ""
path
- path to parse
public static java.lang.String getChildUnder(java.lang.String path, java.lang.String parentPath)
Eg, for /we/like/pies and /we/like will return pies
for /fish/are/friends/not/food and /fish/are/friends will return not
Will explode in fiery ball of death if parentPath is not a parent of path, you have been warned.
path
- full pathparentPath
- path segment that is a super path within path
public static boolean isUnixStylePathAbsolute(java.lang.String unixStylePath)
unixStylePath
- The path to check once normalized
true
if the path isn't trying to go up from the current locationpublic static boolean isNormalizedPathAbsolute(java.lang.String nPath)
public static java.lang.String checkAndNormalizeRootPath(java.lang.String path) throws java.lang.IllegalArgumentException
This method will do the following to the path:
path
by calling isUnixStylePathAbsolute(String)
path
if it is not presentpath
if it is presentpath
via a call to normalizeUnixStylePath(String)
path
is not equals to "/" or ""
path
- The path to normalize
java.lang.IllegalArgumentException
- If the path
is trying to leave the root element via .. notation or is "/" or ""
java.lang.NullPointerException
- If the path
is null
public static java.lang.String normalizeUnixStylePath(java.lang.String unixStylePath)
public static boolean checkCase(java.io.File file, java.lang.String pathToTest)
file
- The existing file to compare againstpathToTest
- The path to test if it is the same
true
if the case is the same in the file and the pathToTest
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |