Class StringSerializer
- java.lang.Object
-
- org.apache.kafka.common.serialization.StringSerializer
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Serializer<String>
public class StringSerializer extends Object implements Serializer<String>
String encoding defaults to UTF8 and can be customized by setting the property key.serializer.encoding, value.serializer.encoding or serializer.encoding. The first two take precedence over the last.
-
-
Constructor Summary
Constructors Constructor Description StringSerializer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
configure(Map<String,?> configs, boolean isKey)
Configure this class.byte[]
serialize(String topic, String data)
Convertdata
into a byte array.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.kafka.common.serialization.Serializer
close, serialize
-
-
-
-
Method Detail
-
configure
public void configure(Map<String,?> configs, boolean isKey)
Description copied from interface:Serializer
Configure this class.- Specified by:
configure
in interfaceSerializer<String>
- Parameters:
configs
- configs in key/value pairsisKey
- whether is for key or value
-
serialize
public byte[] serialize(String topic, String data)
Description copied from interface:Serializer
Convertdata
into a byte array.- Specified by:
serialize
in interfaceSerializer<String>
- Parameters:
topic
- topic associated with datadata
- typed data- Returns:
- serialized bytes
-
-