Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.http.converter.xml
Class MarshallingHttpMessageConverter

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

All Implemented Interfaces:
  HttpMessageConverter<java.lang.Object>

    public class MarshallingHttpMessageConverter

extends AbstractXmlHttpMessageConverter<java.lang.Object>

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.

Since:
  3.0
Author:
  Arjen Poutsma

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 java.lang.Object` | `readFromSource(java.lang.Class<?> clazz, HttpHeaders headers, javax.xml.transform.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(java.lang.Class<?> clazz)` Indicates whether the given class is supported by this converter.
`protected void` | `writeToResult(java.lang.Object o, HttpHeaders headers, javax.xml.transform.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, getContentLength, 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

### MarshallingHttpMessageConverter

    public MarshallingHttpMessageConverter()

  Construct a new `MarshallingHttpMessageConverter` with no `Marshaller` or `Unmarshaller` set. The Marshaller and Unmarshaller must be set after construction by invoking `setMarshaller(Marshaller)` and `setUnmarshaller(Unmarshaller)` .

### MarshallingHttpMessageConverter

    public MarshallingHttpMessageConverter(Marshaller marshaller)

  Construct a new `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.

  Parameters:
    `marshaller` - object used as marshaller and unmarshaller

### MarshallingHttpMessageConverter

    public MarshallingHttpMessageConverter(Marshaller marshaller,
                                           Unmarshaller unmarshaller)

  Construct a new `MarshallingMessageConverter` with the given `Marshaller` and `Unmarshaller`.

  Parameters:
    `marshaller` - the Marshaller to use
    `unmarshaller` - the Unmarshaller to use

Method Detail

### setMarshaller

    public void setMarshaller(Marshaller marshaller)

  Set the `Marshaller` to be used by this message converter.

### setUnmarshaller

    public void setUnmarshaller(Unmarshaller unmarshaller)

  Set the `Unmarshaller` to be used by this message converter.

### 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<java.lang.Object>`
  Parameters:
    `clazz` - the class to test for support
  Returns:
    `true` if supported; `false` otherwise

### readFromSource

    protected java.lang.Object 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<java.lang.Object>`
  Parameters:
    `clazz` - the type of object to return
    `headers` - the HTTP input headers
    `source` - the HTTP input body
  Returns:
    the converted object
  Throws:
    `java.io.IOException` - in case of I/O errors

### writeToResult

    protected void writeToResult(java.lang.Object o,
                                 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<java.lang.Object>`
  Parameters:
    `o` - the object to write to the output message
    `headers` - the HTTP output headers
    `result` - the HTTP output body
  Throws:
    `java.io.IOException` - in case of I/O errors

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD