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 byFormParamorXmlElementannotation.
It is possible to annotate the attribute withUnescapeHtmlannotation 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
XmlElementis 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> booleanasBoolean(T object)static <T> DateasDate(T date, T hour, String userLanguage)static <E extends Enum<E>>
EasEnum(String enumValue, Class<E> enumClass)static <T> IntegerasInteger(T object)static <T> LongasLong(T object)static <T> OffsetDateTimeasOffsetDateTime(T object)static <O> Odecode(javax.servlet.ServletRequest request, Class<O> objectClass)Decodes the request parameters in order to return an object filled with their values.static <O> Odecode(HttpRequest request, Class<O> objectClass)Decodes the request parameters in order to return an object filled with their values.protected static RequestParameterDecodergetInstance()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- theServletRequestthat will be wrapped byHttpRequestobjectClass- 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- theHttpRequestwrapper 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
-
-