|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.http.converter.AbstractHttpMessageConverter<T> org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter<Object> org.springframework.http.converter.xml.MarshallingHttpMessageConverter
public class MarshallingHttpMessageConverter
Implementation of HttpMessageConverter
that can read
and write XML using Spring's Marshaller
and Unmarshaller
abstractions.
This converter requires a Marshaller
and Unmarshaller
before it can be used. These can be injected
by the constructor or bean properties.
By default, this converter supports text/xml
and application/xml
. This can be overridden by
setting the supportedMediaTypes
property.
Field Summary |
---|
Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter |
---|
logger |
Constructor Summary | |
---|---|
MarshallingHttpMessageConverter()
Construct a new MarshallingHttpMessageConverter with no Marshaller or Unmarshaller set. |
|
MarshallingHttpMessageConverter(Marshaller marshaller)
Construct a new MarshallingMessageConverter with the given Marshaller set. |
|
MarshallingHttpMessageConverter(Marshaller marshaller,
Unmarshaller unmarshaller)
Construct a new MarshallingMessageConverter with the given Marshaller and Unmarshaller . |
Method Summary | |
---|---|
protected Object |
readFromSource(Class<Object> clazz,
HttpHeaders headers,
Source source)
Abstract template method called from AbstractHttpMessageConverter.read(Class, HttpInputMessage) . |
void |
setMarshaller(Marshaller marshaller)
Set the Marshaller to be used by this message converter. |
void |
setUnmarshaller(Unmarshaller unmarshaller)
Set the Unmarshaller to be used by this message converter. |
boolean |
supports(Class<?> clazz)
Indicates whether the given class is supported by this converter. |
protected void |
writeToResult(Object o,
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, canWrite, getContentLength, getDefaultContentType, getSupportedMediaTypes, isSupported, read, setSupportedMediaTypes, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MarshallingHttpMessageConverter()
MarshallingHttpMessageConverter
with no Marshaller
or Unmarshaller
set. The
marshaller and unmarshaller must be set after construction by invoking setMarshaller(Marshaller)
and setUnmarshaller(Unmarshaller)
.
public MarshallingHttpMessageConverter(Marshaller marshaller)
MarshallingMessageConverter
with the given Marshaller
set. If the given Marshaller
also implements the Unmarshaller
interface, it is used for both marshalling and unmarshalling.
Otherwise, an exception is thrown.
Note that all Marshaller
implementations in Spring also implement the
Unmarshaller
interface, so that you can safely use this constructor.
marshaller
- object used as marshaller and unmarshallerpublic MarshallingHttpMessageConverter(Marshaller marshaller, Unmarshaller unmarshaller)
MarshallingMessageConverter
with the given Marshaller
and Unmarshaller
.
marshaller
- the Marshaller to useunmarshaller
- the Unmarshaller to useMethod Detail |
---|
public void setMarshaller(Marshaller marshaller)
Marshaller
to be used by this message converter.
public void setUnmarshaller(Unmarshaller unmarshaller)
Unmarshaller
to be used by this message converter.
public boolean supports(Class<?> clazz)
AbstractHttpMessageConverter
supports
in class AbstractHttpMessageConverter<Object>
clazz
- the class to test for support
true
if supported; false
otherwiseprotected Object readFromSource(Class<Object> clazz, HttpHeaders headers, Source source) throws IOException
AbstractXmlHttpMessageConverter
AbstractHttpMessageConverter.read(Class, HttpInputMessage)
.
readFromSource
in class AbstractXmlHttpMessageConverter<Object>
clazz
- the type of object to returnheaders
- the HTTP input headerssource
- the HTTP input body
IOException
- in case of I/O errorsprotected void writeToResult(Object o, HttpHeaders headers, Result result) throws IOException
AbstractXmlHttpMessageConverter
AbstractXmlHttpMessageConverter.writeInternal(Object, HttpOutputMessage)
.
writeToResult
in class AbstractXmlHttpMessageConverter<Object>
o
- the object to write to the output messageheaders
- the HTTP output headersresult
- the HTTP output body
IOException
- in case of I/O errors
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |