org.springframework.http.converter.xml

## Class SourceHttpMessageConverter<T extends Source>

- java.lang.Object
- - org.springframework.http.converter.AbstractHttpMessageConverter<T>
  - - org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter<T>
    - - org.springframework.http.converter.xml.SourceHttpMessageConverter<T>

All Implemented Interfaces:
  HttpMessageConverter<T>

    public class SourceHttpMessageConverter<T extends Source>
    extends AbstractXmlHttpMessageConverter<T>

Implementation of `HttpMessageConverter` that can read and write `Source` objects.

Since:
  3.0
Author:
  Arjen Poutsma

### Field Summary

### Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter

`logger`

### Constructor Summary

Constructors
Constructor and Description
`SourceHttpMessageConverter()`

### Method Summary

Methods
`protected Long` `getContentLength(T t, MediaType contentType)` Returns the content length for the given type.
`protected T` `readFromSource(Class clazz, HttpHeaders headers, Source source)` Abstract template method called from `AbstractHttpMessageConverter.read(Class, HttpInputMessage)`.
`boolean` `supports(Class<?> clazz)` Indicates whether the given class is supported by this converter.
`protected void` `writeToResult(T t, HttpHeaders headers, Result result)` Abstract template method called from `AbstractXmlHttpMessageConverter.writeInternal(Object, HttpOutputMessage)`.

### Methods inherited from class org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter

`readInternal, transform, writeInternal`

### Methods inherited from class org.springframework.http.converter.AbstractHttpMessageConverter

`canRead, canRead, canWrite, canWrite, getDefaultContentType, getSupportedMediaTypes, read, setSupportedMediaTypes, write`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### SourceHttpMessageConverter

    public SourceHttpMessageConverter()

### Method Detail

#### supports

    public boolean supports(Class<?> clazz)

Description copied from class: `AbstractHttpMessageConverter`
Indicates whether the given class is supported by this converter.

Specified by:
  `supports` in class `AbstractHttpMessageConverter<T extends Source>`
Parameters:
  `clazz` - the class to test for support
Returns:
  `true` if supported; `false` otherwise

#### readFromSource

    protected T readFromSource(Class clazz,
                   HttpHeaders headers,
                   Source source)
                                       throws IOException

Description copied from class: `AbstractXmlHttpMessageConverter`
Abstract template method called from `AbstractHttpMessageConverter.read(Class, HttpInputMessage)`.

Specified by:
  `readFromSource` in class `AbstractXmlHttpMessageConverter<T extends Source>`
Parameters:
  `clazz` - the type of object to return
  `headers` - the HTTP input headers
  `source` - the HTTP input body
Returns:
  the converted object
Throws:
  `IOException` - in case of I/O errors

#### getContentLength

    protected Long getContentLength(T t,
                        MediaType contentType)

Description copied from class: `AbstractHttpMessageConverter`
Returns the content length for the given type.

By default, this returns `null`, meaning that the content length is unknown. Can be overridden in subclasses.

Overrides:
  `getContentLength` in class `AbstractHttpMessageConverter<T extends Source>`
Parameters:
  `t` - the type to return the content length for
Returns:
  the content length, or `null` if not known

#### writeToResult

    protected void writeToResult(T t,
                     HttpHeaders headers,
                     Result result)
                          throws IOException

Description copied from class: `AbstractXmlHttpMessageConverter`
Abstract template method called from `AbstractXmlHttpMessageConverter.writeInternal(Object, HttpOutputMessage)`.

Specified by:
  `writeToResult` in class `AbstractXmlHttpMessageConverter<T extends Source>`
Parameters:
  `t` - the object to write to the output message
  `headers` - the HTTP output headers
  `result` - the HTTP output body
Throws:
  `IOException` - in case of I/O errors