org.apache.sling.api.wrappers
Class SlingHttpServletRequestWrapper

java.lang.Object
  extended by javax.servlet.ServletRequestWrapper
      extended by javax.servlet.http.HttpServletRequestWrapper
          extended by org.apache.sling.api.wrappers.SlingHttpServletRequestWrapper
All Implemented Interfaces:
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest, SlingHttpServletRequest

public class SlingHttpServletRequestWrapper
extends javax.servlet.http.HttpServletRequestWrapper
implements SlingHttpServletRequest

The SlingHttpServletRequestWrapper class is a default wrapper class around a SlingHttpServletRequest which may be extended to amend the functionality of the original request object.


Field Summary
 
Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH
 
Constructor Summary
SlingHttpServletRequestWrapper(SlingHttpServletRequest wrappedRequest)
          Create a wrapper for the supplied wrappedRequest
 
Method Summary
 javax.servlet.http.Cookie getCookie(java.lang.String name)
          Returns the named cookie from the HTTP request or null if no such cookie exists in the request.
 javax.servlet.RequestDispatcher getRequestDispatcher(Resource resource)
          Same as SlingHttpServletRequest.getRequestDispatcher(Resource,RequestDispatcherOptions) but using empty options.
 javax.servlet.RequestDispatcher getRequestDispatcher(Resource resource, RequestDispatcherOptions options)
          Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given resource.
 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path, RequestDispatcherOptions options)
          Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path.
 RequestParameter getRequestParameter(java.lang.String name)
          Returns the value of a request parameter as a RequestParameter, or null if the parameter does not exist.
 RequestParameterMap getRequestParameterMap()
          Returns a Map of the parameters of this request.
 RequestParameter[] getRequestParameters(java.lang.String name)
          Returns an array of RequestParameter objects containing all of the values the given request parameter has, or null if the parameter does not exist.
 RequestPathInfo getRequestPathInfo()
          Returns the RequestPathInfo pertaining to this request.
 RequestProgressTracker getRequestProgressTracker()
          Returns the RequestProgressTracker of this request.
 Resource getResource()
          Returns the Resource object on whose behalf the servlet acts.
 java.util.ResourceBundle getResourceBundle(java.util.Locale locale)
          Returns the resource bundle for the given locale.
 java.util.ResourceBundle getResourceBundle(java.lang.String baseName, java.util.Locale locale)
          Returns the resource bundle of the given base name for the given locale.
 ResourceResolver getResourceResolver()
          Returns the ResourceResolver which resolved the resource of this request.
 java.lang.String getResponseContentType()
          Returns the framework preferred content type for the response.
 java.util.Enumeration<java.lang.String> getResponseContentTypes()
          Gets a list of content types which the framework accepts for the response.
 SlingHttpServletRequest getSlingRequest()
          Return the original SlingHttpServletRequest object wrapped by this.
 
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
 
Methods inherited from class javax.servlet.ServletRequestWrapper
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.servlet.http.HttpServletRequest
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromUrl, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isUserInRole
 
Methods inherited from interface javax.servlet.ServletRequest
getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
 

Constructor Detail

SlingHttpServletRequestWrapper

public SlingHttpServletRequestWrapper(SlingHttpServletRequest wrappedRequest)
Create a wrapper for the supplied wrappedRequest

Method Detail

getSlingRequest

public SlingHttpServletRequest getSlingRequest()
Return the original SlingHttpServletRequest object wrapped by this.


getCookie

public javax.servlet.http.Cookie getCookie(java.lang.String name)
Description copied from interface: SlingHttpServletRequest
Returns the named cookie from the HTTP request or null if no such cookie exists in the request.

Specified by:
getCookie in interface SlingHttpServletRequest
Parameters:
name - The name of the cookie to return.
Returns:
The named cookie or null if no such cookie exists.

getRequestProgressTracker

public RequestProgressTracker getRequestProgressTracker()
Description copied from interface: SlingHttpServletRequest
Returns the RequestProgressTracker of this request.

Specified by:
getRequestProgressTracker in interface SlingHttpServletRequest

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(Resource resource)
Description copied from interface: SlingHttpServletRequest
Same as SlingHttpServletRequest.getRequestDispatcher(Resource,RequestDispatcherOptions) but using empty options.

Specified by:
getRequestDispatcher in interface SlingHttpServletRequest

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(Resource resource,
                                                            RequestDispatcherOptions options)
Description copied from interface: SlingHttpServletRequest
Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given resource. A RequestDispatcher object can be used to include the resource in a response.

Returns null if a RequestDispatcher cannot be returned for any reason.

Specified by:
getRequestDispatcher in interface SlingHttpServletRequest
Parameters:
resource - The Resource instance whose response content may be included by the returned dispatcher.
options - influence the rendering of the included Resource
Returns:
a RequestDispatcher object that acts as a wrapper for the resource or null if an error occurs preparing the dispatcher.

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path,
                                                            RequestDispatcherOptions options)
Description copied from interface: SlingHttpServletRequest
Returns a RequestDispatcher object that acts as a wrapper for the resource located at the given path. A RequestDispatcher object can be used to include the resource in a response.

Returns null if a RequestDispatcher cannot be returned for any reason.

