Package org.apache.sling.api.request
Class RequestDispatcherOptions
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<java.lang.String,java.lang.String>
-
- org.apache.sling.api.request.RequestDispatcherOptions
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.util.Map<java.lang.String,java.lang.String>
public class RequestDispatcherOptions extends java.util.HashMap<java.lang.String,java.lang.String>RequestDispatcherOptionsare 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
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringOPT_ADD_SELECTORSWhen dispatching, add the value provided by this option to theRequestPathInfoselectors.static java.lang.StringOPT_FORCE_RESOURCE_TYPEWhen dispatching, use the value provided by this option as the resource type, instead of the one defined by theResource.static java.lang.StringOPT_PROTECT_HEADERS_ON_INCLUDEWhen dispatching with the include method, any headers set by the included resource are ignored.static java.lang.StringOPT_REPLACE_EXTENSIONWhen dispatching, replace theRequestPathInfoextension by the value provided by this optionstatic java.lang.StringOPT_REPLACE_SELECTORSWhen dispatching, replaceRequestPathInfoselectors by the value provided by this option.static java.lang.StringOPT_REPLACE_SUFFIXWhen dispatching, replace theRequestPathInfosuffix by the value provided by this option
-
Constructor Summary
Constructors Constructor Description RequestDispatcherOptions()Creates an instance with no options set.RequestDispatcherOptions(java.lang.String options)Creates a new instances setting options by parsing the givenoptionsstring as follows: If the string is empty ornullno 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 java.lang.StringgetAddSelectors()Returns theOPT_ADD_SELECTORSoption ornullif not set.java.lang.StringgetForceResourceType()Returns theOPT_FORCE_RESOURCE_TYPEoption ornullif not set.java.lang.StringgetReplaceExtension()Returns theOPT_REPLACE_EXTENSIONoption ornullif not set.java.lang.StringgetReplaceSelectors()Returns theOPT_REPLACE_SELECTORSoption ornullif not set.java.lang.StringgetReplaceSuffix()Returns theOPT_REPLACE_SUFFIXoption ornullif not set.booleanisProtectHeadersOnInclude()Returns theOPT_PROTECT_HEADERS_ON_INCLUDEoption orfalseif not set.voidsetAddSelectors(java.lang.String additionalSelectors)voidsetForceResourceType(java.lang.String resourceType)voidsetProtectHeadersOnInclude(boolean flag)Sets theOPT_PROTECT_HEADERS_ON_INCLUDEoption to the given value.voidsetReplaceExtension(java.lang.String replaceExtension)voidsetReplaceSelectors(java.lang.String replaceSelectors)voidsetReplaceSuffix(java.lang.String replaceSuffix)
-
-
-
Field Detail
-
OPT_FORCE_RESOURCE_TYPE
public static final java.lang.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 java.lang.String OPT_REPLACE_SELECTORS
When dispatching, replaceRequestPathInfoselectors 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 java.lang.String OPT_ADD_SELECTORS
When dispatching, add the value provided by this option to theRequestPathInfoselectors.- See Also:
- Constant Field Values
-
OPT_REPLACE_SUFFIX
public static final java.lang.String OPT_REPLACE_SUFFIX
When dispatching, replace theRequestPathInfosuffix by the value provided by this option- See Also:
- Constant Field Values
-
OPT_REPLACE_EXTENSION
public static final java.lang.String OPT_REPLACE_EXTENSION
When dispatching, replace theRequestPathInfoextension by the value provided by this option- Since:
- 2.5.0
- See Also:
- Constant Field Values
-
OPT_PROTECT_HEADERS_ON_INCLUDE
public static final java.lang.String OPT_PROTECT_HEADERS_ON_INCLUDE
When dispatching with the include method, any headers set by the included resource are ignored. This defaults to "false".- Since:
- 2.7.0
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RequestDispatcherOptions
public RequestDispatcherOptions()
Creates an instance with no options set.
-
RequestDispatcherOptions
public RequestDispatcherOptions(java.lang.String options)
Creates a new instances setting options by parsing the givenoptionsstring as follows:- If the string is empty or
nullno 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
RequestDispatcherOptionsobject is created with theOPT_FORCE_RESOURCE_TYPEfield 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
RequestDispatcherOptionsobject 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(java.lang.String resourceType)
- Parameters:
resourceType- the resource type
-
getForceResourceType
public java.lang.String getForceResourceType()
Returns theOPT_FORCE_RESOURCE_TYPEoption ornullif not set.- Returns:
- The resource type.
-
setAddSelectors
public void setAddSelectors(java.lang.String additionalSelectors)
- Parameters:
additionalSelectors- The add selectors
-
getAddSelectors
public java.lang.String getAddSelectors()
Returns theOPT_ADD_SELECTORSoption ornullif not set.- Returns:
- The add selectors.
-
setReplaceSelectors
public void setReplaceSelectors(java.lang.String replaceSelectors)
Sets theOPT_REPLACE_SELECTORSoption to the givenreplaceSelectorsif notnull. If this value contains an empty string, all original selectors are removed.- Parameters:
replaceSelectors- The replace selectors.
-
getReplaceSelectors
public java.lang.String getReplaceSelectors()
Returns theOPT_REPLACE_SELECTORSoption ornullif not set.- Returns:
- The replace selectors.
-
setReplaceSuffix
public void setReplaceSuffix(java.lang.String replaceSuffix)
- Parameters:
replaceSuffix- The replace suffix
-
getReplaceSuffix
public java.lang.String getReplaceSuffix()
Returns theOPT_REPLACE_SUFFIXoption ornullif not set.- Returns:
- The replace suffix
-
setReplaceExtension
public void setReplaceExtension(java.lang.String replaceExtension)
Sets theOPT_REPLACE_EXTENSIONoption to the givenreplaceExtensionif notnull. If this value contains an empty string, the original extension will be removed.- Parameters:
replaceExtension- The replace extension- Since:
- 2.5.0
-
getReplaceExtension
public java.lang.String getReplaceExtension()
Returns theOPT_REPLACE_EXTENSIONoption ornullif not set.- Returns:
- The replace extension
- Since:
- 2.5.0
-
setProtectHeadersOnInclude
public void setProtectHeadersOnInclude(boolean flag)
Sets theOPT_PROTECT_HEADERS_ON_INCLUDEoption to the given value.- Parameters:
flag- The value to set- Since:
- 2.7.0
-
isProtectHeadersOnInclude
public boolean isProtectHeadersOnInclude()
Returns theOPT_PROTECT_HEADERS_ON_INCLUDEoption orfalseif not set.- Returns:
- Are headers protected on include?
- Since:
- 2.7.0
-
-