public interface Context
| Modifier and Type | Interface and Description |
|---|---|
static class |
Context.HTTP_STATUS
Deprecated.
|
static interface |
Context.Impl |
| Modifier and Type | Field and Description |
|---|---|
static String |
CONTENT_TYPE
Content-Type: ...
|
| 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.
|
String |
getAcceptCharset()
Get the charset that is acceptable for the client.
|
String |
getAcceptContentType()
Get the content type that is acceptable for the client.
|
String |
getAcceptEncoding()
Get the encoding that is acceptable for the client.
|
String |
getAcceptLanguage()
Get the language that is acceptable for the client.
|
Object |
getAttribute(String name)
Gets an attribute value previously set by
setAttribute(java.lang.String, java.lang.Object). |
<T> T |
getAttribute(String name,
Class<T> clazz)
Gets an attribute value previously set by
setAttribute(java.lang.String, java.lang.Object). |
Cookie |
getCookie(String cookieName)
Get cookie from context.
|
List<Cookie> |
getCookies()
Get all cookies from the context.
|
String |
getCookieValue(String name)
Get the cookie value from the request, if defined
|
org.apache.commons.fileupload.FileItemIterator |
getFileItemIterator()
Gets the FileItemIterator of the input.
|
FlashCookie |
getFlashCookie()
Returns the flash cookie.
|
String |
getHeader(String name)
Get the (first) request header with the given name
|
Map<String,List<String>> |
getHeaders()
Get all the headers from the request
|
List<String> |
getHeaders(String name)
Get all the request headers with the given name.
|
InputStream |
getInputStream()
Get the input stream to read the request.
|
String |
getMethod()
Returns the name of the HTTP method with which this
request was made, for example, GET, POST, or PUT.
|
String |
getParameter(String name)
Get the parameter with the given key from the request.
|
String |
getParameter(String name,
String defaultValue)
Same like
getParameter(String), but returns given defaultValue
instead of null in case parameter cannot be found. |
Integer |
getParameterAsInteger(String name)
Same like
getParameter(String), but converts the parameter to
Integer if found. |
Integer |
getParameterAsInteger(String name,
Integer defaultValue)
Same like
getParameter(String, String), but converts the
parameter to Integer if found. |
Map<String,String[]> |
getParameters()
Get all the parameters from the request
|
List<String> |
getParameterValues(String name)
Get the parameter with the given key from the request.
|
String |
getPathParameter(String name)
Get the path parameter for the given key.
|
Integer |
getPathParameterAsInteger(String key)
Get the path parameter for the given key and convert it to Integer.
|
String |
getPathParameterEncoded(String name)
Get the path parameter for the given key.
|
BufferedReader |
getReader()
Get the reader to read the request.
|
String |
getRequestContentType()
The Content-Type header field indicates the media type of the request
body sent to the recipient.
|
String |
getRequestPath()
Returns the path that Ninja should act upon.
|
String |
getRequestUri()
Deprecated.
|
Route |
getRoute()
Get the route for this context
|
SessionCookie |
getSessionCookie()
Returns the client side session.
|
Validation |
getValidation()
Get the validation context
|
void |
handleAsync()
Indicate that this request is going to be handled asynchronously
|
boolean |
hasCookie(String cookieName)
Checks whether the context contains a given cookie.
|
boolean |
isMultipart()
Check if request is of type multipart.
|
<T> T |
parseBody(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(String name,
Object value)
Sets an attribute value.
|
static final String CONTENT_TYPE
String getRequestContentType()
Content-Type: text/html;
charset=ISO-8859-4@Deprecated String getRequestUri()
String getRequestPath()
FlashCookie getFlashCookie()
SessionCookie getSessionCookie()
Cookie getCookie(String cookieName)
cookieName - Name of the cookie to retrieveboolean hasCookie(String cookieName)
cookieName - Name of the cookie to check fortrue if the context has a cookie with that name.List<Cookie> getCookies()
String getParameter(String name)
When the parameter is multivalued, returns the first value.
The parameter is decoded by default.
name - The key of the parametergetParameterValues(java.lang.String)List<String> getParameterValues(String name)
The parameter is decoded by default.
name - The key of the parameterString getParameter(String name, String defaultValue)
getParameter(String), but returns given defaultValue
instead of null in case parameter cannot be found.
The parameter is decoded by default.name - The name of the post or query parameterdefaultValue - A default value if parameter not found.Integer getParameterAsInteger(String name)
getParameter(String), but converts the parameter to
Integer if found.
The parameter is decoded by default.name - The name of the post or query parameterInteger getParameterAsInteger(String name, Integer defaultValue)
getParameter(String, String), but converts the
parameter to Integer if found.
The parameter is decoded by default.name - The name of the post or query parameterdefaultValue - A default value if parameter not found.String getPathParameter(String name)
name - The name of the path parameter in a route. Eg
/{myName}/rest/of/urlString getPathParameterEncoded(String name)
name - The name of the path parameter in a route. Eg
/{myName}/rest/of/urlInteger getPathParameterAsInteger(String key)
key - the key of the path parameterMap<String,String[]> getParameters()
String getHeader(String name)
List<String> getHeaders(String name)
Map<String,List<String>> getHeaders()
String getCookieValue(String name)
name - The name of the cookie<T> T parseBody(Class<T> classOfT)
BodyParserEngine
BodyParserEngineJson BodyParserEngineXml
and BodyParserEngineManagerclassOfT - The class of the result.void handleAsync()
void returnResultAsync(Result result)
void asyncRequestComplete()
Result controllerReturned()
ResponseStreams finalizeHeaders(Result result)
InputStream getInputStream() throws IOException
IOExceptionBufferedReader getReader() throws IOException
IOExceptionRoute getRoute()
boolean isMultipart()
org.apache.commons.fileupload.FileItemIterator getFileItemIterator()
Validation getValidation()
String getAcceptContentType()
Result.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.Result mime types that is acceptable for the
client or Result.TEXT_HTML if not setString getAcceptEncoding()
String getAcceptLanguage()
String getAcceptCharset()
String getMethod()
String
specifying the name
of the method with which
this request was made (eg GET, POST, PUT...)Object getAttribute(String name)
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.
null if the attribute does
not exist<T> T getAttribute(String name, Class<T> clazz)
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.
null if the attribute does
not existCopyright © 2013. All Rights Reserved.