java.io.Closeable, java.lang.AutoCloseable, Configurable, Converter, HeaderConverterpublic class StringConverter extends java.lang.Object implements Converter, HeaderConverter
Converter and HeaderConverter 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.
This implementation currently does nothing with the topic names or header names.| Constructor | Description |
|---|---|
StringConverter() |
| Modifier and Type | Method | Description |
|---|---|---|
void |
close() |
|
ConfigDef |
config() |
Configuration specification for this set of header converters.
|
void |
configure(java.util.Map<java.lang.String,?> configs) |
Configure this class with the given key-value pairs
|
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.
|
byte[] |
fromConnectHeader(java.lang.String topic,
java.lang.String headerKey,
Schema schema,
java.lang.Object value) |
|
SchemaAndValue |
toConnectData(java.lang.String topic,
byte[] value) |
Convert a native object to a Kafka Connect data object.
|
SchemaAndValue |
toConnectHeader(java.lang.String topic,
java.lang.String headerKey,
byte[] value) |
Convert the header name and byte array value into a
Header object. |
public ConfigDef config()
HeaderConverterconfig in interface HeaderConverterpublic void configure(java.util.Map<java.lang.String,?> configs)
Configurableconfigure in interface Configurablepublic void configure(java.util.Map<java.lang.String,?> configs,
boolean isKey)
Converterpublic byte[] fromConnectData(java.lang.String topic,
Schema schema,
java.lang.Object value)
ConverterfromConnectData in interface Convertertopic - the topic associated with the dataschema - the schema for the valuevalue - the value to convertpublic SchemaAndValue toConnectData(java.lang.String topic, byte[] value)
ConvertertoConnectData in interface Convertertopic - the topic associated with the datavalue - the value to convertSchema and the converted valuepublic byte[] fromConnectHeader(java.lang.String topic,
java.lang.String headerKey,
Schema schema,
java.lang.Object value)
HeaderConverterfromConnectHeader in interface HeaderConvertertopic - the name of the topic for the record containing the headerheaderKey - the header's key; may not be nullschema - the schema for the header's value; may be nullvalue - the header's value to convert; may be nullpublic SchemaAndValue toConnectHeader(java.lang.String topic, java.lang.String headerKey, byte[] value)
HeaderConverterHeader object.toConnectHeader in interface HeaderConvertertopic - the name of the topic for the record containing the headerheaderKey - the header's key; may not be nullvalue - the header's raw value; may be nullSchemaAndValue; may not be nullpublic void close()
close in interface java.lang.AutoCloseableclose in interface java.io.Closeable