Package org.apache.sling.api.wrappers

# Class JavaxToJakartaRequestWrapper

java.lang.Object
org.apache.felix.http.jakartawrappers.ServletRequestWrapper
org.apache.felix.http.jakartawrappers.HttpServletRequestWrapper
org.apache.sling.api.wrappers.JavaxToJakartaRequestWrapper

All Implemented Interfaces:
  `jakarta.servlet.http.HttpServletRequest`, `jakarta.servlet.ServletRequest`, `Adaptable`, `SlingJakartaHttpServletRequest`

public class JavaxToJakartaRequestWrapper extends org.apache.felix.http.jakartawrappers.HttpServletRequestWrapper implements SlingJakartaHttpServletRequest
Wrapper for `SlingHttpServletRequest` to adapt it to the Jakarta Servlet API.

Since:
  2.9.0

## Field Summary

### Fields inherited from interface jakarta.servlet.http.HttpServletRequest

`BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH`

## Constructor Summary

Constructors
Constructor
Description
`JavaxToJakartaRequestWrapper(SlingHttpServletRequest wrappedRequest)`

## Method Summary

Modifier and Type
Method
Description
`<AdapterType>
AdapterType`
`adaptTo(@NotNull Class<AdapterType> type)`
Adapts the adaptable to another type.
`@Nullable jakarta.servlet.http.Cookie`
`getCookie(String name)`
Returns the named cookie from the HTTP request or `null` if no such cookie exists in the request.
`@Nullable jakarta.servlet.RequestDispatcher`
`getRequestDispatcher(@NotNull String path, RequestDispatcherOptions options)`
Returns a `RequestDispatcher` object that acts as a wrapper for the resource located at the given path.
`@Nullable jakarta.servlet.RequestDispatcher`
`getRequestDispatcher(@NotNull Resource resource)`
Same as `SlingJakartaHttpServletRequest.getRequestDispatcher(Resource,RequestDispatcherOptions)` but using empty options.
`@Nullable jakarta.servlet.RequestDispatcher`
`getRequestDispatcher(@NotNull Resource resource, RequestDispatcherOptions options)`
Returns a `RequestDispatcher` object that acts as a wrapper for the resource located at the given resource.
`@Nullable RequestParameter`
`getRequestParameter(@NotNull String name)`
Returns the value of a request parameter as a `RequestParameter`, or `null` if the parameter does not exist.
`@NotNull List<RequestParameter>`
`getRequestParameterList()`
Returns the request parameters as instances of the `RequestParameter` interface in the order or the request where the query string parameters are first and the POST request parameters are second.
`@NotNull RequestParameterMap`
`getRequestParameterMap()`
Returns a `Map` of the parameters of this request.
`@Nullable RequestParameter[]`
`getRequestParameters(@NotNull 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.
`@NotNull RequestPathInfo`
`getRequestPathInfo()`
Returns the `RequestPathInfo` pertaining to this request.
`@NotNull RequestProgressTracker`
`getRequestProgressTracker()`
Returns the `RequestProgressTracker` of this request.
`@NotNull Resource`
`getResource()`
Returns the `Resource` object on whose behalf the servlet acts.
`@Nullable ResourceBundle`
`getResourceBundle(String baseName, Locale locale)`
Returns the resource bundle of the given base name for the given locale.
`@Nullable ResourceBundle`
`getResourceBundle(Locale locale)`
Returns the resource bundle for the given locale.
`@NotNull ResourceResolver`
`getResourceResolver()`
Returns the `ResourceResolver` which resolved the `resource` of this request.
`@Nullable String`
`getResponseContentType()`
Returns the framework preferred content type for the response.
`@NotNull Enumeration<String>`
`getResponseContentTypes()`
Gets a list of content types which the framework accepts for the response.
`static @Nullable SlingJakartaHttpServletRequest`
`toJakartaRequest(@Nullable SlingHttpServletRequest request)`
Create a new wrapper
`static @Nullable jakarta.servlet.http.HttpServletRequest`
`toJakartaRequest(javax.servlet.http.HttpServletRequest request)`
Create a new wrapper
`static @Nullable jakarta.servlet.ServletRequest`
`toJakartaRequest(javax.servlet.ServletRequest request)`
Create a new wrapper

### Methods inherited from class org.apache.felix.http.jakartawrappers.HttpServletRequestWrapper

`authenticate, changeSessionId, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getTrailerFields, getUserPrincipal, isRequestedSessionIdFromCookie, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgrade`

### Methods inherited from class org.apache.felix.http.jakartawrappers.ServletRequestWrapper

`getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getProtocolRequestId, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, getTranslatedAttributeName, getWrapper, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface jakarta.servlet.http.HttpServletRequest

