Top Description Fields Constructors Methods
org.springframework.http.converter.xml

public abstract Class AbstractXmlHttpMessageConverter<T>

extends AbstractHttpMessageConverter<T>
Class Inheritance
Known Direct Subclasses
org.springframework.http.converter.xml.MarshallingHttpMessageConverter, org.springframework.http.converter.xml.AbstractJaxb2HttpMessageConverter
Type Parameters
<T>
the converted object type
Imports
java.io.IOException, .InputStream, javax.xml.transform.Result, .Source, .TransformerException, .TransformerFactory, javax.xml.transform.stream.StreamResult, .StreamSource, org.springframework.http.HttpHeaders, .HttpInputMessage, .HttpOutputMessage, .MediaType, org.springframework.http.converter.AbstractHttpMessageConverter, .HttpMessageConversionException, .HttpMessageNotReadableException, .HttpMessageNotWritableException, org.springframework.util.StreamUtils

Abstract base class for HttpMessageConverters that convert from/to XML.

By default, subclasses of this converter support text/xml, application/xml, and application/*+xml. This can be overridden by setting the supportedMediaTypes property.

Authors
Arjen Poutsma, Juergen Hoeller
Since
3.0

Field Summary

Modifier and TypeField and Description
private final TransformerFactory
Inherited from org.springframework.http.converter.AbstractHttpMessageConverter:
logger

Constructor Summary

AccessConstructor and Description
protected
AbstractXmlHttpMessageConverter()

Protected constructor that sets the supportedMediaTypes to text/xml and application/xml, and application/*+xml.

Method Summary

Modifier and TypeMethod and Description
protected abstract T

Returns:

the converted object
readFromSource
(Class<? extends T>
the type of object to return
clazz
,
HttpHeaders
the HTTP input headers
headers
,
Source
the HTTP input body
source
)

Abstract template method called from read(Class, HttpInputMessage).

public final T
readInternal(Class<? extends T>
the type of object to return
clazz
,
HttpInputMessage
the HTTP input message to read from
inputMessage
)

Implements abstract org.springframework.http.converter.AbstractHttpMessageConverter.readInternal.

Abstract template method that reads the actual object.
protected void
transform(Source
the source to transform from
source
,
Result
the result to transform to
result
)

Transforms the given Source to the Result.

protected final void
writeInternal(T
the object to write to the output message
t
,
HttpOutputMessage
the HTTP output message to write to
outputMessage
)

Implements abstract org.springframework.http.converter.AbstractHttpMessageConverter.writeInternal.

Abstract template method that writes the actual body.
protected abstract void
writeToResult(T
the object to write to the output message
t
,
HttpHeaders
the HTTP output headers
headers
,
Result
the HTTP output body
result
)

Abstract template method called from writeInternal(Object, HttpOutputMessage).

Inherited from org.springframework.http.converter.AbstractHttpMessageConverter:
addDefaultHeaderscanReadcanReadcanWritecanWritegetContentLengthgetDefaultCharsetgetDefaultContentTypegetSupportedMediaTypesreadsetDefaultCharsetsetSupportedMediaTypessupportssupportsRepeatableWriteswrite

Field Detail

transformerFactoryback to summary
private final TransformerFactory transformerFactory

Constructor Detail

AbstractXmlHttpMessageConverterback to summary
protected AbstractXmlHttpMessageConverter()

Protected constructor that sets the supportedMediaTypes to text/xml and application/xml, and application/*+xml.

Method Detail

readFromSourceback to summary
protected abstract T readFromSource(Class<? extends T> clazz, HttpHeaders headers, Source source) throws Exception

Abstract template method called from read(Class, HttpInputMessage).

Parameters
clazz:Class<? extends T>

the type of object to return

headers:HttpHeaders

the HTTP input headers

source:Source

the HTTP input body

Returns:T

the converted object

Exceptions
Exception:
in case of I/O or conversion errors
readInternalback to summary
public final T readInternal(Class<? extends T> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException

Implements abstract org.springframework.http.converter.AbstractHttpMessageConverter.readInternal.

Doc from org.springframework.http.converter.AbstractHttpMessageConverter.readInternal.

Abstract template method that reads the actual object. Invoked from read.

Parameters
clazz:Class<? extends T>

the type of object to return

inputMessage:HttpInputMessage

the HTTP input message to read from

Returns:T

the converted object

Annotations
@Override
Exceptions
IOException:
in case of I/O errors
HttpMessageNotReadableException:
in case of conversion errors
transformback to summary
protected void transform(Source source, Result result) throws TransformerException

Transforms the given Source to the Result.

Parameters
source:Source

the source to transform from

result:Result

the result to transform to

Exceptions
TransformerException:
in case of transformation errors
writeInternalback to summary
protected final void writeInternal(T t, HttpOutputMessage outputMessage) throws IOException, HttpMessageNotWritableException

Implements abstract org.springframework.http.converter.AbstractHttpMessageConverter.writeInternal.

Doc from org.springframework.http.converter.AbstractHttpMessageConverter.writeInternal.

Abstract template method that writes the actual body. Invoked from write.

Parameters
t:T

the object to write to the output message

outputMessage:HttpOutputMessage

the HTTP output message to write to

Annotations
@Override
Exceptions
IOException:
in case of I/O errors
HttpMessageNotWritableException:
in case of conversion errors
writeToResultback to summary
protected abstract void writeToResult(T t, HttpHeaders headers, Result result) throws Exception

Abstract template method called from writeInternal(Object, HttpOutputMessage).

Parameters
t:T

the object to write to the output message

headers:HttpHeaders

the HTTP output headers

result:Result

the HTTP output body

Exceptions
Exception:
in case of I/O or conversion errors