AbstractMessageConverter

Abstract base class for {@link SmartMessageConverter} implementations including support for common properties and a partial implementation of the conversion methods, mainly to check if the converter supports the conversion based on the payload class and MIME type.

@author Rossen Stoyanchev @author Sebastien Deleuze @author Juergen Hoeller @since 4.0

Constructors

this
this(MimeType supportedMimeType)

Construct an {@code AbstractMessageConverter} supporting a single MIME type. @param supportedMimeType the supported MIME type

this
this(MimeType[] supportedMimeTypes)

Construct an {@code AbstractMessageConverter} supporting multiple MIME types. @param supportedMimeTypes the supported MIME types

Members

Functions

canConvertFrom
bool canConvertFrom(MessageBase message, TypeInfo targetClass)
Undocumented in source. Be warned that the author may not have intended to support it.
canConvertTo
bool canConvertTo(Object payload, MessageHeaders headers, TypeInfo conversionHint)
Undocumented in source. Be warned that the author may not have intended to support it.
convertFromInternal
Object convertFromInternal(MessageBase message, TypeInfo targetClass, TypeInfo conversionHint)

Convert the message payload from serialized form to an Object. @param message the input message @param targetClass the target class for the conversion @param conversionHint an extra object passed to the {@link MessageConverter}, e.g. the associated {@code MethodParameter} (may be {@code null}} @return the result of the conversion, or {@code null} if the converter cannot perform the conversion @since 4.2

convertToInternal
Object convertToInternal(Object payload, MessageHeaders headers, TypeInfo conversionHint)

Convert the payload object to serialized form. @param payload the Object to convert @param headers optional headers for the message (may be {@code null}) @param conversionHint an extra object passed to the {@link MessageConverter}, e.g. the associated {@code MethodParameter} (may be {@code null}} @return the resulting payload for the message, or {@code null} if the converter cannot perform the conversion @since 4.2

fromMessage
Object fromMessage(MessageBase message, TypeInfo targetClass)
Undocumented in source. Be warned that the author may not have intended to support it.
fromMessage
Object fromMessage(MessageBase message, TypeInfo targetClass, TypeInfo conversionHint)
Undocumented in source. Be warned that the author may not have intended to support it.
getContentTypeResolver
ContentTypeResolver getContentTypeResolver()

Return the configured {@link ContentTypeResolver}.

getDefaultContentType
MimeType getDefaultContentType(Object payload)

Returns the default content type for the payload. Called when {@link #toMessage(Object, MessageHeaders)} is invoked without message headers or without a content type header. <p>By default, this returns the first element of the {@link #getSupportedMimeTypes() supportedMimeTypes}, if any. Can be overridden in sub-classes. @param payload the payload being converted to message @return the content type, or {@code null} if not known

getMimeType
MimeType getMimeType(MessageHeaders headers)
Undocumented in source. Be warned that the author may not have intended to support it.
getSupportedMimeTypes
MimeType[] getSupportedMimeTypes()

Return the supported MIME types.

isStrictContentTypeMatch
bool isStrictContentTypeMatch()

Whether content type resolution must produce a value that matches one of the supported MIME types.

setContentTypeResolver
void setContentTypeResolver(ContentTypeResolver resolver)

Configure the {@link ContentTypeResolver} to use to resolve the content type of an input message. <p>Note that if no resolver is configured, then {@link #setStrictContentTypeMatch() strictContentTypeMatch} should be left as {@code false} (the default) or otherwise this converter will ignore all messages. <p>By default, a {@code DefaultContentTypeResolver} instance is used.

setStrictContentTypeMatch
void setStrictContentTypeMatch(bool strictContentTypeMatch)

Whether this converter should convert messages for which no content type could be resolved through the configured {@link hunt.stomp.converter.ContentTypeResolver}. <p>A converter can configured to be strict only when a {@link #setContentTypeResolver contentTypeResolver} is configured and the list of {@link #getSupportedMimeTypes() supportedMimeTypes} is not be empty. <p>When this flag is set to {@code true}, {@link #supportsMimeType(MessageHeaders)} will return {@code false} if the {@link #setContentTypeResolver contentTypeResolver} is not defined or if no content-type header is present.

supports
bool supports(TypeInfo typeInfo)

Whether the given class is supported by this converter. @param clazz the class to test for support @return {@code true} if supported; {@code false} otherwise

supportsMimeType
bool supportsMimeType(MessageHeaders headers)
Undocumented in source. Be warned that the author may not have intended to support it.
toMessage
MessageBase toMessage(Object payload, MessageHeaders headers)
Undocumented in source. Be warned that the author may not have intended to support it.
toMessage
MessageBase toMessage(Object payload, MessageHeaders headers, TypeInfo conversionHint)
Undocumented in source. Be warned that the author may not have intended to support it.

Inherited Members

From SmartMessageConverter

fromMessage
Object fromMessage(MessageBase message, TypeInfo targetClass, TypeInfo conversionHint)

A variant of {@link #fromMessage(Message, Class)} which takes an extra conversion context as an argument, allowing to take e.g. annotations on a payload parameter into account. @param message the input message @param targetClass the target class for the conversion @param conversionHint an extra object passed to the {@link MessageConverter}, e.g. the associated {@code MethodParameter} (may be {@code null}} @return the result of the conversion, or {@code null} if the converter cannot perform the conversion @see #fromMessage(Message, Class)

fromMessage
alias fromMessage = MessageConverter.fromMessage
Undocumented in source.
toMessage
MessageBase toMessage(Object payload, MessageHeaders headers, TypeInfo conversionHint)

A variant of {@link #toMessage(Object, MessageHeaders)} which takes an extra conversion context as an argument, allowing to take e.g. annotations on a return type into account. @param payload the Object to convert @param headers optional headers for the message (may be {@code null}) @param conversionHint an extra object passed to the {@link MessageConverter}, e.g. the associated {@code MethodParameter} (may be {@code null}} @return the new message, or {@code null} if the converter does not support the Object type or the target media type @see #toMessage(Object, MessageHeaders)

toMessage
alias toMessage = MessageConverter.toMessage
Undocumented in source.

Meta