Context.HTTP_STATUS, Context.ImplCONTENT_TYPE, NINJA_PROPERTIES_X_FORWARDED_FOR, X_FORWARD_HEADER| Constructor and Description |
|---|
WrappedContext(Context wrapped) |
| Modifier and Type | Method and Description |
|---|---|
void |
asyncRequestComplete()
Indicate that processing this request is complete.
|
Result |
controllerReturned() |
ResponseStreams |
finalizeHeaders(Result result)
Finalizing the headers copies all stuff into the headers.
|
ResponseStreams |
finalizeHeadersWithoutFlashAndSessionCookie(Result result)
Finalizing the headers copies all stuff into the headers.
|
java.lang.String |
getAcceptCharset()
Get the charset that is acceptable for the client.
|
java.lang.String |
getAcceptContentType()
Get the content type that is acceptable for the client.
|
java.lang.String |
getAcceptEncoding()
Get the encoding that is acceptable for the client.
|
java.lang.String |
getAcceptLanguage()
Get the language that is acceptable for the client.
|
java.lang.Object |
getAttribute(java.lang.String name)
Gets an attribute value previously set by
Context.setAttribute(java.lang.String, java.lang.Object). |
<T> T |
getAttribute(java.lang.String name,
java.lang.Class<T> clazz)
Gets an attribute value previously set by
Context.setAttribute(java.lang.String, java.lang.Object). |
java.lang.String |
getContextPath()
Get the context path on which the application is running
That means:
- when running on root the context path is empty
- when running on context there is NEVER a trailing slash
We conform to the following rules:
Returns the portion of the request URI that indicates the context of the
request.
|
Cookie |
getCookie(java.lang.String cookieName)
Get cookie from context.
|
java.util.List<Cookie> |
getCookies()
Get all cookies from the context.
|
java.lang.String |
getCookieValue(java.lang.String name)
Get the cookie value from the request, if defined
|
org.apache.commons.fileupload.FileItemIterator |
getFileItemIterator()
Gets the FileItemIterator of the input.
|
FlashScope |
getFlashCookie()
Deprecated => please use getFlashScope()
|
FlashScope |
getFlashScope()
Returns the flash cookie.
|
java.lang.String |
getHeader(java.lang.String name)
Get the (first) request header with the given name
|
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getHeaders()
Get all the headers from the request
|
java.util.List<java.lang.String> |
getHeaders(java.lang.String name)
Get all the request headers with the given name.
|
java.lang.String |
getHostname()
Returns the hostname as seen by the server.
|
java.io.InputStream |
getInputStream()
Get the input stream to read the request.
|
java.lang.String |
getMethod()
Returns the name of the HTTP method with which this
request was made, for example, GET, POST, or PUT.
|
java.lang.String |
getParameter(java.lang.String key)
Get the parameter with the given key from the request.
|
java.lang.String |
getParameter(java.lang.String key,
java.lang.String defaultValue)
Same like
Context.getParameter(String), but returns given defaultValue
instead of null in case parameter cannot be found. |
<T> T |
getParameterAs(java.lang.String key,
java.lang.Class<T> clazz)
Same like
Context.getParameter(String), but converts the parameter to
Class type if found. |
<T> T |
getParameterAs(java.lang.String key,
java.lang.Class<T> clazz,
T defaultValue)
Same like
Context.getParameter(String, String), but converts the
parameter to Class type if found. |
java.lang.Integer |
getParameterAsInteger(java.lang.String key)
Same like
Context.getParameter(String), but converts the parameter to
Integer if found. |
java.lang.Integer |
getParameterAsInteger(java.lang.String key,
java.lang.Integer defaultValue)
Same like
Context.getParameter(String, String), but converts the
parameter to Integer if found. |
java.util.Map<java.lang.String,java.lang.String[]> |
getParameters()
Get all the parameters from the request
|
java.util.List<java.lang.String> |
getParameterValues(java.lang.String name)
Get the parameter with the given key from the request.
|
java.lang.String |
getPathParameter(java.lang.String key)
Get the path parameter for the given key.
|
java.lang.Integer |
getPathParameterAsInteger(java.lang.String key)
Get the path parameter for the given key and convert it to Integer.
|
java.lang.String |
getPathParameterEncoded(java.lang.String key)
Get the path parameter for the given key.
|
java.io.BufferedReader |
getReader()
Get the reader to read the request.
|
java.lang.String |
getRemoteAddr()
Returns the Internet Protocol (IP) address of the client
or last proxy that sent the request.
|
java.lang.String |
getRequestContentType()
The Content-Type header field indicates the media type of the request
body sent to the recipient.
|
java.lang.String |
getRequestPath()
Returns the path that Ninja should act upon.
|
java.lang.String |
getRequestUri()
Returns the uri as seen by the server.
|
Route |
getRoute()
Get the route for this context
|
Session |
getSession()
Returns the client side session.
|
Session |
getSessionCookie()
Deprecated => please use getSession();
|
Validation |
getValidation()
Get the validation context
|
void |
handleAsync()
Indicate that this request is going to be handled asynchronously
|
boolean |
hasCookie(java.lang.String cookieName)
Checks whether the context contains a given cookie.
|
boolean |
isAsync() |
boolean |
isMultipart()
Check if request is of type multipart.
|
boolean |
isRequestJson()
Check to see if the request content type is JSON.
|
boolean |
isRequestXml()
Check to see if the request content type is XML.
|
<T> T |
parseBody(java.lang.Class<T> classOfT)
This will give you the request body nicely parsed.
|
void |
returnResultAsync(Result result)
Indicate that request processing of an async request is complete.
|
void |
setAttribute(java.lang.String name,
java.lang.Object value)
Sets an attribute value.
|
public WrappedContext(Context wrapped)
public java.lang.String getRequestUri()
ContextgetRequestUri in interface Contextpublic java.lang.String getHostname()
ContextgetHostname in interface Contextpublic java.lang.String getRemoteAddr()
ContextREMOTE_ADDR.
To honour the X-Forwarded-For flag make sure you set
"ninja.ninja.x_forwarded_for_enabled=true" in your application.conf. Default
behavior is NOT to take X-Forwarded-For flag into account.getRemoteAddr in interface ContextString containing the
IP address of the client that sent the request. Takes into
account X-Forwarded-For header if configured to do so.public FlashScope getFlashCookie()
ContextgetFlashCookie in interface Contextpublic Session getSessionCookie()
ContextgetSessionCookie in interface Contextpublic FlashScope getFlashScope()
ContextgetFlashScope in interface Contextpublic Session getSession()
ContextgetSession in interface Contextpublic java.lang.String getParameter(java.lang.String key)
ContextWhen the parameter is multivalued, returns the first value.
The parameter is decoded by default.
getParameter in interface Contextkey - The key of the parameterContext.getParameterValues(java.lang.String)public java.util.List<java.lang.String> getParameterValues(java.lang.String name)
ContextThe parameter is decoded by default.
getParameterValues in interface Contextname - The key of the parameterpublic java.lang.String getParameter(java.lang.String key,
java.lang.String defaultValue)
ContextContext.getParameter(String), but returns given defaultValue
instead of null in case parameter cannot be found.
The parameter is decoded by default.getParameter in interface Contextkey - The name of the post or query parameterdefaultValue - A default value if parameter not found.public java.lang.Integer getParameterAsInteger(java.lang.String key)
ContextContext.getParameter(String), but converts the parameter to
Integer if found.
The parameter is decoded by default.getParameterAsInteger in interface Contextkey - The name of the post or query parameterpublic java.lang.Integer getParameterAsInteger(java.lang.String key,
java.lang.Integer defaultValue)
ContextContext.getParameter(String, String), but converts the
parameter to Integer if found.
The parameter is decoded by default.getParameterAsInteger in interface Contextkey - The name of the post or query parameterdefaultValue - A default value if parameter not found.public <T> T getParameterAs(java.lang.String key,
java.lang.Class<T> clazz)
ContextContext.getParameter(String), but converts the parameter to
Class type if found.
The parameter is decoded by default.getParameterAs in interface Contextkey - The name of the post or query parameterpublic <T> T getParameterAs(java.lang.String key,
java.lang.Class<T> clazz,
T defaultValue)
ContextContext.getParameter(String, String), but converts the
parameter to Class type if found.
The parameter is decoded by default.getParameterAs in interface Contextkey - The name of the post or query parameterdefaultValue - A default value if parameter not found.public java.lang.String getPathParameter(java.lang.String key)
ContextgetPathParameter in interface Contextkey - The name of the path parameter in a route. Eg
/{myName}/rest/of/urlpublic java.lang.Integer getPathParameterAsInteger(java.lang.String key)
ContextgetPathParameterAsInteger in interface Contextkey - the key of the path parameterpublic java.util.Map<java.lang.String,java.lang.String[]> getParameters()
ContextgetParameters in interface Contextpublic java.lang.String getHeader(java.lang.String name)
Contextpublic java.util.List<java.lang.String> getHeaders(java.lang.String name)
ContextgetHeaders in interface Contextpublic java.util.Map<java.lang.String,java.util.List<java.lang.String>> getHeaders()
ContextgetHeaders in interface Contextpublic java.lang.String getCookieValue(java.lang.String name)
ContextgetCookieValue in interface Contextname - The name of the cookiepublic <T> T parseBody(java.lang.Class<T> classOfT)
ContextBodyParserEngine
BodyParserEngineJson BodyParserEngineXml
and BodyParserEngineManagerpublic void handleAsync()
ContexthandleAsync in interface Contextpublic void returnResultAsync(Result result)
ContextreturnResultAsync in interface Contextpublic void asyncRequestComplete()
ContextasyncRequestComplete in interface Contextpublic Result controllerReturned()
controllerReturned in interface Contextpublic ResponseStreams finalizeHeaders(Result result)
ContextfinalizeHeaders in interface Contextpublic ResponseStreams finalizeHeadersWithoutFlashAndSessionCookie(Result result)
ContextfinalizeHeadersWithoutFlashAndSessionCookie in interface Contextpublic java.io.InputStream getInputStream()
throws java.io.IOException
ContextgetInputStream in interface Contextjava.io.IOExceptionpublic java.io.BufferedReader getReader()
throws java.io.IOException
Contextpublic java.lang.String getRequestContentType()
ContextContent-Type: text/html;
charset=ISO-8859-4getRequestContentType in interface Contextpublic Route getRoute()
Contextpublic boolean isMultipart()
ContextisMultipart in interface Contextpublic org.apache.commons.fileupload.FileItemIterator getFileItemIterator()
ContextgetFileItemIterator in interface Contextpublic java.lang.String getRequestPath()
ContextgetRequestPath in interface Contextpublic Validation getValidation()
ContextgetValidation in interface Contextpublic java.lang.String getPathParameterEncoded(java.lang.String key)
ContextgetPathParameterEncoded in interface Contextkey - The name of the path parameter in a route. Eg
/{myName}/rest/of/urlpublic java.lang.String getAcceptContentType()
ContextResult.TEXT_HTML > Result.APPLICATION_XML > Result.APPLICATION_JSON > Result.TEXT_PLAIN > Result.APPLICATION_OCTET_STREAM level- or quality-parameter are ignored
with this method.) E.g. Accept: text/*;q=0.3, text/html;q=0.7,
text/html;level=1,text/html;level=2;q=0.4
The Accept request-header field can be used to specify certain media
types which are acceptable for the response. Accept headers can be used
to indicate that the request is specifically limited to a small set of
desired types, as in the case of a request for an in-line image.getAcceptContentType in interface ContextResult mime types that is acceptable for the
client or Result.TEXT_HTML if not setpublic java.lang.String getAcceptEncoding()
ContextgetAcceptEncoding in interface Contextpublic java.lang.String getAcceptLanguage()
ContextgetAcceptLanguage in interface Contextpublic java.lang.String getAcceptCharset()
ContextgetAcceptCharset in interface Contextpublic Cookie getCookie(java.lang.String cookieName)
Contextpublic boolean hasCookie(java.lang.String cookieName)
Contextpublic java.util.List<Cookie> getCookies()
ContextgetCookies in interface Contextpublic java.lang.String getMethod()
Contextpublic java.lang.Object getAttribute(java.lang.String name)
ContextContext.setAttribute(java.lang.String, java.lang.Object).
Attributes are shared state for the duration of the request;
useful to pass values between filters and
controllers.
getAttribute in interface Contextnull if the attribute does
not existpublic <T> T getAttribute(java.lang.String name,
java.lang.Class<T> clazz)
ContextContext.setAttribute(java.lang.String, java.lang.Object).
This is a convenience method, equivalent to:
return clazz.cast(getAttribute(name));
Attributes are shared state for the duration of the request;
useful to pass values between filters and
controllers.
getAttribute in interface Contextnull if the attribute does
not existpublic void setAttribute(java.lang.String name,
java.lang.Object value)
Context
Attributes are shared state for the duration of the request;
useful to pass values between filters and
controllers.
setAttribute in interface ContextContext.getAttribute(String),
Context.getAttribute(String, Class)public java.lang.String getContextPath()
ContextgetContextPath in interface Contextpublic boolean isRequestJson()
ContextChecks to see if the request content type has been set application/json
isRequestJson in interface Contextapplication/jsonpublic boolean isRequestXml()
ContextChecks to see if the request content type has been set application/xml
isRequestXml in interface Contextapplication/xmlCopyright © 2014 ninjaframework. All Rights Reserved.