|
|||||||||
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<T> org.springframework.http.converter.xml.AbstractJaxb2HttpMessageConverter<java.lang.Object> org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter
public class Jaxb2RootElementHttpMessageConverter
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.
Field Summary |
---|
Fields inherited from class org.springframework.http.converter.AbstractHttpMessageConverter |
---|
logger |
Constructor Summary | |
---|---|
Jaxb2RootElementHttpMessageConverter()
|
Method Summary | |
---|---|
boolean |
canRead(java.lang.Class<?> clazz,
MediaType mediaType)
Indicates whether the given class can be read by this converter. |
boolean |
canWrite(java.lang.Class<?> clazz,
MediaType mediaType)
Indicates whether the given class can be written by this converter. |
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) . |
private void |
setCharset(MediaType contentType,
javax.xml.bind.Marshaller marshaller)
|
protected 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.AbstractJaxb2HttpMessageConverter |
---|
createMarshaller, createUnmarshaller, getJaxbContext |
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, read, setSupportedMediaTypes, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Jaxb2RootElementHttpMessageConverter()
Method Detail |
---|
public boolean canRead(java.lang.Class<?> clazz, MediaType mediaType)
AbstractHttpMessageConverter
This implementation checks if the given class is supported, and if the supported media types include the given media type.
canRead
in interface HttpMessageConverter<java.lang.Object>
canRead
in class AbstractHttpMessageConverter<java.lang.Object>
clazz
- the class to test for readabilitymediaType
- the media type to read, can be null
if not specified.
Typically the value of a Content-Type
header.
true
if readable; false
otherwisepublic boolean canWrite(java.lang.Class<?> clazz, MediaType mediaType)
AbstractHttpMessageConverter
This implementation checks if the given class is supported, and if the supported media types include the given media type.
canWrite
in interface HttpMessageConverter<java.lang.Object>
canWrite
in class AbstractHttpMessageConverter<java.lang.Object>
clazz
- the class to test for writabilitymediaType
- the media type to write, can be null
if not specified.
Typically the value of an Accept
header.
true
if writable; false
otherwiseprotected boolean supports(java.lang.Class<?> clazz)
AbstractHttpMessageConverter
supports
in class AbstractHttpMessageConverter<java.lang.Object>
clazz
- the class to test for support
true
if supported; false
otherwiseprotected java.lang.Object readFromSource(java.lang.Class<?> clazz, HttpHeaders headers, javax.xml.transform.Source source) throws java.io.IOException
AbstractXmlHttpMessageConverter
AbstractHttpMessageConverter.read(Class, HttpInputMessage)
.
readFromSource
in class AbstractXmlHttpMessageConverter<java.lang.Object>
clazz
- the type of object to returnheaders
- the HTTP input headerssource
- the HTTP input body
java.io.IOException
- in case of I/O errorsprotected void writeToResult(java.lang.Object o, HttpHeaders headers, javax.xml.transform.Result result) throws java.io.IOException
AbstractXmlHttpMessageConverter
AbstractXmlHttpMessageConverter.writeInternal(Object, HttpOutputMessage)
.
writeToResult
in class AbstractXmlHttpMessageConverter<java.lang.Object>
o
- the object to write to the output messageheaders
- the HTTP output headersresult
- the HTTP output body
java.io.IOException
- in case of I/O errorsprivate void setCharset(MediaType contentType, javax.xml.bind.Marshaller marshaller) throws javax.xml.bind.PropertyException
javax.xml.bind.PropertyException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |