Class PathInfo

  • All Implemented Interfaces:
    RequestPathInfo

    public class PathInfo
    extends java.lang.Object
    implements RequestPathInfo
    Utility class for creating a sling RequestPathInfo by parsing a URL path. Note that this does not check for the existence of the resource and finding the longest-matching path as the default Sling resource resolution does, it only works by parsing the raw string.

    The parsing structure looks like this: /resource/path.selector.ext/suffix. The rules are (following the Sling convention):

    • extension is everything between the last dot in the URL and the next slash (or the end of the string)
    • suffix is everything after the extension (including the slash)
    • resource path is everything from the start up to the first dot after the last slash (excluding extension and suffix)
    • selectors are the dot-separated elements between the path and the extension
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getExtension()
      Returns the extension from the URL or null if the request URL does not contain an extension.
      java.lang.String getResourcePath()
      Return the "resource path" part of the URL, what comes before selectors, extension and suffix.
      java.lang.String[] getSelectors()
      Returns the selectors decoded from the request URL as an array of strings.
      java.lang.String getSelectorString()
      Returns the selectors decoded from the request URL as string.
      java.lang.String getSuffix()
      Returns the suffix part of the URL or null if the request URL does not contain a suffix.
      Resource getSuffixResource()
      Returns the resource addressed by the suffix or null if the request does not have a suffix or the suffix does not address an accessible resource.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PathInfo

        public PathInfo​(java.lang.String urlPath)
        Creates a RequestPathInfo by parsing the path part of a URL. This method does not support url path suffixes containing dots (".").
        Parameters:
        urlPath - the path part of a URL
      • PathInfo

        public PathInfo​(ResourceResolver resolver,
                        java.lang.String urlPath)
        Create a RequestPathInfo object using the given ResourceResolver and urlPath. The resolver is used to map the underlying resource and reliably disassemble the urlPath into its segments.
        Parameters:
        resolver - The resource resolver.
        urlPath - The url path.