Class PathUtil
- java.lang.Object
-
- org.jboss.shrinkwrap.impl.base.path.PathUtil
-
public final class PathUtil extends Object
PathUtil A series of internal-only path utilities for adjusting relative forms, removing double-slashes, etc. Used in correcting inputs in the creation of new Paths- Author:
- Aslak Knutsen, ALR
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
adjustToAbsoluteDirectoryContext(String path)
Adjusts the specified path to absolute form: 1) Adds, if not present, a preceding slash 2) Adds, if not present, a trailing slash Null arguments are returned as-isstatic String
adjustToRelativeDirectoryContext(String path)
Adjusts the specified path to relative form: 1) Removes, if present, a preceding slash 2) Adds, if not present, a trailing slash Null arguments are returned as-isstatic String
composeAbsoluteContext(String base, String context)
Composes an absolute context from a given base and actual context relative to the base, returning the result.static String
optionallyAppendSlash(String path)
Adds, if not already present, the absolute slash following the specified path, and returns the adjusted result.static String
optionallyPrependSlash(String path)
Adds, if not already present, the absolute slash preceding the specified path, and returns the adjusted result.static String
optionallyRemoveFollowingSlash(String path)
Removes, if present, the absolute slash following the specified path, and returns the adjusted result.static String
optionallyRemovePrecedingSlash(String path)
Removes, if present, the absolute slash preceding the specified path, and returns the adjusted result.
-
-
-
Field Detail
-
EMPTY
public static final String EMPTY
Empty String- See Also:
- Constant Field Values
-
-
Method Detail
-
composeAbsoluteContext
public static String composeAbsoluteContext(String base, String context)
Composes an absolute context from a given base and actual context relative to the base, returning the result. ie. base of "base" and context of "context" will result in form "/base/context".
-
adjustToRelativeDirectoryContext
public static String adjustToRelativeDirectoryContext(String path)
Adjusts the specified path to relative form: 1) Removes, if present, a preceding slash 2) Adds, if not present, a trailing slash Null arguments are returned as-is- Parameters:
path
-
-
adjustToAbsoluteDirectoryContext
public static String adjustToAbsoluteDirectoryContext(String path)
Adjusts the specified path to absolute form: 1) Adds, if not present, a preceding slash 2) Adds, if not present, a trailing slash Null arguments are returned as-is- Parameters:
path
-
-
optionallyRemovePrecedingSlash
public static String optionallyRemovePrecedingSlash(String path)
Removes, if present, the absolute slash preceding the specified path, and returns the adjusted result.- Parameters:
path
-- Returns:
-
optionallyRemoveFollowingSlash
public static String optionallyRemoveFollowingSlash(String path)
Removes, if present, the absolute slash following the specified path, and returns the adjusted result.- Parameters:
path
-- Returns:
-
optionallyAppendSlash
public static String optionallyAppendSlash(String path)
Adds, if not already present, the absolute slash following the specified path, and returns the adjusted result.- Parameters:
path
-- Returns:
-
-