StringMessageConverter

A {@link MessageConverter} that supports MIME type "text/plain" with the payload converted to and from a string.

@author Rossen Stoyanchev @since 4.0

Constructors

this
this()
Undocumented in source.
this
this(Charset defaultCharset)
Undocumented in source.

Members

Functions

supports
bool supports(TypeInfo typeInfo)
Undocumented in source. Be warned that the author may not have intended to support it.

Inherited Members

From AbstractMessageConverter

getSupportedMimeTypes
MimeType[] getSupportedMimeTypes()

Return 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.

getContentTypeResolver
ContentTypeResolver getContentTypeResolver()

Return the configured {@link ContentTypeResolver}.

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.

isStrictContentTypeMatch
bool isStrictContentTypeMatch()

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

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

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.
canConvertFrom
bool canConvertFrom(MessageBase message, TypeInfo targetClass)
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.
canConvertTo
bool canConvertTo(Object payload, MessageHeaders headers, TypeInfo conversionHint)
Undocumented in source. Be warned that the author may not have intended to support it.
supportsMimeType
bool supportsMimeType(MessageHeaders headers)
Undocumented in source. Be warned that the author may not have intended to support it.
getMimeType
MimeType getMimeType(MessageHeaders headers)
Undocumented in source. Be warned that the author may not have intended to support it.
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

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

Meta