public class PathInfo extends java.lang.Object implements RequestPathInfo
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):
Constructor and Description |
---|
PathInfo(ResourceResolver resolver,
java.lang.String urlPath)
|
PathInfo(java.lang.String urlPath)
Creates a
RequestPathInfo by parsing the path part of a URL. |
Modifier and Type | Method and 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.
|
public PathInfo(java.lang.String urlPath)
RequestPathInfo
by parsing the path part of a URL. This method does not support url path
suffixes containing dots (".").urlPath
- the path part of a URLpublic PathInfo(ResourceResolver resolver, java.lang.String urlPath)
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.resolver
- The resource resolver.urlPath
- The url path.public java.lang.String getResourcePath()
RequestPathInfo
Resource.getPath()
.
Rather it is equal to the
resolution path metadata property
of the resource.getResourcePath
in interface RequestPathInfo
public java.lang.String getSelectorString()
RequestPathInfo
null
if the request has no selectors.
Decomposition of the request URL is defined in the Decomposition of a Request URL above.
getSelectorString
in interface RequestPathInfo
null
RequestPathInfo.getSelectors()
public java.lang.String[] getSelectors()
RequestPathInfo
selector string
by splitting the string on
dots. Returns an empty array if the request has no selectors.
Decomposition of the request URL is defined in the Decomposition of a Request URL above.
getSelectors
in interface RequestPathInfo
RequestPathInfo.getSelectorString()
public java.lang.String getExtension()
RequestPathInfo
null
if the request
URL does not contain an extension.
Decomposition of the request URL is defined in the Decomposition of a Request URL above.
getExtension
in interface RequestPathInfo
public java.lang.String getSuffix()
RequestPathInfo
null
if the request
URL does not contain a suffix.
Decomposition of the request URL is defined in the Decomposition of a Request URL above.
getSuffix
in interface RequestPathInfo
public Resource getSuffixResource()
RequestPathInfo
The suffix is expected to be the absolute path to the resource suitable
as an argument to the
ResourceResolver.getResource(String)
method.
getSuffixResource
in interface RequestPathInfo
null
.Copyright © 2010 - 2020 Adobe. All Rights Reserved