Class PathInfoUtil


  • @ProviderType
    public final class PathInfoUtil
    extends Object
    Util class to help with parsing URIs and PathInfos.
    • Method Detail

      • getQueryParam

        public static String getQueryParam​(org.apache.sling.api.SlingHttpServletRequest request,
                                           String key)
        Get a named Query Parameter from the Request.
        Parameters:
        request -
        key -
        Returns:
      • getQueryParam

        public static String getQueryParam​(org.apache.sling.api.SlingHttpServletRequest request,
                                           String key,
                                           String dfault)
        Get a named Query Parameter from the Request.
        Parameters:
        request -
        key -
        dfault - Value to return if Query Parameter value is blank
        Returns:
      • getSelector

        public static String getSelector​(org.apache.sling.api.SlingHttpServletRequest request,
                                         int index)
        Gets the selector at the supplied index.

        Given: /content/page.selA.selB.html
        getSelector(request, 0) // --> "selA"
        getSelector(request, 1) // --> "selB"

        Parameters:
        request -
        index -
        Returns:
        null if selector cannot be found at the specified index
      • getSelector

        public static String getSelector​(org.apache.sling.api.SlingHttpServletRequest request,
                                         int index,
                                         String defaultValue)

        Gets the selector at the supplied index, using a default if there is no selector at that index.

        Given: /content/page.selA.html
        getSelector(request, 0, "default") // --> "selA"
        getSelector(request, 1, "default2") // --> "default2"

        Parameters:
        request - the request
        index - the index
        defaultValue - the default value
        Returns:
        the selector value or the default
      • getSuffixSegments

        public static String[] getSuffixSegments​(org.apache.sling.api.SlingHttpServletRequest request)
        Gets the suffixes as an array; each segment is the text between the /'s. /segment-0/segment-1/segment-2
        Parameters:
        request -
        Returns:
        and array of the suffix segments or empty array
      • getSuffixSegment

        public static String getSuffixSegment​(org.apache.sling.api.SlingHttpServletRequest request,
                                              int index)

        Gets the suffix segment at the supplied index.

        Given: /content/page.html/suffixA/suffixB
        getSuffixSegment(request, 0) // --> "suffixA"
        getSuffixSegment(request, 1) // --> "suffixB"

        Parameters:
        request -
        index -
        Returns:
        null if suffix segment cannot be found at the specified index
      • getSuffix

        public static String getSuffix​(org.apache.sling.api.SlingHttpServletRequest request)
        Get the entire suffix.
        Parameters:
        request -
        Returns:
        Returns null if Request's pathInfo or Suffix is null
      • getFirstSuffixSegment

        public static String getFirstSuffixSegment​(org.apache.sling.api.SlingHttpServletRequest request)
        Get the first suffix segment.
        Parameters:
        request -
        Returns:
        the String in the first suffix segment or null if no suffix
      • getLastSuffixSegment

        public static String getLastSuffixSegment​(org.apache.sling.api.SlingHttpServletRequest request)
        Gets the last suffix segment.
        Parameters:
        request -
        Returns:
        the String in the last suffix segment or null if no suffix