Package io.wcm.handler.url.suffix
Class SuffixParser
java.lang.Object
io.wcm.handler.url.suffix.SuffixParser
Parses suffixes from Sling URLs build with
SuffixBuilder.-
Constructor Summary
ConstructorsConstructorDescriptionSuffixParser(@NotNull org.apache.sling.api.SlingHttpServletRequest request) Create aSuffixParserwith the defaultSuffixStateKeepingStrategy(which discards all existing suffix state when constructing a new suffix) -
Method Summary
Modifier and TypeMethodDescription<T> TExtract the value of a named suffix part from this request's suffix<T> TExtract the value of a named suffix part from this request's suffix@Nullable com.day.cq.wcm.api.PagegetPage()Parse the suffix as page paths and return the first page that exists with a page path relative to the current page path.@Nullable com.day.cq.wcm.api.PagegetPage(@NotNull com.day.cq.wcm.api.Page basePage) Parse the suffix as page paths and return the first page that exists.@Nullable com.day.cq.wcm.api.PageParse the suffix as page paths, return the first page from the suffix (relativ to the current page) that matches the given filter.@Nullable com.day.cq.wcm.api.PagegetPage(@Nullable Predicate<com.day.cq.wcm.api.Page> filter, @Nullable com.day.cq.wcm.api.Page basePage) Get the first item returned bygetPages(Predicate, Page)or null if list is empty@NotNull List<com.day.cq.wcm.api.Page> getPages()Get the pages selected in the suffix of the URL with page paths relative to the current page path.@NotNull List<com.day.cq.wcm.api.Page> Get the pages selected in the suffix of the URL with page paths relative to the current page path.@NotNull List<com.day.cq.wcm.api.Page> getPages(@Nullable Predicate<com.day.cq.wcm.api.Page> filter, @Nullable com.day.cq.wcm.api.Page basePage) Get the pages selected in the suffix of the URL@Nullable org.apache.sling.api.resource.ResourceGet a resource within the current page by interpreting the suffix as a JCR path relative to this page's jcr:content node@Nullable org.apache.sling.api.resource.ResourcegetResource(@NotNull Predicate<org.apache.sling.api.resource.Resource> filter) Parse the suffix as resource paths, return the first resource from the suffix (relativ to the current page's content) that matches the given filter.@Nullable org.apache.sling.api.resource.ResourcegetResource(@Nullable Predicate<org.apache.sling.api.resource.Resource> filter, @Nullable org.apache.sling.api.resource.Resource baseResource) Get the first item returned bygetResources(Predicate, Resource)or null if list is empty@Nullable org.apache.sling.api.resource.ResourcegetResource(@NotNull org.apache.sling.api.resource.Resource baseResource) Parse the suffix as resource paths and return the first resource that exists@NotNull List<org.apache.sling.api.resource.Resource> Get the resources within the current page selected in the suffix of the URL@NotNull List<org.apache.sling.api.resource.Resource> getResources(@NotNull Predicate<org.apache.sling.api.resource.Resource> filter) Get the resources selected in the suffix of the URL@NotNull List<org.apache.sling.api.resource.Resource> getResources(@Nullable Predicate<org.apache.sling.api.resource.Resource> filter, @Nullable org.apache.sling.api.resource.Resource baseResource) Get the resources selected in the suffix of the URL@NotNull List<org.apache.sling.api.resource.Resource> getResources(@NotNull org.apache.sling.api.resource.Resource baseResource) Get the resources selected in the suffix of the URL
-
Constructor Details
-
SuffixParser
public SuffixParser(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request) Create aSuffixParserwith the defaultSuffixStateKeepingStrategy(which discards all existing suffix state when constructing a new suffix)- Parameters:
request- Sling request
-
-
Method Details
-
get
Extract the value of a named suffix part from this request's suffix- Type Parameters:
T- Parameter type.- Parameters:
key- key of the suffix partclazz- Type expected for return value. Only String, Boolean, Integer, Long are supported.- Returns:
- the value of that named parameter (or the default value if not used)
-
get
Extract the value of a named suffix part from this request's suffix- Type Parameters:
T- Parameter type.- Parameters:
key- key of the suffix partdefaultValue- the default value to return if suffix part not set. Only String, Boolean, Integer, Long are supported.- Returns:
- the value of that named parameter (or the default value if not used)
-
getResource
@Nullable public @Nullable org.apache.sling.api.resource.Resource getResource()Get a resource within the current page by interpreting the suffix as a JCR path relative to this page's jcr:content node- Returns:
- the Resource or null if no such resource exists
-
getResource
@Nullable public @Nullable org.apache.sling.api.resource.Resource getResource(@NotNull @NotNull org.apache.sling.api.resource.Resource baseResource) Parse the suffix as resource paths and return the first resource that exists- Parameters:
baseResource- the suffix path is relative to this resource path (null for current page's jcr:content node)- Returns:
- the resource or null if no such resource was selected by suffix
-
getResource
@Nullable public @Nullable org.apache.sling.api.resource.Resource getResource(@NotNull @NotNull Predicate<org.apache.sling.api.resource.Resource> filter) Parse the suffix as resource paths, return the first resource from the suffix (relativ to the current page's content) that matches the given filter.- Parameters:
filter- a filter that selects only the resource you're interested in.- Returns:
- the resource or null if no such resource was selected by suffix
-
getResource
@Nullable public @Nullable org.apache.sling.api.resource.Resource getResource(@Nullable @Nullable Predicate<org.apache.sling.api.resource.Resource> filter, @Nullable @Nullable org.apache.sling.api.resource.Resource baseResource) Get the first item returned bygetResources(Predicate, Resource)or null if list is empty- Parameters:
filter- the resource filterbaseResource- the suffix path is relative to this resource path (null for current page's jcr:content node)- Returns:
- the first
Resourceor null
-
getResources
Get the resources within the current page selected in the suffix of the URL- Returns:
- a list containing the Resources
-
getResources
@NotNull public @NotNull List<org.apache.sling.api.resource.Resource> getResources(@NotNull @NotNull org.apache.sling.api.resource.Resource baseResource) Get the resources selected in the suffix of the URL- Parameters:
baseResource- the suffix path is relative to this resource path (null for current page's jcr:content node)- Returns:
- a list containing the Resources
-
getResources
@NotNull public @NotNull List<org.apache.sling.api.resource.Resource> getResources(@NotNull @NotNull Predicate<org.apache.sling.api.resource.Resource> filter) Get the resources selected in the suffix of the URL- Parameters:
filter- optional filter to select only specific resources- Returns:
- a list containing the Resources
-
getResources
@NotNull public @NotNull List<org.apache.sling.api.resource.Resource> getResources(@Nullable @Nullable Predicate<org.apache.sling.api.resource.Resource> filter, @Nullable @Nullable org.apache.sling.api.resource.Resource baseResource) Get the resources selected in the suffix of the URL- Parameters:
filter- optional filter to select only specific resourcesbaseResource- the suffix path is relative to this resource path (null for current page's jcr:content node)- Returns:
- a list containing the Resources
-
getPage
@Nullable public @Nullable com.day.cq.wcm.api.Page getPage()Parse the suffix as page paths and return the first page that exists with a page path relative to the current page path.- Returns:
- the page or null if no such page was selected by suffix
-
getPage
@Nullable public @Nullable com.day.cq.wcm.api.Page getPage(@NotNull @NotNull com.day.cq.wcm.api.Page basePage) Parse the suffix as page paths and return the first page that exists.- Parameters:
basePage- the suffix page is relative to this page path (null for current page)- Returns:
- the page or null if no such page was selected by suffix
-
getPage
@Nullable public @Nullable com.day.cq.wcm.api.Page getPage(@NotNull @NotNull Predicate<com.day.cq.wcm.api.Page> filter) Parse the suffix as page paths, return the first page from the suffix (relativ to the current page) that matches the given filter.- Parameters:
filter- a filter that selects only the page you're interested in.- Returns:
- the page or null if no such page was selected by suffix
-
getPage
@Nullable public @Nullable com.day.cq.wcm.api.Page getPage(@Nullable @Nullable Predicate<com.day.cq.wcm.api.Page> filter, @Nullable @Nullable com.day.cq.wcm.api.Page basePage) Get the first item returned bygetPages(Predicate, Page)or null if list is empty- Parameters:
filter- the resource filterbasePage- the suffix path is relative to this page path (null for current page)- Returns:
- the first
Pageor null
-
getPages
Get the pages selected in the suffix of the URL with page paths relative to the current page path.- Returns:
- a list containing the Pages
-
getPages
@NotNull public @NotNull List<com.day.cq.wcm.api.Page> getPages(@NotNull @NotNull Predicate<com.day.cq.wcm.api.Page> filter) Get the pages selected in the suffix of the URL with page paths relative to the current page path.- Parameters:
filter- optional filter to select only specific pages- Returns:
- a list containing the Pages
-
getPages
@NotNull public @NotNull List<com.day.cq.wcm.api.Page> getPages(@Nullable @Nullable Predicate<com.day.cq.wcm.api.Page> filter, @Nullable @Nullable com.day.cq.wcm.api.Page basePage) Get the pages selected in the suffix of the URL- Parameters:
filter- optional filter to select only specific pagesbasePage- the suffix path is relative to this page path (null for current page)- Returns:
- a list containing the Pages
-