Package org.silverpeas.core.web.http
Class RequestParameterDecoder
- java.lang.Object
-
- org.silverpeas.core.web.http.RequestParameterDecoder
-
public class RequestParameterDecoder extends Object
This class decodes the request parameters in order to set them to a simple specified POJO which attributes are annotated byFormParam
orXmlElement
annotation.
It is possible to annotate the attribute withUnescapeHtml
annotation in order to perform an HTML unescape operation (string type only).
WARNINGS:- for now, the decoder is not compatible with Inner Classes
- specified default value on
XmlElement
is not yet handled
- Author:
- Yohann Chastagnier
-
-
Constructor Summary
Constructors Constructor Description RequestParameterDecoder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> boolean
asBoolean(T object)
static <T> Date
asDate(T date, T hour, String userLanguage)
static <E extends Enum<E>>
EasEnum(String enumValue, Class<E> enumClass)
static <T> Integer
asInteger(T object)
static <T> Long
asLong(T object)
static <T> OffsetDateTime
asOffsetDateTime(T object)
static <O> O
decode(javax.servlet.ServletRequest request, Class<O> objectClass)
Decodes the request parameters in order to return an object filled with their values.static <O> O
decode(HttpRequest request, Class<O> objectClass)
Decodes the request parameters in order to return an object filled with their values.protected static RequestParameterDecoder
getInstance()
Gets the singleton instance.
-
-
-
Method Detail
-
getInstance
protected static RequestParameterDecoder getInstance()
Gets the singleton instance.- Returns:
- the singleton instance.
-
decode
public static <O> O decode(javax.servlet.ServletRequest request, Class<O> objectClass)
Decodes the request parameters in order to return an object filled with their values.- Type Parameters:
O
- the type of the requested returned instance.- Parameters:
request
- theServletRequest
that will be wrapped byHttpRequest
objectClass
- the class of the requested returned instance.- Returns:
- the decoded specified entity.
-
decode
public static <O> O decode(HttpRequest request, Class<O> objectClass)
Decodes the request parameters in order to return an object filled with their values.- Type Parameters:
O
- the type of the requested returned instance.- Parameters:
request
- theHttpRequest
wrapper that handle efficiently all parameters, included those of multipart request type.objectClass
- the class of the requested returned instance.- Returns:
- the decoded specified entity.
-
asOffsetDateTime
public static <T> OffsetDateTime asOffsetDateTime(T object)
-
asBoolean
public static <T> boolean asBoolean(T object)
-
asLong
public static <T> Long asLong(T object)
-
asInteger
public static <T> Integer asInteger(T object)
-
asDate
public static <T> Date asDate(T date, T hour, String userLanguage) throws ParseException
- Throws:
ParseException
-
-