GenericHttpMessageConverter (Spring Framework 3.2.1.RELEASE API)
Date: 2013-01-24

org.springframework.http.converter

## Interface GenericHttpMessageConverter<T>

- All Superinterfaces:
    HttpMessageConverter<T>
  All Known Implementing Classes:
    Jaxb2CollectionHttpMessageConverter, MappingJackson2HttpMessageConverter, MappingJacksonHttpMessageConverter

      public interface GenericHttpMessageConverter<T>
      extends HttpMessageConverter<T>

  A specialization of `HttpMessageConverter` that can convert an HTTP request into a target object of a specified generic type.
  Since:
    3.2
  Author:
    Arjen Poutsma, Rossen Stoyanchev
  See Also:
    `ParameterizedTypeReference`

- - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `canRead(Type type, Class<?> contextClass, MediaType mediaType)` Indicates whether the given type can be read by this converter.
    `T` | `read(Type type, Class<?> contextClass, HttpInputMessage inputMessage)` Read an object of the given type form the given input message, and returns it.

    - ### Methods inherited from interface org.springframework.http.converter.HttpMessageConverter

      `canRead, canWrite, getSupportedMediaTypes, read, write`

- - ### Method Detail

    - #### canRead

          boolean canRead(Type type,
                        Class<?> contextClass,
                        MediaType mediaType)

      Indicates whether the given type can be read by this converter.
      Parameters:
        `type` - the type to test for readability
        `contextClass` - a context class for the target type, for example a class in which the target type appears in a method signature, can be `null`
        `mediaType` - the media type to read, can be `null` if not specified. Typically the value of a `Content-Type` header.
      Returns:
        `true` if readable; `false` otherwise

    - #### read

          T read(Type type,
               Class<?> contextClass,
               HttpInputMessage inputMessage)
                 throws IOException,
                        HttpMessageNotReadableException

      Read an object of the given type form the given input message, and returns it.
      Parameters:
        `type` - the type of object to return. This type must have previously been passed to the `canRead` method of this interface, which must have returned `true`.
        `contextClass` - a context class for the target type, for example a class in which the target type appears in a method signature, can be `null`
        `inputMessage` - the HTTP input message to read from
      Returns:
        the converted object
      Throws:
        `IOException` - in case of I/O errors
        `HttpMessageNotReadableException` - in case of conversion errors