Top Description Fields Constructors Methods
org.springframework.messaging.converter

public Class StringMessageConverter

extends AbstractMessageConverter
Class Inheritance
Imports
java.nio.charset.Charset, .StandardCharsets, org.springframework.lang.Nullable, org.springframework.messaging.Message, .MessageHeaders, org.springframework.util.Assert, .MimeType

A MessageConverter that supports MIME type "text/plain" with the payload converted to and from a String.
Author
Rossen Stoyanchev
Since
4.0

Field Summary

Modifier and TypeField and Description
private final Charset
Inherited from org.springframework.messaging.converter.AbstractMessageConverter:
logger

Constructor Summary

AccessConstructor and Description
public
public

Method Summary

Modifier and TypeMethod and Description
protected Object
convertFromInternal(Message<?>
the input message
message
,
Class<?>
the target class for the conversion
targetClass
,
Object
an extra object passed to the MessageConverter, e.g. the associated MethodParameter (may be null}
conversionHint
)

Overrides org.springframework.messaging.converter.AbstractMessageConverter.convertFromInternal.

Convert the message payload from serialized form to an Object.

protected Object
convertToInternal(Object
the Object to convert
payload
,
MessageHeaders
optional headers for the message (may be null)
headers
,
Object
an extra object passed to the MessageConverter, e.g. the associated MethodParameter (may be null}
conversionHint
)

Overrides org.springframework.messaging.converter.AbstractMessageConverter.convertToInternal.

Convert the payload object to serialized form.

private Charset
protected boolean
supports(Class<?>
the class to test for support
clazz
)

Implements abstract org.springframework.messaging.converter.AbstractMessageConverter.supports.

Whether the given class is supported by this converter.

Inherited from org.springframework.messaging.converter.AbstractMessageConverter:
addSupportedMimeTypescanConvertFromcanConvertTofromMessagefromMessagegetContentTypeResolvergetDefaultContentTypegetMimeTypegetResolvedTypegetSerializedPayloadClassgetSupportedMimeTypesisStrictContentTypeMatchsetContentTypeResolversetSerializedPayloadClasssetStrictContentTypeMatchsupportsMimeTypetoMessagetoMessage

Field Detail

defaultCharsetback to summary
private final Charset defaultCharset

Constructor Detail

StringMessageConverterback to summary
public StringMessageConverter()
StringMessageConverterback to summary
public StringMessageConverter(Charset defaultCharset)

Method Detail

convertFromInternalback to summary
protected Object convertFromInternal(Message<?> message, Class<?> targetClass, Object conversionHint)

Overrides org.springframework.messaging.converter.AbstractMessageConverter.convertFromInternal.

Doc from org.springframework.messaging.converter.AbstractMessageConverter.convertFromInternal.

Convert the message payload from serialized form to an Object.

Parameters
message:Message<?>

the input message

targetClass:Class<?>

the target class for the conversion

conversionHint:Object

an extra object passed to the MessageConverter, e.g. the associated MethodParameter (may be null}

Returns:Object

the result of the conversion, or null if the converter cannot perform the conversion

Annotations
@Override
convertToInternalback to summary
protected Object convertToInternal(Object payload, MessageHeaders headers, Object conversionHint)

Overrides org.springframework.messaging.converter.AbstractMessageConverter.convertToInternal.

Doc from org.springframework.messaging.converter.AbstractMessageConverter.convertToInternal.

Convert the payload object to serialized form.

Parameters
payload:Object

the Object to convert

headers:MessageHeaders

optional headers for the message (may be null)

conversionHint:Object

an extra object passed to the MessageConverter, e.g. the associated MethodParameter (may be null}

Returns:Object

the resulting payload for the message, or null if the converter cannot perform the conversion

Annotations
@Override
@Nullable
getContentTypeCharsetback to summary
private Charset getContentTypeCharset(MimeType mimeType)
supportsback to summary
protected boolean supports(Class<?> clazz)

Implements abstract org.springframework.messaging.converter.AbstractMessageConverter.supports.

Doc from org.springframework.messaging.converter.AbstractMessageConverter.supports.

Whether the given class is supported by this converter.

Parameters
clazz:Class<?>

the class to test for support

Returns:boolean

true if supported; false otherwise

Annotations
@Override