Package org.forgerock.http.util
Class Paths
java.lang.Object
org.forgerock.http.util.Paths
Utilities for manipulating paths.
-
Method Summary
Modifier and TypeMethodDescriptionstatic String
addLeadingSlash
(String rawPath) Add leading slash (if there is not already), returns the same value otherwise.static String
addTrailingSlash
(String rawPath) Adds a trailing slash at the end of the given raw path or returns the same value if an end slash is present.getPathElements
(String rawPath) Converts a path into a list of URL-decoded path elements.static String
Joins a list of URL-decoded path elements into a url-encoded path.static String
removeLeadingSlash
(String rawPath) Removes the leading slash, if present, from the resource name.static String
removeTrailingSlash
(String rawPath) Removes trailing slash (if there is any), returns the same value otherwise.static String
Returns the URL path decoding of the provided object's string representation.static String
Returns the URL path encoding of the provided object's string representation.
-
Method Details
-
urlDecode
Returns the URL path decoding of the provided object's string representation.- Parameters:
value
- The value to be URL path decoded.- Returns:
- The URL path decoding of the provided object's string representation.
-
urlEncode
Returns the URL path encoding of the provided object's string representation.- Parameters:
value
- The value to be URL path encoded.- Returns:
- The URL path encoding of the provided object's string representation.
-
getPathElements
Converts a path into a list of URL-decoded path elements. If the leading path element is empty it is dropped, meaning thatnull
,""
and"/"
will all return an empty list, and"//"
will return a list with two elements, both empty strings, as all intermediate and trailing empty paths are retained.- Parameters:
rawPath
- The raw, URL-encoded path string.- Returns:
- An immutable list of the path elements.
-
joinPath
Joins a list of URL-decoded path elements into a url-encoded path.- Parameters:
elements
- The list of (URL-decoded) elements.- Returns:
- The raw path.
-
addTrailingSlash
Adds a trailing slash at the end of the given raw path or returns the same value if an end slash is present.- Parameters:
rawPath
- The raw, URL-encoded path string, notnull
.- Returns:
- The raw path ended with a slash (if there was none), otherwise returns the same raw path.
-
removeTrailingSlash
Removes trailing slash (if there is any), returns the same value otherwise. Note that this method does not recursively clean the value from all its trailing slashes (/openam// will be transformed to /openam/, not /openam).- Parameters:
rawPath
- The raw path with (possibly) trailing slash, notnull
.- Returns:
- The raw path without the trailing slash (if there was one), same path otherwise.
-
addLeadingSlash
Add leading slash (if there is not already), returns the same value otherwise.- Parameters:
rawPath
- The raw, URL-encoded path string, notnull
.- Returns:
- The raw path with a leading slash (if there was none), same path otherwise.
-
removeLeadingSlash
Removes the leading slash, if present, from the resource name.- Parameters:
rawPath
- The raw, URL-encoded path string, notnull
.- Returns:
- The resource name without a leading slash.
- Throws:
NullPointerException
- If the specified resourceName isnull
.
-