public class StringConverter extends java.lang.Object implements Converter
Converter
implementation that only supports serializing to strings. When converting Kafka Connect data to bytes,
the schema will be ignored and Object.toString()
will always be invoked to convert the data to a String.
When converting from bytes to Kafka Connect format, the converter will only ever return an optional string schema and
a string or null.
Encoding configuration is identical to StringSerializer
and StringDeserializer
, but for convenience
this class can also be configured to use the same encoding for both encoding and decoding with the converter.encoding
setting.Constructor and Description |
---|
StringConverter() |
Modifier and Type | Method and Description |
---|---|
void |
configure(java.util.Map<java.lang.String,?> configs,
boolean isKey)
Configure this class.
|
byte[] |
fromConnectData(java.lang.String topic,
Schema schema,
java.lang.Object value)
Convert a Kafka Connect data object to a native object for serialization.
|
SchemaAndValue |
toConnectData(java.lang.String topic,
byte[] value)
Convert a native object to a Kafka Connect data object.
|
public void configure(java.util.Map<java.lang.String,?> configs, boolean isKey)
Converter
public byte[] fromConnectData(java.lang.String topic, Schema schema, java.lang.Object value)
Converter
fromConnectData
in interface Converter
topic
- the topic associated with the dataschema
- the schema for the valuevalue
- the value to convertpublic SchemaAndValue toConnectData(java.lang.String topic, byte[] value)
Converter
toConnectData
in interface Converter
topic
- the topic associated with the datavalue
- the value to convertSchema
and the converted value