Package io.wcm.handler.url.suffix
Class SuffixBuilder
java.lang.Object
io.wcm.handler.url.suffix.SuffixBuilder
Builds suffixes to be used in Sling URLs and that can be parsed with
SuffixParser.-
Constructor Summary
ConstructorsConstructorDescriptionCreate aSuffixBuilderwhich discards all existing suffix state when constructing a new suffix.SuffixBuilder(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull SuffixStateKeepingStrategy stateStrategy) Create aSuffixBuilderwith a customSuffixStateKeepingStrategy(see convenience methods likethatKeepsResourceParts(SlingHttpServletRequest)for often-used strategies)SuffixBuilder(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull Predicate<String> suffixPartFilter) Create aSuffixBuilderthat keeps only the suffix parts matched by the given filter when constructing a new suffix -
Method Summary
Modifier and TypeMethodDescription@NotNull Stringbuild()Build complete suffix.@NotNull SuffixBuilderpage(@NotNull com.day.cq.wcm.api.Page page, @NotNull com.day.cq.wcm.api.Page suffixBasePage) Puts a relative path of a page into the suffix.@NotNull SuffixBuilderpages(@NotNull List<com.day.cq.wcm.api.Page> pages, @NotNull com.day.cq.wcm.api.Page suffixBasePage) Constructs a suffix that contains multiple key-value pairs and address pages.@NotNull SuffixBuilderPuts a key-value pair into the suffix.@NotNull SuffixBuilderPuts a map of key-value pairs into the suffix.@NotNull SuffixBuilderresource(@NotNull org.apache.sling.api.resource.Resource resource, @NotNull org.apache.sling.api.resource.Resource suffixBaseResource) Puts a relative path of a resource into the suffix.@NotNull SuffixBuilderresources(@NotNull List<org.apache.sling.api.resource.Resource> resources, @NotNull org.apache.sling.api.resource.Resource baseResource) Constructs a suffix that contains multiple key-value pairs and address resources.static @NotNull SuffixBuilderstatic @NotNull SuffixBuilderthatDiscardsNamedParts(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull String @NotNull ... keysToDiscard) static @NotNull SuffixBuilderthatDiscardsResourceAndNamedParts(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull String @NotNull ... keysToDiscard) static @NotNull SuffixBuilderthatDiscardsResourceParts(@NotNull org.apache.sling.api.SlingHttpServletRequest request) static @NotNull SuffixBuilderthatDiscardsSpecificResourceAndNamedParts(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull String resourcePathToDiscard, @NotNull String @NotNull ... keysToDiscard) static @NotNull SuffixBuilderthatKeepsAllParts(@NotNull org.apache.sling.api.SlingHttpServletRequest request) static @NotNull SuffixBuilderthatKeepsNamedParts(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull String @NotNull ... keysToKeep) static @NotNull SuffixBuilderthatKeepsNamedPartsAndResources(@NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull String @NotNull ... keysToKeep) static @NotNull SuffixBuilderthatKeepsResourceParts(@NotNull org.apache.sling.api.SlingHttpServletRequest request)
-
Constructor Details
-
SuffixBuilder
public SuffixBuilder()Create aSuffixBuilderwhich discards all existing suffix state when constructing a new suffix. -
SuffixBuilder
public SuffixBuilder(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull SuffixStateKeepingStrategy stateStrategy) Create aSuffixBuilderwith a customSuffixStateKeepingStrategy(see convenience methods likethatKeepsResourceParts(SlingHttpServletRequest)for often-used strategies)- Parameters:
request- Sling requeststateStrategy- the strategy to use to decide which parts of the suffix of the current request needs to be kept in new constructed links
-
SuffixBuilder
public SuffixBuilder(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull Predicate<String> suffixPartFilter) Create aSuffixBuilderthat keeps only the suffix parts matched by the given filter when constructing a new suffix- Parameters:
request- Sling requestsuffixPartFilter- the filter that is called for each suffix part
-
-
Method Details
-
thatDiscardsAllSuffixState
- Returns:
- a
SuffixBuilderthat discards all existing suffix state when constructing a new suffix
-
thatKeepsResourceParts
@NotNull public static @NotNull SuffixBuilder thatKeepsResourceParts(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request) - Parameters:
request- Sling request- Returns:
- a
SuffixBuilderthat discards everything but the *resource* parts of the suffix
-
thatKeepsNamedParts
@NotNull public static @NotNull SuffixBuilder thatKeepsNamedParts(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull String @NotNull ... keysToKeep) - Parameters:
request- Sling requestkeysToKeep- Keys to keep- Returns:
- a
SuffixBuilderthat keeps only the named key/value-parts defined by pKeysToKeep
-
thatKeepsNamedPartsAndResources
@NotNull public static @NotNull SuffixBuilder thatKeepsNamedPartsAndResources(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull String @NotNull ... keysToKeep) - Parameters:
request- Sling requestkeysToKeep- Keys to keep- Returns:
- a
SuffixBuilderthat keeps the named key/value-parts defined by pKeysToKeep and all resource parts
-
thatKeepsAllParts
@NotNull public static @NotNull SuffixBuilder thatKeepsAllParts(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request) - Parameters:
request- Sling request- Returns:
- a
SuffixBuilderthat keeps all parts from the current request's suffix when constructing a new suffix
-
thatDiscardsResourceParts
@NotNull public static @NotNull SuffixBuilder thatDiscardsResourceParts(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request) - Parameters:
request- Sling request- Returns:
- a
SuffixBuilderthat will discard the resource parts, but keep all named key/value-parts
-
thatDiscardsNamedParts
@NotNull public static @NotNull SuffixBuilder thatDiscardsNamedParts(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull String @NotNull ... keysToDiscard) - Parameters:
request- Sling requestkeysToDiscard- the keys of the named parts to discard- Returns:
- a
SuffixBuilderthat will keep all parts except those named key/value-parts defined by pKeysToDiscard
-
thatDiscardsResourceAndNamedParts
@NotNull public static @NotNull SuffixBuilder thatDiscardsResourceAndNamedParts(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull String @NotNull ... keysToDiscard) - Parameters:
request- Sling requestkeysToDiscard- the keys of the named parts to discard- Returns:
SuffixBuilderthat will discard all resource parts and the named parts defined by pKeysToDiscard
-
thatDiscardsSpecificResourceAndNamedParts
@NotNull public static @NotNull SuffixBuilder thatDiscardsSpecificResourceAndNamedParts(@NotNull @NotNull org.apache.sling.api.SlingHttpServletRequest request, @NotNull @NotNull String resourcePathToDiscard, @NotNull @NotNull String @NotNull ... keysToDiscard) - Parameters:
request- Sling requestresourcePathToDiscard- relative path of the resource to discardkeysToDiscard- the keys of the named parts to discard- Returns:
SuffixBuilderthat will discard *one specific resource path* and the named parts defined by pKeysToDiscard
-
put
@NotNull public @NotNull SuffixBuilder put(@NotNull @NotNull String key, @NotNull @NotNull Object value) Puts a key-value pair into the suffix.- Parameters:
key- the keyvalue- the value- Returns:
- this
-
putAll
Puts a map of key-value pairs into the suffix.- Parameters:
map- map of key-value pairs- Returns:
- this
-
resource
@NotNull public @NotNull SuffixBuilder resource(@NotNull @NotNull org.apache.sling.api.resource.Resource resource, @NotNull @NotNull org.apache.sling.api.resource.Resource suffixBaseResource) Puts a relative path of a resource into the suffix.- Parameters:
resource- the resourcesuffixBaseResource- the base resource used to construct the relative path- Returns:
- this
-
resources
@NotNull public @NotNull SuffixBuilder resources(@NotNull @NotNull List<org.apache.sling.api.resource.Resource> resources, @NotNull @NotNull org.apache.sling.api.resource.Resource baseResource) Constructs a suffix that contains multiple key-value pairs and address resources. Depending on theSuffixStateKeepingStrategy, the suffix contains further parts from the current request that should be kept when constructing new links.- Parameters:
resources- resources to addressbaseResource- base resource to construct relative path- Returns:
- the suffix containing the map-content as encoded key value-pairs (and eventually other parts)
-
page
@NotNull public @NotNull SuffixBuilder page(@NotNull @NotNull com.day.cq.wcm.api.Page page, @NotNull @NotNull com.day.cq.wcm.api.Page suffixBasePage) Puts a relative path of a page into the suffix.- Parameters:
page- the pagesuffixBasePage- the base page used to construct the relative path- Returns:
- this
-
pages
@NotNull public @NotNull SuffixBuilder pages(@NotNull @NotNull List<com.day.cq.wcm.api.Page> pages, @NotNull @NotNull com.day.cq.wcm.api.Page suffixBasePage) Constructs a suffix that contains multiple key-value pairs and address pages. Depending on theSuffixStateKeepingStrategy, the suffix contains further parts from the current request that should be kept when constructing new links.- Parameters:
pages- pages to addresssuffixBasePage- the base page used to construct the relative path- Returns:
- this
-
build
Build complete suffix.- Returns:
- the suffix
-