Specified by:
getRequestDispatcher in interface SlingHttpServletRequest
Parameters:
path - a String specifying the pathname to the resource. If it is relative, it must be relative against the current servlet.
options - influence the rendering of the included Resource
Returns:
a RequestDispatcher object that acts as a wrapper for the resource or null if an error occurs preparing the dispatcher.

getRequestParameter

public RequestParameter getRequestParameter(java.lang.String name)
Description copied from interface: SlingHttpServletRequest
Returns the value of a request parameter as a RequestParameter, or null if the parameter does not exist.

This method should only be used if the parameter has only one value. If the parameter might have more than one value, use SlingHttpServletRequest.getRequestParameters(String).

If this method is used with a multivalued parameter, the value returned is equal to the first value in the array returned by getRequestParameters.

This method is a shortcut for getRequestParameterMap().getValue(String).

Specified by:
getRequestParameter in interface SlingHttpServletRequest
Parameters:
name - a String specifying the name of the parameter
Returns:
a RequestParameter representing the single value of the parameter
See Also:
SlingHttpServletRequest.getRequestParameters(String), RequestParameterMap.getValue(String)

getRequestParameterMap

public RequestParameterMap getRequestParameterMap()
Description copied from interface: SlingHttpServletRequest
Returns a Map of the parameters of this request.

The values in the returned Map are from type RequestParameter array (RequestParameter[]).

If no parameters exist this method returns an empty Map.

Specified by:
getRequestParameterMap in interface SlingHttpServletRequest
Returns:
an immutable Map containing parameter names as keys and parameter values as map values, or an empty Map if no parameters exist. The keys in the parameter map are of type String. The values in the parameter map are of type RequestParameter array (RequestParameter[]).

getRequestParameters

public RequestParameter[] getRequestParameters(java.lang.String name)
Description copied from interface: SlingHttpServletRequest
Returns an array of RequestParameter objects containing all of the values the given request parameter has, or null if the parameter does not exist.

If the parameter has a single value, the array has a length of 1.

This method is a shortcut for getRequestParameterMap().getValues(String).

Specified by:
getRequestParameters in interface SlingHttpServletRequest
Parameters:
name - a String containing the name of the parameter the value of which is requested
Returns:
an array of RequestParameter objects containing the parameter values.
See Also:
SlingHttpServletRequest.getRequestParameter(String), RequestParameterMap.getValues(String)

getRequestPathInfo

public RequestPathInfo getRequestPathInfo()
Description copied from interface: SlingHttpServletRequest
Returns the RequestPathInfo pertaining to this request.

Specified by:
getRequestPathInfo in interface SlingHttpServletRequest
Returns:
the request path info.

getResource

public Resource getResource()
Description copied from interface: SlingHttpServletRequest
Returns the Resource object on whose behalf the servlet acts.

Specified by:
getResource in interface SlingHttpServletRequest
Returns:
The Resource object of this request.

getResourceResolver

public ResourceResolver getResourceResolver()
Description copied from interface: SlingHttpServletRequest
Returns the ResourceResolver which resolved the resource of this request.

Specified by:
getResourceResolver in interface SlingHttpServletRequest
Returns:
The resource resolver

getResourceBundle

public java.util.ResourceBundle getResourceBundle(java.util.Locale locale)
Description copied from interface: SlingHttpServletRequest
Returns the resource bundle for the given locale.

Specified by:
getResourceBundle in interface SlingHttpServletRequest
Parameters:
locale - the locale for which to retrieve the resource bundle. If this is null, the locale returned by ServletRequest.getLocale() is used to select the resource bundle.
Returns:
the resource bundle for the given locale

getResourceBundle

public java.util.ResourceBundle getResourceBundle(java.lang.String baseName,
                                                  java.util.Locale locale)
Description copied from interface: SlingHttpServletRequest
Returns the resource bundle of the given base name for the given locale.

Specified by:
getResourceBundle in interface SlingHttpServletRequest
Parameters:
baseName - The base name of the resource bundle to returned. If this parameter is null, the same resource bundle must be returned as if the SlingHttpServletRequest.getResourceBundle(Locale) method is called.
locale - the locale for which to retrieve the resource bundle. If this is null, the locale returned by ServletRequest.getLocale() is used to select the resource bundle.
Returns:
the resource bundle for the given locale

getResponseContentType

public java.lang.String getResponseContentType()
Description copied from interface: SlingHttpServletRequest
Returns the framework preferred content type for the response. The content type only includes the MIME type, not the character set.

For included resources this method will returned the same string as returned by the ServletResponse.getContentType() without the character set.

Specified by:
getResponseContentType in interface SlingHttpServletRequest
Returns:
preferred MIME type of the response

getResponseContentTypes

public java.util.Enumeration<java.lang.String> getResponseContentTypes()
Description copied from interface: SlingHttpServletRequest
Gets a list of content types which the framework accepts for the response. This list is ordered with the most preferable types listed first. The content type only includes the MIME type, not the character set.

For included resources this method will returned an enumeration containing a single entry which is the same string as returned by the ServletResponse.getContentType() without the character set.

Specified by:
getResponseContentTypes in interface SlingHttpServletRequest
Returns:
ordered list of MIME types for the response


Copyright © 2007-2009. All Rights Reserved.