public class

Jaxb2RootElementHttpMessageConverter

extends AbstractJaxb2HttpMessageConverter<T>
java.lang.Object
   ↳ org.springframework.http.converter.AbstractHttpMessageConverter<T>
     ↳ org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter<T>
       ↳ org.springframework.http.converter.xml.AbstractJaxb2HttpMessageConverter<T>
         ↳ org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter

Class Overview

Implementation of HttpMessageConverter that can read and write XML using JAXB2.

This converter can read classes annotated with XmlRootElement and XmlType, and write classes annotated with with XmlRootElement, or subclasses thereof.

Summary

[Expand]
Inherited Fields
From class org.springframework.http.converter.AbstractHttpMessageConverter
Public Constructors
Jaxb2RootElementHttpMessageConverter()
Public Methods
boolean canRead(Class<?> clazz, MediaType mediaType)
Indicates whether the given class can be read by this converter.

This implementation checks if the given class is supported, and if the supported media types include the given media type.

boolean canWrite(Class<?> clazz, MediaType mediaType)
Indicates whether the given class can be written by this converter.

This implementation checks if the given class is supported, and if the supported media types include the given media type.

Protected Methods
Object readFromSource(Class<?> clazz, HttpHeaders headers, Source source)
Abstract template method called from read(Class, HttpInputMessage).
boolean supports(Class<?> clazz)
Indicates whether the given class is supported by this converter.
void writeToResult(Object o, HttpHeaders headers, Result result)
Abstract template method called from writeInternal(Object, HttpOutputMessage).
[Expand]
Inherited Methods
From class org.springframework.http.converter.xml.AbstractJaxb2HttpMessageConverter
From class org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter
From class org.springframework.http.converter.AbstractHttpMessageConverter
From class java.lang.Object
From interface org.springframework.http.converter.HttpMessageConverter

Public Constructors

public Jaxb2RootElementHttpMessageConverter ()

Public Methods

public boolean canRead (Class<?> clazz, MediaType mediaType)

Indicates whether the given class can be read by this converter.

This implementation checks if the given class is supported, and if the supported media types include the given media type.

Parameters
clazz the class to test for readability
mediaType the media type to read, can be null if not specified. Typically the value of a Content-Type header.
Returns
  • true if readable; false otherwise

public boolean canWrite (Class<?> clazz, MediaType mediaType)

Indicates whether the given class can be written by this converter.

This implementation checks if the given class is supported, and if the supported media types include the given media type.

Parameters
clazz the class to test for writability
mediaType the media type to write, can be null if not specified. Typically the value of an Accept header.
Returns
  • true if writable; false otherwise

Protected Methods

protected Object readFromSource (Class<?> clazz, HttpHeaders headers, Source source)

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

Parameters
clazz the type of object to return
headers the HTTP input headers
source the HTTP input body
Returns
  • the converted object
Throws
IOException

protected boolean supports (Class<?> clazz)

Indicates whether the given class is supported by this converter.

Parameters
clazz the class to test for support
Returns
  • true if supported; false otherwise

protected void writeToResult (Object o, HttpHeaders headers, Result result)

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

Parameters
o the object to write to the output message
headers the HTTP output headers
result the HTTP output body
Throws
IOException