Class Jaxb2RootElementHttpMessageConverter
java.lang.Object
org.springframework.http.converter.AbstractHttpMessageConverter<T>
org.springframework.http.converter.xml.AbstractXmlHttpMessageConverter<T>
org.springframework.http.converter.xml.AbstractJaxb2HttpMessageConverter<Object>
org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter
- All Implemented Interfaces:
- HttpMessageConverter<Object>
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 XmlRootElement,
 or subclasses thereof.
 
Note: When using Spring's Marshaller/Unmarshaller abstractions from spring-oxm,
 you should use the MarshallingHttpMessageConverter instead.
- Since:
- 3.0
- Author:
- Arjen Poutsma, Sebastien Deleuze, Rossen Stoyanchev
- See Also:
- 
Field SummaryFields inherited from class org.springframework.http.converter.AbstractHttpMessageConverterlogger
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanThis implementation checks if the given class is supported, and if the supported media types include the given media type.booleanbooleanReturn whether XML external entities are allowed.booleanReturn whether DTD parsing is supported.protected SourceprocessSource(Source source) protected ObjectreadFromSource(Class<?> clazz, HttpHeaders headers, Source source) Abstract template method called fromAbstractHttpMessageConverter.read(Class, HttpInputMessage).voidsetProcessExternalEntities(boolean processExternalEntities) Indicate whether external XML entities are processed when converting to a Source.voidsetSupportDtd(boolean supportDtd) Indicate whether DTD parsing should be supported.protected booleanIndicates whether the given class is supported by this converter.protected voidwriteToResult(Object o, HttpHeaders headers, Result result) Abstract template method called fromAbstractXmlHttpMessageConverter.writeInternal(Object, HttpOutputMessage).Methods inherited from class org.springframework.http.converter.xml.AbstractJaxb2HttpMessageConvertercreateMarshaller, createUnmarshaller, customizeMarshaller, customizeUnmarshaller, getJaxbContextMethods inherited from class org.springframework.http.converter.xml.AbstractXmlHttpMessageConverterreadInternal, transform, writeInternalMethods inherited from class org.springframework.http.converter.AbstractHttpMessageConverteraddDefaultHeaders, canRead, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, writeMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.http.converter.HttpMessageConvertergetSupportedMediaTypes
- 
Constructor Details- 
Jaxb2RootElementHttpMessageConverterpublic Jaxb2RootElementHttpMessageConverter()
 
- 
- 
Method Details- 
setSupportDtdpublic void setSupportDtd(boolean supportDtd) Indicate whether DTD parsing should be supported.Default is falsemeaning that DTD is disabled.
- 
isSupportDtdpublic boolean isSupportDtd()Return whether DTD parsing is supported.
- 
setProcessExternalEntitiespublic void setProcessExternalEntities(boolean processExternalEntities) Indicate whether external XML entities are processed when converting to a Source.Default is false, meaning that external entities are not resolved.Note: setting this option to truealso automatically setssetSupportDtd(boolean)totrue.
- 
isProcessExternalEntitiespublic boolean isProcessExternalEntities()Return whether XML external entities are allowed.
- 
canReadDescription copied from class:AbstractHttpMessageConverterThis implementation checks if the given class is supported, and if the supported media types include the given media type.- Specified by:
- canReadin interface- HttpMessageConverter<Object>
- Overrides:
- canReadin class- AbstractHttpMessageConverter<Object>
- Parameters:
- clazz- the class to test for readability
- mediaType- the media type to read (can be- nullif not specified); typically the value of a- Content-Typeheader.
- Returns:
- trueif readable;- falseotherwise
 
- 
canWriteDescription copied from class:AbstractHttpMessageConverterThis implementation checks if the given class is supported, and if the supported media types include the given media type.- Specified by:
- canWritein interface- HttpMessageConverter<Object>
- Overrides:
- canWritein class- AbstractHttpMessageConverter<Object>
- Parameters:
- clazz- the class to test for writability
- mediaType- the media type to write (can be- nullif not specified); typically the value of an- Acceptheader.
- Returns:
- trueif writable;- falseotherwise
 
- 
supportsDescription copied from class:AbstractHttpMessageConverterIndicates whether the given class is supported by this converter.- Specified by:
- supportsin class- AbstractHttpMessageConverter<Object>
- Parameters:
- clazz- the class to test for support
- Returns:
- trueif supported;- falseotherwise
 
- 
readFromSourceprotected Object readFromSource(Class<?> clazz, HttpHeaders headers, Source source) throws Exception Description copied from class:AbstractXmlHttpMessageConverterAbstract template method called fromAbstractHttpMessageConverter.read(Class, HttpInputMessage).- Specified by:
- readFromSourcein class- AbstractXmlHttpMessageConverter<Object>
- Parameters:
- clazz- the type of object to return
- headers- the HTTP input headers
- source- the HTTP input body
- Returns:
- the converted object
- Throws:
- Exception- in case of I/O or conversion errors
 
- 
processSource
- 
writeToResultDescription copied from class:AbstractXmlHttpMessageConverterAbstract template method called fromAbstractXmlHttpMessageConverter.writeInternal(Object, HttpOutputMessage).- Specified by:
- writeToResultin class- AbstractXmlHttpMessageConverter<Object>
- Parameters:
- o- the object to write to the output message
- headers- the HTTP output headers
- result- the HTTP output body
- Throws:
- Exception- in case of I/O or conversion errors
 
 
-