Class PathUtil
- java.lang.Object
-
- org.jboss.shrinkwrap.impl.base.path.PathUtil
-
public final class PathUtil extends java.lang.ObjectPathUtil 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
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringEMPTYEmpty String
-
Constructor Summary
Constructors Modifier Constructor Description privatePathUtil()No instantiation
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringadjustToAbsoluteDirectoryContext(java.lang.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 java.lang.StringadjustToRelativeDirectoryContext(java.lang.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-isprivate static voidassertSpecified(java.lang.String path)Ensures the path is specifiedstatic java.lang.StringcomposeAbsoluteContext(java.lang.String base, java.lang.String context)Composes an absolute context from a given base and actual context relative to the base, returning the result.(package private) static ArchivePathgetParent(ArchivePath path)Obtains the parent of this Path, if exists, else null.private static booleanisFirstCharSlash(java.lang.String path)Returns whether or not the first character in the specified String is a slashprivate static booleanisLastCharSlash(java.lang.String path)Returns whether or not the last character in the specified String is a slashstatic java.lang.StringoptionallyAppendSlash(java.lang.String path)Adds, if not already present, the absolute slash following the specified path, and returns the adjusted result.static java.lang.StringoptionallyPrependSlash(java.lang.String path)Adds, if not already present, the absolute slash preceding the specified path, and returns the adjusted result.static java.lang.StringoptionallyRemoveFollowingSlash(java.lang.String path)Removes, if present, the absolute slash following the specified path, and returns the adjusted result.static java.lang.StringoptionallyRemovePrecedingSlash(java.lang.String path)Removes, if present, the absolute slash preceding the specified path, and returns the adjusted result.
-
-
-
Field Detail
-
EMPTY
public static final java.lang.String EMPTY
Empty String- See Also:
- Constant Field Values
-
-
Method Detail
-
composeAbsoluteContext
public static java.lang.String composeAbsoluteContext(java.lang.String base, java.lang.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 java.lang.String adjustToRelativeDirectoryContext(java.lang.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 java.lang.String adjustToAbsoluteDirectoryContext(java.lang.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 java.lang.String optionallyRemovePrecedingSlash(java.lang.String path)
Removes, if present, the absolute slash preceding the specified path, and returns the adjusted result.- Parameters:
path-- Returns:
-
optionallyRemoveFollowingSlash
public static java.lang.String optionallyRemoveFollowingSlash(java.lang.String path)
Removes, if present, the absolute slash following the specified path, and returns the adjusted result.- Parameters:
path-- Returns:
-
optionallyAppendSlash
public static java.lang.String optionallyAppendSlash(java.lang.String path)
Adds, if not already present, the absolute slash following the specified path, and returns the adjusted result.- Parameters:
path-- Returns:
-
optionallyPrependSlash
public static java.lang.String optionallyPrependSlash(java.lang.String path)
Adds, if not already present, the absolute slash preceding the specified path, and returns the adjusted result. If the argument is null, adjusts to an empty String before processing.- Parameters:
path-- Returns:
-
getParent
static ArchivePath getParent(ArchivePath path)
Obtains the parent of this Path, if exists, else null. For instance if the Path is "/my/path", the parent will be "/my". Each call will result in a new object reference, though subsequent calls upon the same Path will be equal by value.- Parameters:
path- The path whose parent context we should return- Returns:
-
isFirstCharSlash
private static boolean isFirstCharSlash(java.lang.String path)
Returns whether or not the first character in the specified String is a slash
-
isLastCharSlash
private static boolean isLastCharSlash(java.lang.String path)
Returns whether or not the last character in the specified String is a slash
-
assertSpecified
private static void assertSpecified(java.lang.String path)
Ensures the path is specified- Parameters:
path-
-
-