Package org.apache.sling.api.request
Interface RequestPathInfo
-
- All Known Subinterfaces:
SlingUri
- All Known Implementing Classes:
PathInfo
,RequestPathInfoWrapper
@ProviderType public interface RequestPathInfo
Sling breaks the request URI into four parts: the path itself, optional dot-separated selectors and extension that follow it, and an optional path suffix.Decomposition of a Request URL
content path
- The longest substring of the request URI resolving to aResource
object such that the content path is either the complete request URI or the next character in the request URI after the content path is either a dot (.
) or a slash (/
).selectors
- If the first character in the request URI after the content path is a dot, the string after the dot upto but not including the last dot before the next slash character or the end of the request URI. If the content path spans the complete request URI or if a slash follows the content path in the request, then no selectors exist. If only one dot follows the content path before the end of the request URI or the next slash, no selectors exist. The selectors are available asa single string
and as anarray of strings
, which is the selector string splitted on dots.extension
- The string after the last dot after the content path in the request uri but before the end of the request uri or the next slash after the content path in the request uri. If the content path spans the complete request URI or a slash follows the content path in the request URI, the extension is empty.suffix path
- If the request URI contains a slash character after the content path and optional selectors and extension, the path starting with the slash up to the end of the request URI is the suffix path.
Examples:
URI decomposition URI Content Path Selectors Extension Suffix /a/b /a/b null null null /a/b.html /a/b null html null /a/b.s1.html /a/b s1 html null /a/b.s1.s2.html /a/b s1.s2 html null /a/b/c/d /a/b null null /c/d /a/b.html/c/d /a/b null html /c/d /a/b.s1.html/c/d /a/b s1 html /c/d /a/b.s1.s2.html/c/d /a/b s1.s2 html /c/d /a/b/c/d.s.txt /a/b null null /c/d.s.txt /a/b.html/c/d.s.txt /a/b null html /c/d.s.txt /a/b.s1.html/c/d.s.txt /a/b s1 html /c/d.s.txt /a/b.s1.s2.html/c/d.s.txt /a/b s1.s2 html /c/d.s.txt
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @Nullable String
getExtension()
Returns the extension from the URL ornull
if the request URL does not contain an extension.@NotNull String
getResourcePath()
Return the "resource path" part of the URL, what comes before selectors, extension and suffix.@NotNull String[]
getSelectors()
Returns the selectors decoded from the request URL as an array of strings.@Nullable String
getSelectorString()
Returns the selectors decoded from the request URL as string.@Nullable String
getSuffix()
Returns the suffix part of the URL ornull
if the request URL does not contain a suffix.@Nullable 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.
-
-
-
Method Detail
-
getResourcePath
@NotNull @NotNull String getResourcePath()
Return the "resource path" part of the URL, what comes before selectors, extension and suffix. This string is part of the request URL and need not be equal to theResource.getPath()
. Rather it is equal to theresolution path metadata property
of the resource.- Returns:
- The resource path
-
getExtension
@Nullable @Nullable String getExtension()
Returns the extension from the URL ornull
if the request URL does not contain an extension.Decomposition of the request URL is defined in the Decomposition of a Request URL above.
- Returns:
- The extension from the request URL.
-
getSelectorString
@Nullable @Nullable String getSelectorString()
Returns the selectors decoded from the request URL as string. Returnsnull
if the request has no selectors.Decomposition of the request URL is defined in the Decomposition of a Request URL above.
- Returns:
- The selector string or
null
- See Also:
getSelectors()
-
getSelectors
@NotNull @NotNull String[] getSelectors()
Returns the selectors decoded from the request URL as an array of strings. This array is derived from theselector 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.
- Returns:
- An array of selectors
- See Also:
getSelectorString()
-
getSuffix
@Nullable @Nullable String getSuffix()
Returns the suffix part of the URL ornull
if the request URL does not contain a suffix.Decomposition of the request URL is defined in the Decomposition of a Request URL above.
- Returns:
- The suffix part of the request URL.
-
getSuffixResource
@Nullable @Nullable 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.The suffix is expected to be the absolute path to the resource suitable as an argument to the
ResourceResolver.getResource(String)
method.- Returns:
- The suffix resource or
null
. - Since:
- 2.3 (Sling API Bundle 2.3.2)
-
-