Class 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 by FormParam or XmlElement annotation.
    It is possible to annotate the attribute with UnescapeHtml 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 Detail

      • RequestParameterDecoder

        public RequestParameterDecoder()
    • 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 - the ServletRequest that will be wrapped by HttpRequest
        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 - the HttpRequest 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)
      • asEnum

        public static <E extends Enum<E>> E asEnum​(String enumValue,
                                                   Class<E> enumClass)