public class SpincastRequestRequestContextAddon<R extends IRequestContext<?>> extends Object implements IRequestRequestContextAddon<R>
| Constructor and Description |
|---|
SpincastRequestRequestContextAddon(R requestContext,
IServer server,
IJsonManager jsonManager,
IXmlManager xmlManager,
ISpincastUtils spincastUtils,
ISpincastConfig spincastConfig) |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
getBodyAsByteArray()
The bytes of the request's body.
|
InputStream |
getBodyAsInputStream()
The raw InputStream of the request's body.
|
String |
getBodyAsString()
The request's body as a String, using the
UTF-8 encoding. |
String |
getBodyAsString(String encoding)
The request's body as a String, using the specified encoding.
|
String |
getContentType()
The Content-Type of the request, if any.
|
ContentTypeDefaults |
getContentTypeBestMatch()
Finds the best
Content-Type to use for a response
using the "Accept" header of the request. |
protected Object |
getExchange() |
List<String> |
getFormData(String name)
A specific parameter submitted from a
FORM via a POST method. |
String |
getFormDataFirst(String name)
The first (and often only) value of a specific parameter submitted from a
FORM via a POST method. |
Map<String,List<String>> |
getFormDatas()
The parameters submitted from a
FORM via a POST method. |
String |
getFullUrl()
Returns the full URL, including the queryString.
|
List<String> |
getHeader(String name)
Returns the values of the specified header from the current request or
an empty list if not found.
|
String |
getHeaderFirst(String name)
The first value of the specified header from the current request.
|
Map<String,List<String>> |
getHeaders()
Returns all headers of the current request.
|
HttpMethod |
getHttpMethod()
Gets the request's
HTTP method. |
<T> T |
getJsonBody(Class<T> clazz)
The request's body deserialized to the specified
class. |
IJsonObject |
getJsonBodyAsJsonObject()
The request's body deserialized to a
IJsonObject. |
Map<String,Object> |
getJsonBodyAsMap()
The request's body deserialized to a
Map<String, Object>. |
protected IJsonManager |
getJsonManager() |
Locale |
getLocaleBestMatch()
Find the best
Locale to use for a response
using the "Accept-Language" header of
the request. |
String |
getOriginalFullUrl()
If the request has been forwarded,
getFullUrl() is
going to return the new, forwarded, url. |
String |
getPathParam(String name)
A specific value parsed from a dynamic parameter of the route path.
|
Map<String,String> |
getPathParams()
The values parsed from the dynamic parameters of the route path.
|
String |
getQueryString()
The queryString of the request, without the "?".
|
List<String> |
getQueryStringParam(String name)
A specific parameter taken from the queryString of the request.
|
String |
getQueryStringParamFirst(String name)
The first (and often only) value of a specific parameter taken from the
queryString of the request.
|
Map<String,List<String>> |
getQueryStringParams()
The parameters taken from the queryString of the request.
|
protected R |
getRequestContext() |
String |
getRequestPath()
The path of the request (no querystring).
|
protected IServer |
getServer() |
protected ISpincastConfig |
getSpincastConfig() |
protected ISpincastUtils |
getSpincastUtils() |
File |
getUploadedFileFirst(String name)
The first (and often only) uploaded file of the specified name.
|
Map<String,List<File>> |
getUploadedFiles()
The uploaded files, with their names as the keys.
|
List<File> |
getUploadedFiles(String name)
The uploaded files of the specified name.
|
<T> T |
getXmlBody(Class<T> clazz)
The request's body deserialized to the specified
class. |
IJsonObject |
getXmlBodyAsJsonObject()
The request's body deserialized to a
IJsonObject. |
Map<String,Object> |
getXmlBodyAsMap()
The request's body deserialized to a
Map<String, Object>. |
protected IXmlManager |
getXmlManager() |
boolean |
isHTMLShouldBeReturn()
Will return
true if the request specifies
that HTML is the most appropriate format
to return. |
boolean |
isJsonShouldBeReturn()
Will return
true if the request specifies
that Json is the most appropriate format
to return. |
boolean |
isPlainTextShouldBeReturn()
Will return
true if the request specifies
that plain-text is the most appropriate format
to return. |
boolean |
isXMLShouldBeReturn()
Will return
true if the request specifies
that XML is the most appropriate format
to return. |
protected void |
parseQueryString() |
void |
parseQueryStringParams() |
protected void |
parseRequestPath() |
protected void |
parseUrl() |
protected void |
validateUrlInfoCache() |
@Inject public SpincastRequestRequestContextAddon(R requestContext, IServer server, IJsonManager jsonManager, IXmlManager xmlManager, ISpincastUtils spincastUtils, ISpincastConfig spincastConfig)
protected R getRequestContext()
protected IServer getServer()
protected IJsonManager getJsonManager()
protected IXmlManager getXmlManager()
protected ISpincastUtils getSpincastUtils()
protected ISpincastConfig getSpincastConfig()
protected Object getExchange()
public HttpMethod getHttpMethod()
IRequestRequestContextAddonHTTP method.getHttpMethod in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public ContentTypeDefaults getContentTypeBestMatch()
IRequestRequestContextAddonContent-Type to use for a response
using the "Accept" header of the request. It will
fallback to ContentTypeDefaults.TEXT if nothing more specific
is found.getContentTypeBestMatch in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public boolean isJsonShouldBeReturn()
IRequestRequestContextAddontrue if the request specifies
that Json is the most appropriate format
to return.isJsonShouldBeReturn in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public boolean isHTMLShouldBeReturn()
IRequestRequestContextAddontrue if the request specifies
that HTML is the most appropriate format
to return.isHTMLShouldBeReturn in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public boolean isXMLShouldBeReturn()
IRequestRequestContextAddontrue if the request specifies
that XML is the most appropriate format
to return.isXMLShouldBeReturn in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public boolean isPlainTextShouldBeReturn()
IRequestRequestContextAddontrue if the request specifies
that plain-text is the most appropriate format
to return.isPlainTextShouldBeReturn in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public Map<String,List<String>> getHeaders()
IRequestRequestContextAddonTreeMap which iscase insensitive for the keys.
The map is immutable.getHeaders in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public List<String> getHeader(String name)
IRequestRequestContextAddonname is case insensitive.
The list is immutable.getHeader in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public String getHeaderFirst(String name)
IRequestRequestContextAddonname is case insensitive.
Returns null if the header is not found.getHeaderFirst in interface IRequestRequestContextAddon<R extends IRequestContext<?>>protected void validateUrlInfoCache()
protected void parseUrl()
protected void parseRequestPath()
protected void parseQueryString()
public void parseQueryStringParams()
public String getFullUrl()
IRequestRequestContextAddongetFullUrl in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public String getOriginalFullUrl()
IRequestRequestContextAddongetFullUrl() is
going to return the new, forwarded, url.
This method will always return the original url.getOriginalFullUrl in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public String getRequestPath()
IRequestRequestContextAddongetRequestPath in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public String getQueryString()
IRequestRequestContextAddongetQueryString in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public Map<String,List<String>> getQueryStringParams()
IRequestRequestContextAddongetQueryStringParams in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public List<String> getQueryStringParam(String name)
IRequestRequestContextAddongetQueryStringParam in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public String getQueryStringParamFirst(String name)
IRequestRequestContextAddonnull if the parameter doesn't exist.getQueryStringParamFirst in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public Map<String,String> getPathParams()
IRequestRequestContextAddongetPathParams in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public String getPathParam(String name)
IRequestRequestContextAddonname is case sensitive, since you have easy control over it.getPathParam in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public InputStream getBodyAsInputStream()
IRequestRequestContextAddongetBodyAsInputStream in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public String getBodyAsString()
IRequestRequestContextAddonUTF-8 encoding.
Note that the characters read cannot be read again!getBodyAsString in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public String getBodyAsString(String encoding)
IRequestRequestContextAddongetBodyAsString in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public byte[] getBodyAsByteArray()
IRequestRequestContextAddongetBodyAsByteArray in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public IJsonObject getJsonBodyAsJsonObject()
IRequestRequestContextAddonIJsonObject. A valid Json body
is expected.
Note that this can only be called once.getJsonBodyAsJsonObject in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public Map<String,Object> getJsonBodyAsMap()
IRequestRequestContextAddonMap<String, Object>. A valid Json body
is expected.
Note that this can only be called once.getJsonBodyAsMap in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public <T> T getJsonBody(Class<T> clazz)
IRequestRequestContextAddonclass. A valid Json body
is expected.
Note that this can only be called once.getJsonBody in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public IJsonObject getXmlBodyAsJsonObject()
IRequestRequestContextAddonIJsonObject. A valid XML body
is expected.
Note that this can only be called once.getXmlBodyAsJsonObject in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public Map<String,Object> getXmlBodyAsMap()
IRequestRequestContextAddonMap<String, Object>. A valid XML body
is expected.
Note that this can only be called once.getXmlBodyAsMap in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public <T> T getXmlBody(Class<T> clazz)
IRequestRequestContextAddonclass. A valid XML body
is expected.
Note that this can only be called once.getXmlBody in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public Map<String,List<String>> getFormDatas()
IRequestRequestContextAddonFORM via a POST method.
More than one value with the same key is possible.
The names are case sensitive.
The map is immutable.getFormDatas in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public List<String> getFormData(String name)
IRequestRequestContextAddonFORM via a POST method.
More than one value with the same name is possible.
The name is case sensitive.
The list is immutable.getFormData in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public String getFormDataFirst(String name)
IRequestRequestContextAddonFORM via a POST method.
The name is case sensitive.
Returns null if the parameter doesn't exist.getFormDataFirst in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public Map<String,List<File>> getUploadedFiles()
IRequestRequestContextAddongetUploadedFiles in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public List<File> getUploadedFiles(String name)
IRequestRequestContextAddonname is possible.
The list is immutable.
Returns an empty list if no uploaded files of this name exists.getUploadedFiles in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public File getUploadedFileFirst(String name)
IRequestRequestContextAddonnull if no uploaded file of this name exists.getUploadedFileFirst in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public Locale getLocaleBestMatch()
IRequestRequestContextAddonLocale to use for a response
using the "Accept-Language" header of
the request.
Returns the default Locale (taken from the configurations)
if nothing more specific is found.getLocaleBestMatch in interface IRequestRequestContextAddon<R extends IRequestContext<?>>public String getContentType()
IRequestRequestContextAddongetContentType in interface IRequestRequestContextAddon<R extends IRequestContext<?>>Content-Type of the request or null
if none was specified.Copyright © 2016. All rights reserved.