Package org.apache.sling.api.request
Class RequestDispatcherOptions
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<String,String>
-
- org.apache.sling.api.request.RequestDispatcherOptions
-
- All Implemented Interfaces:
Serializable
,Cloneable
,Map<String,String>
public class RequestDispatcherOptions extends HashMap<String,String>
RequestDispatcherOptions
are used in theSlingHttpServletRequest.getRequestDispatcher(org.apache.sling.api.resource.Resource, RequestDispatcherOptions)
method, to give more control on some aspects of the include/forward mechanism. Typical use cases include:- Forcing a resource type, to render a Resource in a specific way, like for example render myself in a suitable way for a navigation box.
- Adding selectors when including a Resource, like for example add a "teaser" selector to the request that I'm including here.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Field Summary
Fields Modifier and Type Field Description static String
OPT_ADD_SELECTORS
When dispatching, add the value provided by this option to theRequestPathInfo
selectors.static String
OPT_FORCE_RESOURCE_TYPE
When dispatching, use the value provided by this option as the resource type, instead of the one defined by theResource
.static String
OPT_REPLACE_SELECTORS
When dispatching, replaceRequestPathInfo
selectors by the value provided by this option.static String
OPT_REPLACE_SUFFIX
When dispatching, replace theRequestPathInfo
suffix by the value provided by this option
-
Constructor Summary
Constructors Constructor Description RequestDispatcherOptions()
Creates an instance with no options set.RequestDispatcherOptions(String options)
Creates a new instances setting options by parsing the givenoptions
string as follows: If the string is empty ornull
no options are set. If the string neither contains a comma nor an equals sign, the string is assumed to be a resource type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getAddSelectors()
Returns theOPT_ADD_SELECTORS
option ornull
if not set.String
getForceResourceType()
Returns theOPT_FORCE_RESOURCE_TYPE
option ornull
if not set.String
getReplaceSelectors()
Returns theOPT_REPLACE_SELECTORS
option ornull
if not set.String
getReplaceSuffix()
Returns theOPT_REPLACE_SUFFIX
option ornull
if not set.void
setAddSelectors(String additionalSelectors)
void
setForceResourceType(String resourceType)
void
setReplaceSelectors(String replaceSelectors)
void
setReplaceSuffix(String replaceSuffix)
-
Methods inherited from class java.util.HashMap
clear, clone, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from class java.util.AbstractMap
equals, hashCode, toString
-
-
-
-
Field Detail
-
OPT_FORCE_RESOURCE_TYPE
public static final String OPT_FORCE_RESOURCE_TYPE
When dispatching, use the value provided by this option as the resource type, instead of the one defined by theResource
.- See Also:
- Constant Field Values
-
OPT_REPLACE_SELECTORS
public static final String OPT_REPLACE_SELECTORS
When dispatching, replaceRequestPathInfo
selectors by the value provided by this option. If this value contains an empty string, all original selectors are removed.- See Also:
- Constant Field Values
-
OPT_ADD_SELECTORS
public static final String OPT_ADD_SELECTORS
When dispatching, add the value provided by this option to theRequestPathInfo
selectors.- See Also:
- Constant Field Values
-
OPT_REPLACE_SUFFIX
public static final String OPT_REPLACE_SUFFIX
When dispatching, replace theRequestPathInfo
suffix by the value provided by this option- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RequestDispatcherOptions
public RequestDispatcherOptions()
Creates an instance with no options set.
-
RequestDispatcherOptions
public RequestDispatcherOptions(String options)
Creates a new instances setting options by parsing the givenoptions
string as follows:- If the string is empty or
null
no options are set. - If the string neither contains a comma nor an equals sign, the
string is assumed to be a resource type. Hence a
RequestDispatcherOptions
object is created with theOPT_FORCE_RESOURCE_TYPE
field set to the string. - Otherwise the string is assumed to be a comma separated list of name
value pairs where the equals sign is used to separate the name from its
value. Hence a
RequestDispatcherOptions
object is created from the name value pair list.
- Parameters:
options
- The options to set.
- If the string is empty or
-
-
Method Detail
-
setForceResourceType
public void setForceResourceType(String resourceType)
- Parameters:
resourceType
- the resource type
-
getForceResourceType
public String getForceResourceType()
Returns theOPT_FORCE_RESOURCE_TYPE
option ornull
if not set.- Returns:
- The resource type.
-
setAddSelectors
public void setAddSelectors(String additionalSelectors)
- Parameters:
additionalSelectors
- The add selectors
-
getAddSelectors
public String getAddSelectors()
Returns theOPT_ADD_SELECTORS
option ornull
if not set.- Returns:
- The add selectors.
-
setReplaceSelectors
public void setReplaceSelectors(String replaceSelectors)
Sets theOPT_REPLACE_SELECTORS
option to the givenreplaceSelectors
if notnull
. If this value contains an empty string, all original selectors are removed.- Parameters:
replaceSelectors
- The replace selectors.
-
getReplaceSelectors
public String getReplaceSelectors()
Returns theOPT_REPLACE_SELECTORS
option ornull
if not set.- Returns:
- The replace selectors.
-
setReplaceSuffix
public void setReplaceSuffix(String replaceSuffix)
- Parameters:
replaceSuffix
- The replace suffix
-
getReplaceSuffix
public String getReplaceSuffix()
Returns theOPT_REPLACE_SUFFIX
option ornull
if not set.- Returns:
- The replace suffix
-
-