类 MarshallingHttpMessageConverter
java.lang.Object
cn.taketoday.http.converter.AbstractHttpMessageConverter<T>
cn.taketoday.http.converter.xml.AbstractXmlHttpMessageConverter<Object>
cn.taketoday.http.converter.xml.MarshallingHttpMessageConverter
- 所有已实现的接口:
HttpMessageConverter<Object>
Implementation of
HttpMessageConverter
that can read and write XML using Infra 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.
- 从以下版本开始:
- 4.0
- 作者:
- Arjen Poutsma
-
字段概要
字段修饰符和类型字段说明private cn.taketoday.oxm.Marshallerprivate cn.taketoday.oxm.Unmarshaller从类继承的字段 cn.taketoday.http.converter.AbstractHttpMessageConverter
logger -
构造器概要
构造器构造器说明Construct a newMarshallingHttpMessageConverterwith noMarshallerorUnmarshallerset.MarshallingHttpMessageConverter(cn.taketoday.oxm.Marshaller marshaller) Construct a newMarshallingMessageConverterwith the givenMarshallerset.MarshallingHttpMessageConverter(cn.taketoday.oxm.Marshaller marshaller, cn.taketoday.oxm.Unmarshaller unmarshaller) Construct a newMarshallingMessageConverterwith the givenMarshallerandUnmarshaller. -
方法概要
修饰符和类型方法说明booleanThis implementation checks if the given class is supported, and if the supported media types include the given media type.booleanprotected ObjectreadFromSource(Class<?> clazz, HttpHeaders headers, Source source) Abstract template method called fromAbstractHttpMessageConverter.read(Class, HttpInputMessage).voidsetMarshaller(cn.taketoday.oxm.Marshaller marshaller) Set theMarshallerto be used by this message converter.voidsetUnmarshaller(cn.taketoday.oxm.Unmarshaller unmarshaller) Set theUnmarshallerto be used by this message converter.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).从类继承的方法 cn.taketoday.http.converter.xml.AbstractXmlHttpMessageConverter
readInternal, transform, writeInternal从类继承的方法 cn.taketoday.http.converter.AbstractHttpMessageConverter
addDefaultHeaders, canRead, canWrite, getContentLength, getDefaultCharset, getDefaultContentType, getSupportedMediaTypes, read, setDefaultCharset, setSupportedMediaTypes, write从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait从接口继承的方法 cn.taketoday.http.converter.HttpMessageConverter
getSupportedMediaTypes
-
字段详细资料
-
marshaller
@Nullable private cn.taketoday.oxm.Marshaller marshaller -
unmarshaller
@Nullable private cn.taketoday.oxm.Unmarshaller unmarshaller
-
-
构造器详细资料
-
MarshallingHttpMessageConverter
public MarshallingHttpMessageConverter()Construct a newMarshallingHttpMessageConverterwith noMarshallerorUnmarshallerset. The Marshaller and Unmarshaller must be set after construction by invokingsetMarshaller(Marshaller)andsetUnmarshaller(Unmarshaller). -
MarshallingHttpMessageConverter
public MarshallingHttpMessageConverter(cn.taketoday.oxm.Marshaller marshaller) Construct a newMarshallingMessageConverterwith the givenMarshallerset.If the given
Marshalleralso implements theUnmarshallerinterface, it is used for both marshalling and unmarshalling. Otherwise, an exception is thrown.Note that all
Marshallerimplementations in Infra also implement theUnmarshallerinterface, so that you can safely use this constructor.- 参数:
marshaller- object used as marshaller and unmarshaller
-
MarshallingHttpMessageConverter
public MarshallingHttpMessageConverter(cn.taketoday.oxm.Marshaller marshaller, cn.taketoday.oxm.Unmarshaller unmarshaller) Construct a newMarshallingMessageConverterwith the givenMarshallerandUnmarshaller.- 参数:
marshaller- the Marshaller to useunmarshaller- the Unmarshaller to use
-
-
方法详细资料
-
setMarshaller
public void setMarshaller(cn.taketoday.oxm.Marshaller marshaller) Set theMarshallerto be used by this message converter. -
setUnmarshaller
public void setUnmarshaller(cn.taketoday.oxm.Unmarshaller unmarshaller) Set theUnmarshallerto be used by this message converter. -
canRead
从类复制的说明:AbstractHttpMessageConverterThis implementation checks if the given class is supported, and if the supported media types include the given media type.- 指定者:
canRead在接口中HttpMessageConverter<Object>- 覆盖:
canRead在类中AbstractHttpMessageConverter<Object>- 参数:
clazz- the class to test for readabilitymediaType- the media type to read (can benullif not specified); typically the value of aContent-Typeheader.- 返回:
trueif readable;falseotherwise
-
canWrite
从类复制的说明:AbstractHttpMessageConverterThis implementation checks if the given class is supported, and if the supported media types include the given media type.- 指定者:
canWrite在接口中HttpMessageConverter<Object>- 覆盖:
canWrite在类中AbstractHttpMessageConverter<Object>- 参数:
clazz- the class to test for writabilitymediaType- the media type to write (can benullif not specified); typically the value of anAcceptheader.- 返回:
trueif writable;falseotherwise
-
supports
从类复制的说明:AbstractHttpMessageConverterIndicates whether the given class is supported by this converter.- 指定者:
supports在类中AbstractHttpMessageConverter<Object>- 参数:
clazz- the class to test for support- 返回:
trueif supported;falseotherwise
-
readFromSource
protected Object readFromSource(Class<?> clazz, HttpHeaders headers, Source source) throws Exception 从类复制的说明:AbstractXmlHttpMessageConverterAbstract template method called fromAbstractHttpMessageConverter.read(Class, HttpInputMessage).- 指定者:
readFromSource在类中AbstractXmlHttpMessageConverter<Object>- 参数:
clazz- the type of object to returnheaders- the HTTP input headerssource- the HTTP input body- 返回:
- the converted object
- 抛出:
Exception- in case of I/O or conversion errors
-
writeToResult
从类复制的说明:AbstractXmlHttpMessageConverterAbstract template method called fromAbstractXmlHttpMessageConverter.writeInternal(Object, HttpOutputMessage).- 指定者:
writeToResult在类中AbstractXmlHttpMessageConverter<Object>- 参数:
o- the object to write to the output messageheaders- the HTTP output headersresult- the HTTP output body- 抛出:
Exception- in case of I/O or conversion errors
-