Class StringMessageConverter
- java.lang.Object
- org.springframework.messaging.converter.AbstractMessageConverter
- org.springframework.messaging.converter.StringMessageConverter
- All Implemented Interfaces:
MessageConverter,SmartMessageConverter
public class StringMessageConverter extends AbstractMessageConverter
AMessageConverterthat supports MIME type "text/plain" with the payload converted to and from a String.- Since:
- 4.0
- Author:
- Rossen Stoyanchev
Field Summary
Fields inherited from class org.springframework.messaging.converter.AbstractMessageConverter
logger
Constructor Summary
Constructors Constructor Description StringMessageConverter()StringMessageConverter(Charset defaultCharset)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ObjectconvertFromInternal(Message<?> message, Class<?> targetClass, Object conversionHint)Convert the message payload from serialized form to an Object.protected ObjectconvertToInternal(Object payload, MessageHeaders headers, Object conversionHint)Convert the payload object to serialized form.protected booleansupports(Class<?> clazz)Whether the given class is supported by this converter.Methods inherited from class org.springframework.messaging.converter.AbstractMessageConverter
addSupportedMimeTypes, canConvertFrom, canConvertTo, fromMessage, fromMessage, getContentTypeResolver, getDefaultContentType, getMimeType, getSerializedPayloadClass, getSupportedMimeTypes, isStrictContentTypeMatch, setContentTypeResolver, setSerializedPayloadClass, setStrictContentTypeMatch, supportsMimeType, toMessage, toMessage
Constructor Detail
StringMessageConverter
public StringMessageConverter()
StringMessageConverter
public StringMessageConverter(Charset defaultCharset)
Method Detail
supports
protected boolean supports(Class<?> clazz)
Description copied from class:AbstractMessageConverterWhether the given class is supported by this converter.- Specified by:
supportsin classAbstractMessageConverter- Parameters:
clazz- the class to test for support- Returns:
trueif supported;falseotherwise
convertFromInternal
protected Object convertFromInternal(Message<?> message, Class<?> targetClass, @Nullable Object conversionHint)
Description copied from class:AbstractMessageConverterConvert the message payload from serialized form to an Object.- Overrides:
convertFromInternalin classAbstractMessageConverter- Parameters:
message- the input messagetargetClass- the target class for the conversionconversionHint- an extra object passed to theMessageConverter, e.g. the associatedMethodParameter(may benull}- Returns:
- the result of the conversion, or
nullif the converter cannot perform the conversion
convertToInternal
@Nullable protected Object convertToInternal(Object payload, @Nullable MessageHeaders headers, @Nullable Object conversionHint)
Description copied from class:AbstractMessageConverterConvert the payload object to serialized form.- Overrides:
convertToInternalin classAbstractMessageConverter- Parameters:
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}- Returns:
- the resulting payload for the message, or
nullif the converter cannot perform the conversion