org.springframework.http.converter
Interface HttpMessageConverter<T>

All Known Implementing Classes:
AbstractHttpMessageConverter, AbstractXmlHttpMessageConverter, BufferedImageHttpMessageConverter, ByteArrayHttpMessageConverter, FormHttpMessageConverter, MappingJacksonHttpMessageConverter, MarshallingHttpMessageConverter, SourceHttpMessageConverter, StringHttpMessageConverter

public interface HttpMessageConverter<T>

Strategy interface that specifies a converter that can convert from and to HTTP requests and responses.

Since:
3.0
Author:
Arjen Poutsma

Method Summary
 List<MediaType> getSupportedMediaTypes()
          Return the list of MediaType objects supported by this converter.
 T read(Class<T> clazz, HttpInputMessage inputMessage)
          Read an object of the given type form the given input message, and returns it.
 boolean supports(Class<? extends T> clazz)
          Indicate whether the given class is supported by this converter.
 void write(T t, HttpOutputMessage outputMessage)
          Write an given object to the given output message.
 

Method Detail

supports

boolean supports(Class<? extends T> clazz)
Indicate whether the given class is supported by this converter.

Parameters:
clazz - the class to test for support
Returns:
true if supported; false otherwise

getSupportedMediaTypes

List<MediaType> getSupportedMediaTypes()
Return the list of MediaType objects supported by this converter.


read

T read(Class<T> clazz,
       HttpInputMessage inputMessage)
       throws IOException,
              HttpMessageNotReadableException
Read an object of the given type form the given input message, and returns it.

Parameters:
clazz - the type of object to return
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

write

void write(T t,
           HttpOutputMessage outputMessage)
           throws IOException,
                  HttpMessageNotWritableException
Write an given object to the given output message.

Parameters:
t - the object to write to the output message
outputMessage - the message to write to
Throws:
IOException - in case of I/O errors
HttpMessageNotWritableException - in case of conversion errors