`authenticate, changeSessionId, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRequestedSessionId, getRequestURI, getRequestURL, getServletPath, getSession, getSession, getTrailerFields, isRequestedSessionIdFromCookie, isRequestedSessionIdFromURL, isRequestedSessionIdValid, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgrade`

### Methods inherited from interface jakarta.servlet.ServletRequest

`getAsyncContext, getAttribute, getAttributeNames, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getProtocolRequestId, getReader, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getRequestId, getScheme, getServerName, getServerPort, getServletConnection, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setCharacterEncoding, startAsync, startAsync`

### Methods inherited from interface org.apache.sling.api.SlingJakartaHttpServletRequest

`getAuthType, getRemoteUser, getUserPrincipal`

## Constructor Details

### JavaxToJakartaRequestWrapper

public JavaxToJakartaRequestWrapper(SlingHttpServletRequest wrappedRequest)

## Method Details

### toJakartaRequest

@Nullable public static @Nullable jakarta.servlet.ServletRequest toJakartaRequest(@Nullable javax.servlet.ServletRequest request)
Create a new wrapper

Parameters:
  `request` - The request object (may be null)
Returns:
  null if the request parameter is null or the wrapped request object otherwise

### toJakartaRequest

@Nullable public static @Nullable jakarta.servlet.http.HttpServletRequest toJakartaRequest(@Nullable javax.servlet.http.HttpServletRequest request)
Create a new wrapper

Parameters:
  `request` - The http request object (may be null)
Returns:
  null if the request parameter is null or the wrapped request object otherwise

### toJakartaRequest

@Nullable public static @Nullable SlingJakartaHttpServletRequest toJakartaRequest(@Nullable @Nullable SlingHttpServletRequest request)
Create a new wrapper

Parameters:
  `request` - The sling http request object (may be null)
Returns:
  null if the request parameter is null or the wrapped request object otherwise

### getCookie

@Nullable public @Nullable jakarta.servlet.http.Cookie getCookie(String name)
Description copied from interface: `SlingJakartaHttpServletRequest`
Returns the named cookie from the HTTP request or `null` if no such cookie exists in the request.

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

### getRequestDispatcher

@Nullable public @Nullable jakarta.servlet.RequestDispatcher getRequestDispatcher(@NotNull @NotNull String path, RequestDispatcherOptions options)
Description copied from interface: `SlingJakartaHttpServletRequest`
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 `SlingJakartaHttpServletRequest`
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.

### getRequestDispatcher

@Nullable public @Nullable jakarta.servlet.RequestDispatcher getRequestDispatcher(@NotNull @NotNull Resource resource, RequestDispatcherOptions options)
Description copied from interface: `SlingJakartaHttpServletRequest`
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 `SlingJakartaHttpServletRequest`
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

@Nullable public @Nullable jakarta.servlet.RequestDispatcher getRequestDispatcher(@NotNull @NotNull Resource resource)
Description copied from interface: `SlingJakartaHttpServletRequest`
Same as `SlingJakartaHttpServletRequest.getRequestDispatcher(Resource,RequestDispatcherOptions)` but using empty options.

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

### getRequestParameter

