Package org.apache.kafka.connect.storage
Class SimpleHeaderConverter
- java.lang.Object
-
- org.apache.kafka.connect.storage.SimpleHeaderConverter
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Configurable
,HeaderConverter
public class SimpleHeaderConverter extends Object implements HeaderConverter
AHeaderConverter
that serializes header values as strings and that deserializes header values to the most appropriate numeric, boolean, array, or map representation. Schemas are not serialized, but are inferred upon deserialization when possible.
-
-
Constructor Summary
Constructors Constructor Description SimpleHeaderConverter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
ConfigDef
config()
Configuration specification for this set of header converters.void
configure(Map<String,?> configs)
Configure this class with the given key-value pairsbyte[]
fromConnectHeader(String topic, String headerKey, Schema schema, Object value)
SchemaAndValue
toConnectHeader(String topic, String headerKey, byte[] value)
Convert the header name and byte array value into aHeader
object.
-
-
-
Method Detail
-
config
public ConfigDef config()
Description copied from interface:HeaderConverter
Configuration specification for this set of header converters.- Specified by:
config
in interfaceHeaderConverter
- Returns:
- the configuration specification; may not be null
-
configure
public void configure(Map<String,?> configs)
Description copied from interface:Configurable
Configure this class with the given key-value pairs- Specified by:
configure
in interfaceConfigurable
-
toConnectHeader
public SchemaAndValue toConnectHeader(String topic, String headerKey, byte[] value)
Description copied from interface:HeaderConverter
Convert the header name and byte array value into aHeader
object.- Specified by:
toConnectHeader
in interfaceHeaderConverter
- Parameters:
topic
- 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 null- Returns:
- the
SchemaAndValue
; may not be null
-
fromConnectHeader
public byte[] fromConnectHeader(String topic, String headerKey, Schema schema, Object value)
Description copied from interface:HeaderConverter
- Specified by:
fromConnectHeader
in interfaceHeaderConverter
- Parameters:
topic
- 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 null- Returns:
- the byte array form of the Header's value; may be null if the value is null
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
-