Class AbstractXmlHttpMessageConverter<T>
- java.lang.Object
- org.springframework.http.converter.AbstractHttpMessageConverter<T>
- org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter<T>
- All Implemented Interfaces:
HttpMessageConverter<T>
- Direct Known Subclasses:
AbstractJaxb2HttpMessageConverter,MarshallingHttpMessageConverter
public abstract class AbstractXmlHttpMessageConverter<T> extends AbstractHttpMessageConverter<T>
Abstract base class forHttpMessageConvertersthat convert from/to XML.By default, subclasses of this converter support
text/xml,application/xml, andapplication/*-xml. This can be overridden by setting thesupportedMediaTypesproperty.- Since:
- 3.0
- Author:
- Arjen Poutsma
Field Summary
Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
logger
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractXmlHttpMessageConverter()Protected constructor that sets thesupportedMediaTypestotext/xmlandapplication/xml, andapplication/*-xml.
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TreadFromSource(Class<? extends T> clazz, HttpHeaders headers, Source source)Abstract template method called fromAbstractHttpMessageConverter.read(Class, HttpInputMessage).TreadInternal(Class<? extends T> clazz, HttpInputMessage inputMessage)Abstract template method that reads the actual object.protected voidtransform(Source source, Result result)Transforms the givenSourceto theResult.protected voidwriteInternal(T t, HttpOutputMessage outputMessage)Abstract template method that writes the actual body.protected abstract voidwriteToResult(T t, HttpHeaders headers, Result result)Abstract template method called fromwriteInternal(Object, HttpOutputMessage).Methods inherited from class org.springframework.http.converter.AbstractHttpMessageConverter
addDefaultHeaders, canRead, canRead, canWrite, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, supports, write
Constructor Detail
AbstractXmlHttpMessageConverter
protected AbstractXmlHttpMessageConverter()
Protected constructor that sets thesupportedMediaTypestotext/xmlandapplication/xml, andapplication/*-xml.
Method Detail
readInternal
public final T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException
Description copied from class:AbstractHttpMessageConverterAbstract template method that reads the actual object. Invoked fromAbstractHttpMessageConverter.read(java.lang.Class<? extends T>, org.springframework.http.HttpInputMessage).- Specified by:
readInternalin classAbstractHttpMessageConverter<T>- Parameters:
clazz- the type of object to returninputMessage- the HTTP input message to read from- Returns:
- the converted object
- Throws:
IOException- in case of I/O errorsHttpMessageNotReadableException- in case of conversion errors
writeInternal
protected final void writeInternal(T t, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException
Description copied from class:AbstractHttpMessageConverterAbstract template method that writes the actual body. Invoked fromAbstractHttpMessageConverter.write(T, org.springframework.http.MediaType, org.springframework.http.HttpOutputMessage).- Specified by:
writeInternalin classAbstractHttpMessageConverter<T>- Parameters:
t- the object to write to the output messageoutputMessage- the HTTP output message to write to- Throws:
IOException- in case of I/O errorsHttpMessageNotWritableException- in case of conversion errors
transform
protected void transform(Source source, Result result) throws TransformerException
Transforms the givenSourceto theResult.- Parameters:
source- the source to transform fromresult- the result to transform to- Throws:
TransformerException- in case of transformation errors
readFromSource
protected abstract T readFromSource(Class<? extends T> clazz, HttpHeaders headers, Source source) throws IOException, HttpMessageNotReadableException
Abstract template method called fromAbstractHttpMessageConverter.read(Class, HttpInputMessage).- Parameters:
clazz- the type of object to returnheaders- the HTTP input headerssource- the HTTP input body- Returns:
- the converted object
- Throws:
IOException- in case of I/O errorsHttpMessageNotReadableException- in case of conversion errors
writeToResult
protected abstract void writeToResult(T t, HttpHeaders headers, Result result) throws IOException, HttpMessageNotWritableException
Abstract template method called fromwriteInternal(Object, HttpOutputMessage).- Parameters:
t- the object to write to the output messageheaders- the HTTP output headersresult- the HTTP output body- Throws:
IOException- in case of I/O errorsHttpMessageNotWritableException- in case of conversion errors