@Nullable public @Nullable RequestParameter getRequestParameter(@NotNull @NotNull String name)
Description copied from interface: `SlingJakartaHttpServletRequest`
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 `SlingJakartaHttpServletRequest.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 `SlingJakartaHttpServletRequest`
Parameters:
  `name` - a `String` specifying the name of the parameter
Returns:
  a `RequestParameter` representing the single value of the parameter
See Also:
  - `SlingJakartaHttpServletRequest.getRequestParameters(String)`
  - `RequestParameterMap.getValue(String)`

### getRequestParameterList

@NotNull public @NotNull List<RequestParameter> getRequestParameterList()
Description copied from interface: `SlingJakartaHttpServletRequest`
Returns the request parameters as instances of the `RequestParameter` interface in the order or the request where the query string parameters are first and the POST request parameters are second.

Specified by:
  `getRequestParameterList` in interface `SlingJakartaHttpServletRequest`
Returns:
  The list of `RequestParameter` in request declaration order.

### getRequestParameterMap

@NotNull public @NotNull RequestParameterMap getRequestParameterMap()
Description copied from interface: `SlingJakartaHttpServletRequest`
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 `SlingJakartaHttpServletRequest`
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

@Nullable public @Nullable RequestParameter[] getRequestParameters(@NotNull @NotNull String name)
Description copied from interface: `SlingJakartaHttpServletRequest`
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 `SlingJakartaHttpServletRequest`
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:
  - `SlingJakartaHttpServletRequest.getRequestParameter(String)`
  - `RequestParameterMap.getValues(String)`

### getRequestPathInfo

@NotNull public @NotNull RequestPathInfo getRequestPathInfo()
Description copied from interface: `SlingJakartaHttpServletRequest`
Returns the `RequestPathInfo` pertaining to this request.

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

### getRequestProgressTracker

@NotNull public @NotNull RequestProgressTracker getRequestProgressTracker()
Description copied from interface: `SlingJakartaHttpServletRequest`
Returns the `RequestProgressTracker` of this request.

Specified by:
  `getRequestProgressTracker` in interface `SlingJakartaHttpServletRequest`
Returns:
  The request progress tracker.

### getResource

@NotNull public @NotNull Resource getResource()
Description copied from interface: `SlingJakartaHttpServletRequest`
Returns the `Resource` object on whose behalf the servlet acts.

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

### getResourceBundle

@Nullable public @Nullable ResourceBundle getResourceBundle(Locale locale)
Description copied from interface: `SlingJakartaHttpServletRequest`
Returns the resource bundle for the given locale.

Specified by:
  `getResourceBundle` in interface `SlingJakartaHttpServletRequest`
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

@Nullable public @Nullable ResourceBundle getResourceBundle(String baseName, Locale locale)
Description copied from interface: `SlingJakartaHttpServletRequest`
Returns the resource bundle of the given base name for the given locale.

Specified by:
  `getResourceBundle` in interface `SlingJakartaHttpServletRequest`
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 `SlingJakartaHttpServletRequest.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

### getResourceResolver

@NotNull public @NotNull ResourceResolver getResourceResolver()
Description copied from interface: `SlingJakartaHttpServletRequest`
Returns the `ResourceResolver` which resolved the `resource` of this request.

Specified by:
  `getResourceResolver` in interface `SlingJakartaHttpServletRequest`
Returns:
  The resource resolver

### getResponseContentType

@Nullable public @Nullable String getResponseContentType()
Description copied from interface: `SlingJakartaHttpServletRequest`
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 `SlingJakartaHttpServletRequest`
Returns:
  preferred MIME type of the response

### getResponseContentTypes

@NotNull public @NotNull Enumeration<String> getResponseContentTypes()
Description copied from interface: `SlingJakartaHttpServletRequest`
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 `SlingJakartaHttpServletRequest`
Returns:
  ordered list of MIME types for the response

### adaptTo

@Nullable public <AdapterType> AdapterType adaptTo(@NotNull @NotNull Class<AdapterType> type)
Description copied from interface: `Adaptable`
Adapts the adaptable to another type.

Please note that it is explicitly left as an implementation detail whether each call to this method with the same `type` yields the same object or a new object on each call.

Implementations of this method should document their adapted types as well as their behaviour with respect to returning newly created or same instances on each call.

Specified by:
  `adaptTo` in interface `Adaptable`
Type Parameters:
  `AdapterType` - The generic type to which this object is adapted to
Parameters:
  `type` - The Class object of the target type, such as `javax.jcr.Node.class` or `java.io.File.class`
Returns:
  The adapter target or `null` if the object cannot adapt to the requested type