Class PathUtil
java.lang.Object
org.jboss.shrinkwrap.impl.base.path.PathUtil
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
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
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
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 void
assertSpecified
(String path) Ensures the path is specifiedstatic String
composeAbsoluteContext
(String base, String context) Composes an absolute context from a given base and actual context relative to the base, returning the result.(package private) static ArchivePath
getParent
(ArchivePath path) Obtains the parent of this Path, if exists, else null.private static boolean
isFirstCharSlash
(String path) Returns whether or not the first character in the specified String is a slashprivate static boolean
isLastCharSlash
(String path) Returns whether or not the last character in the specified String is a slashstatic 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
Removes, if present, the absolute slash following the specified path, and returns the adjusted result.static String
Removes, if present, the absolute slash preceding the specified path, and returns the adjusted result.
-
Field Details
-
EMPTY
Empty String- See Also:
-
-
Constructor Details
-
PathUtil
private PathUtil()No instantiation
-
-
Method Details
-
composeAbsoluteContext
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
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
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
Removes, if present, the absolute slash preceding the specified path, and returns the adjusted result.- Parameters:
path
-- Returns:
-
optionallyRemoveFollowingSlash
Removes, if present, the absolute slash following the specified path, and returns the adjusted result.- Parameters:
path
-- Returns:
-
optionallyAppendSlash
Adds, if not already present, the absolute slash following the specified path, and returns the adjusted result.- Parameters:
path
-- Returns:
-
optionallyPrependSlash
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
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
Returns whether or not the first character in the specified String is a slash -
isLastCharSlash
Returns whether or not the last character in the specified String is a slash -
assertSpecified
Ensures the path is specified- Parameters:
path
-
-