Class Paths

java.lang.Object
org.forgerock.http.util.Paths

public final class Paths extends Object
Utilities for manipulating paths.
  • Method Details

    • urlDecode

      public static String urlDecode(Object value)
      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

      public static String urlEncode(Object value)
      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

      public static List<String> getPathElements(String rawPath)
      Converts a path into a list of URL-decoded path elements. If the leading path element is empty it is dropped, meaning that null, "" 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

      public static String joinPath(List<String> elements)
      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

      public 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.
      Parameters:
      rawPath - The raw, URL-encoded path string, not null.
      Returns:
      The raw path ended with a slash (if there was none), otherwise returns the same raw path.
    • removeTrailingSlash

      public static String removeTrailingSlash(String rawPath)
      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, not null.
      Returns:
      The raw path without the trailing slash (if there was one), same path otherwise.
    • addLeadingSlash

      public static String addLeadingSlash(String rawPath)
      Add leading slash (if there is not already), returns the same value otherwise.
      Parameters:
      rawPath - The raw, URL-encoded path string, not null.
      Returns:
      The raw path with a leading slash (if there was none), same path otherwise.
    • removeLeadingSlash

      public static String removeLeadingSlash(String rawPath)
      Removes the leading slash, if present, from the resource name.
      Parameters:
      rawPath - The raw, URL-encoded path string, not null.
      Returns:
      The resource name without a leading slash.
      Throws:
      NullPointerException - If the specified resourceName is null.