类 SimpleMessageConverter

  • 所有已实现的接口:
    MessageConverter
    直接已知子类:
    GenericMessageConverter

    public class SimpleMessageConverter
    extends Object
    implements MessageConverter
    A simple converter that simply unwraps the message payload as long as it matches the expected target class. Or reversely, simply wraps the payload in a message.

    Note that this converter ignores any content type information that may be present in message headers and should not be used if payload conversion is actually required.

    从以下版本开始:
    4.0
    作者:
    Rossen Stoyanchev
    • 方法详细资料

      • fromMessage

        @Nullable
        public Object fromMessage​(Message<?> message,
                                  Class<?> targetClass)
        从接口复制的说明: MessageConverter
        Convert the payload of a Message from a serialized form to a typed Object of the specified target class. The MessageHeaders.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 message
        targetClass - the target class for the conversion
        返回:
        the result of the conversion, or null if the converter cannot perform the conversion
      • toMessage

        public Message<?> toMessage​(Object payload,
                                    @Nullable
                                    MessageHeaders headers)
        从接口复制的说明: MessageConverter
        Create a Message whose payload is the result of converting the given payload Object to serialized form. The optional MessageHeaders parameter may contain a MessageHeaders.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 convert
        headers - optional headers for the message (may be null)
        返回:
        the new message, or null if the converter does not support the Object type or the target media type