org.springframework.http.converter.xml
Class SourceHttpMessageConverter<T extends javax.xml.transform.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 javax.xml.transform.Source>
- extends AbstractXmlHttpMessageConverter<T>
Implementation of HttpMessageConverter
that can read and write Source
objects.
- Since:
- 3.0
- Author:
- Arjen Poutsma
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SourceHttpMessageConverter
public SourceHttpMessageConverter()
supports
public boolean supports(java.lang.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 javax.xml.transform.Source>
- Parameters:
clazz
- the class to test for support
- Returns:
true
if supported; false
otherwise
readFromSource
protected T readFromSource(java.lang.Class clazz,
HttpHeaders headers,
javax.xml.transform.Source source)
throws java.io.IOException
- Description copied from class:
AbstractXmlHttpMessageConverter
- Abstract template method called from
AbstractHttpMessageConverter.read(Class, HttpInputMessage)
.
- Specified by:
readFromSource
in class AbstractXmlHttpMessageConverter<T extends javax.xml.transform.Source>
- Parameters:
clazz
- the type of object to returnheaders
- the HTTP input headerssource
- the HTTP input body
- Returns:
- the converted object
- Throws:
java.io.IOException
- in case of I/O errors
transformToByteArrayInputStream
private java.io.ByteArrayInputStream transformToByteArrayInputStream(javax.xml.transform.Source source)
throws javax.xml.transform.TransformerException
- Throws:
javax.xml.transform.TransformerException
getContentLength
protected java.lang.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 javax.xml.transform.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,
javax.xml.transform.Result result)
throws java.io.IOException
- Description copied from class:
AbstractXmlHttpMessageConverter
- Abstract template method called from
AbstractXmlHttpMessageConverter.writeInternal(Object, HttpOutputMessage)
.
- Specified by:
writeToResult
in class AbstractXmlHttpMessageConverter<T extends javax.xml.transform.Source>
- Parameters:
t
- the object to write to the output messageheaders
- the HTTP output headersresult
- the HTTP output body
- Throws:
java.io.IOException
- in case of I/O errors