类 CompositeMessageConverter
- java.lang.Object
- org.springframework.messaging.converter.CompositeMessageConverter
- 所有已实现的接口:
MessageConverter
,SmartMessageConverter
public class CompositeMessageConverter extends Object implements SmartMessageConverter
AMessageConverter
that delegates to a list of registered converters to be invoked until one of them returns a non-null result.As of 4.2.1, this composite converter implements
SmartMessageConverter
in order to support the delegation of conversion hints.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Juergen Hoeller
构造器概要
构造器 构造器 说明 CompositeMessageConverter(Collection<MessageConverter> converters)
Create an instance with the given converters.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 Object
fromMessage(Message<?> message, Class<?> targetClass)
Convert the payload of aMessage
from a serialized form to a typed Object of the specified target class.Object
fromMessage(Message<?> message, Class<?> targetClass, Object conversionHint)
A variant ofMessageConverter.fromMessage(Message, Class)
which takes an extra conversion context as an argument, allowing to take e.g. annotations on a payload parameter into account.List<MessageConverter>
getConverters()
Return the underlying list of delegate converters.Message<?>
toMessage(Object payload, MessageHeaders headers)
Create aMessage
whose payload is the result of converting the given payload Object to serialized form.Message<?>
toMessage(Object payload, MessageHeaders headers, Object conversionHint)
A variant ofMessageConverter.toMessage(Object, MessageHeaders)
which takes an extra conversion context as an argument, allowing to take e.g. annotations on a return type into account.String
toString()
构造器详细资料
CompositeMessageConverter
public CompositeMessageConverter(Collection<MessageConverter> converters)
Create an instance with the given converters.
方法详细资料
fromMessage
public Object fromMessage(Message<?> message, Class<?> targetClass)
从接口复制的说明:MessageConverter
Convert the payload of aMessage
from a serialized form to a typed Object of the specified target class. TheMessageHeaders.CONTENT_TYPE
header should indicate the MIME type to convert from.If the converter does not support the specified media type or cannot perform the conversion, it should return
null
.- 指定者:
fromMessage
在接口中MessageConverter
- 参数:
message
- the input messagetargetClass
- the target class for the conversion- 返回:
- the result of the conversion, or
null
if the converter cannot perform the conversion
fromMessage
public Object fromMessage(Message<?> message, Class<?> targetClass, Object conversionHint)
从接口复制的说明:SmartMessageConverter
A variant ofMessageConverter.fromMessage(Message, Class)
which takes an extra conversion context as an argument, allowing to take e.g. annotations on a payload parameter into account.- 指定者:
fromMessage
在接口中SmartMessageConverter
- 参数:
message
- the input messagetargetClass
- the target class for the conversionconversionHint
- an extra object passed to theMessageConverter
, e.g. the associatedMethodParameter
(may benull
}- 返回:
- the result of the conversion, or
null
if the converter cannot perform the conversion - 另请参阅:
MessageConverter.fromMessage(Message, Class)
toMessage
public Message<?> toMessage(Object payload, MessageHeaders headers)
从接口复制的说明:MessageConverter
Create aMessage
whose payload is the result of converting the given payload Object to serialized form. The optionalMessageHeaders
parameter may contain aMessageHeaders.CONTENT_TYPE
header to specify the target media type for the conversion and it may contain additional headers to be added to the message.If the converter does not support the specified media type or cannot perform the conversion, it should return
null
.- 指定者:
toMessage
在接口中MessageConverter
- 参数:
payload
- the Object to convertheaders
- optional headers for the message (may benull
)- 返回:
- the new message, or
null
if the converter does not support the Object type or the target media type
toMessage
public Message<?> toMessage(Object payload, MessageHeaders headers, Object conversionHint)
从接口复制的说明:SmartMessageConverter
A variant ofMessageConverter.toMessage(Object, MessageHeaders)
which takes an extra conversion context as an argument, allowing to take e.g. annotations on a return type into account.- 指定者:
toMessage
在接口中SmartMessageConverter
- 参数:
payload
- the Object to convertheaders
- optional headers for the message (may benull
)conversionHint
- an extra object passed to theMessageConverter
, e.g. the associatedMethodParameter
(may benull
}- 返回:
- the new message, or
null
if the converter does not support the Object type or the target media type - 另请参阅:
MessageConverter.toMessage(Object, MessageHeaders)
getConverters
public List<MessageConverter> getConverters()
Return the underlying list of delegate converters.