Class StringMessageConverter
- All Implemented Interfaces:
MessageConverter
A MessageConverter implementation that returns the message as-is for String types. It is expected that the message is already a string. Otherwise, an IllegalArgumentException is thrown.
This converter should not be used for more complex applications.
Use Jackson2MessageConverter, Jackson3MessageConverter or provide your own
implementation of MessageConverter instead.
This message converter always uses the content type "text/plain;charset=UTF-8".
- Since:
- 1.0.0
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the content type associated with this message converter.convertToString(Object object) Converts the given object to its String representation.<T> TconvertToType(String messageStr, Class<T> targetType) Converts the given message string to the specified target type.
-
Constructor Details
-
StringMessageConverter
public StringMessageConverter()Creates a new StringMessageConverter.- Since:
- 1.0.0
-
-
Method Details
-
convertToType
Description copied from interface:MessageConverterConverts the given message string to the specified target type.- Specified by:
convertToTypein interfaceMessageConverter- Type Parameters:
T- the target type- Parameters:
messageStr- the message in String formattargetType- the desired target type class- Returns:
- the converted message object of the specified target type
-
convertToString
Description copied from interface:MessageConverterConverts the given object to its String representation.
The string must be UTF-8 encoded.
- Specified by:
convertToStringin interfaceMessageConverter- Parameters:
object- the object to convert- Returns:
- the String representation of the object
-
contentType
Description copied from interface:MessageConverterReturns the content type associated with this message converter. This content type is used in STOMP message headers to indicate the format of the message body.
This is typically a MIME type, such as
text/plain;charset=UTF-8orapplication/json;charset=UTF-8.- Specified by:
contentTypein interfaceMessageConverter- Returns:
- the content type as a String
-