Package com.solace.serdes
Class StringSerializer
- java.lang.Object
-
- com.solace.serdes.StringSerializer
-
- All Implemented Interfaces:
Serializer<String>
,Closeable
,AutoCloseable
public class StringSerializer extends Object implements Serializer<String>
A serializer for converting strings to byte[] using a specified character encoding.
-
-
Field Summary
Fields Modifier and Type Field Description static String
SOLACE_SERIALIZER_STRING_ENCODING
-
Constructor Summary
Constructors Constructor Description StringSerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configure(Map<String,?> properties)
Configures thisStringSerializer
with the given properties.byte[]
serialize(String destinationName, String data)
Serializes the given string data to byte[] using the configured character encoding.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.solace.serdes.Serializer
close, serialize
-
-
-
-
Field Detail
-
SOLACE_SERIALIZER_STRING_ENCODING
public static final String SOLACE_SERIALIZER_STRING_ENCODING
- See Also:
- Constant Field Values
-
-
Method Detail
-
configure
public void configure(Map<String,?> properties)
Configures thisStringSerializer
with the given properties.NOTE: The default encoding is UTF-8.
- Specified by:
configure
in interfaceSerializer<String>
- Parameters:
properties
- a map of configuration properties- Throws:
IllegalArgumentException
- if the charset encoding type is unsupported or the specified charset is unsupported, or when properties is null.
-
serialize
public byte[] serialize(String destinationName, String data)
Serializes the given string data to byte[] using the configured character encoding.NOTE: The default encoding is UTF-8.
- Specified by:
serialize
in interfaceSerializer<String>
- Parameters:
destinationName
- the name of the destination (not used in this implementation)data
- the string data to serialize- Returns:
- the serialized byte[], or null if the input data is null
-
-