Package io.debezium.connector.mysql
Class MySqlDefaultValueConverter
java.lang.Object
io.debezium.connector.mysql.MySqlDefaultValueConverter
- All Implemented Interfaces:
DefaultValueConverter
This class is used by a DDL parser to convert the string default value to a Java type
recognized by value converters for a subset of types. The functionality is kept separate
from the main converters to centralize the formatting logic if necessary.
- Author:
- Jiri Pechanec
- See Also:
-
AbstractRowsEventDataDeserializer
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.debezium.relational.DefaultValueConverter
DefaultValueConverter.DefaultValueMapper
-
Field Summary
Modifier and TypeFieldDescriptionprivate static final Pattern
private final MySqlValueConverters
private static final String
private static final Pattern
private static final Pattern
private static final String
private static final DateTimeFormatter
private static final org.slf4j.Logger
private static final Pattern
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate String
Clean input timestamp to yyyy-mm-dd hh:mm:ss[.fffffffff] formatConverts a default value from the expected format to a logical object acceptable by the main JDBC converter.private Object
convertToBit
(String value) private Object
convertToBits
(Column column, String value) Converts a string object for an expected JDBC type ofTypes.BIT
.private Object
convertToBits
(String value) private Object
convertToBoolean
(String value) Converts a string object for an expected JDBC type ofTypes.BOOLEAN
.private Object
convertToDecimal
(Column column, String value) Converts a string object for an expected JDBC type ofTypes.DECIMAL
.private Object
convertToDouble
(String value) Converts a string object for an expected JDBC type ofTypes.DOUBLE
.private Object
convertToDuration
(Column column, String value) Converts a string object for an object type ofDuration
.private Object
convertToLocalDate
(Column column, String value) Converts a string object for an object type ofLocalDate
orLocalDateTime
in case of MySql Date type.private Object
convertToLocalDateTime
(Column column, String value) Converts a string object for an object type ofLocalDateTime
.private Object
convertToTimestamp
(Column column, String value) Converts a string object for an object type ofTimestamp
.parseDefaultValue
(Column column, String defaultValueExpression) This interface is used by a DDL parser to convert the string default value to a Java type recognized by value converters for a subset of types.private String
replaceFirstNonNumericSubstring
(String s, int startIndex, char c) Replace the first non-numeric substringprivate String
private DateTimeFormatter
timestampFormat
(int length)
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
EPOCH_EQUIVALENT_TIMESTAMP
-
EPOCH_EQUIVALENT_DATE
-
EPOCH_TIMESTAMP
- See Also:
-
EPOCH_DATE
- See Also:
-
TIMESTAMP_PATTERN
-
CHARSET_INTRODUCER_PATTERN
-
TRIM_DATA_TYPES
-
NUMBER_DATA_TYPES
-
ISO_LOCAL_DATE_WITH_OPTIONAL_TIME
-
converters
-
-
Constructor Details
-
MySqlDefaultValueConverter
-
-
Method Details
-
parseDefaultValue
This interface is used by a DDL parser to convert the string default value to a Java type recognized by value converters for a subset of types.- Specified by:
parseDefaultValue
in interfaceDefaultValueConverter
- Parameters:
column
- the column definition describing thedata
value; never nulldefaultValueExpression
- the default value literal; may be null- Returns:
- value converted to a Java type; optional
-
convert
Converts a default value from the expected format to a logical object acceptable by the main JDBC converter.- Parameters:
column
- column definitionvalue
- string formatted default value- Returns:
- value converted to a Java type
-
convertToLocalDate
Converts a string object for an object type ofLocalDate
orLocalDateTime
in case of MySql Date type. If the column definition allows null and default value is 0000-00-00, we need return null; else 0000-00-00 will be replaced with 1970-01-01;- Parameters:
column
- the column definition describing thedata
value; never nullvalue
- the string object to be converted into aLocalDate
type orLocalDateTime
in case of MySql Date type;- Returns:
- the converted value;
-
convertToLocalDateTime
Converts a string object for an object type ofLocalDateTime
. If the column definition allows null and default value is 0000-00-00 00:00:00, we need return null, else 0000-00-00 00:00:00 will be replaced with 1970-01-01 00:00:00;- Parameters:
column
- the column definition describing thedata
value; never nullvalue
- the string object to be converted into aLocalDateTime
type;- Returns:
- the converted value;
-
convertToTimestamp
Converts a string object for an object type ofTimestamp
. If the column definition allows null and default value is 0000-00-00 00:00:00, we need return null, else 0000-00-00 00:00:00 will be replaced with 1970-01-01 00:00:00;- Parameters:
column
- the column definition describing thedata
value; never nullvalue
- the string object to be converted into aTimestamp
type;- Returns:
- the converted value;
-
convertToDuration
Converts a string object for an object type ofDuration
.- Parameters:
column
- the column definition describing thedata
value; never nullvalue
- the string object to be converted into aDuration
type;- Returns:
- the converted value;
-
convertToDouble
Converts a string object for an expected JDBC type ofTypes.DOUBLE
.- Parameters:
value
- the string object to be converted into aTypes.DOUBLE
type;- Returns:
- the converted value;
-
convertToDecimal
Converts a string object for an expected JDBC type ofTypes.DECIMAL
.- Parameters:
column
- the column definition describing thedata
value; never nullvalue
- the string object to be converted into aTypes.DECIMAL
type;- Returns:
- the converted value;
-
convertToBits
Converts a string object for an expected JDBC type ofTypes.BIT
.- Parameters:
column
- the column definition describing thedata
value; never nullvalue
- the string object to be converted into aTypes.BIT
type;- Returns:
- the converted value;
-
convertToBit
-
convertToBits
-
convertToBoolean
Converts a string object for an expected JDBC type ofTypes.BOOLEAN
.- Parameters:
value
- the string object to be converted into aTypes.BOOLEAN
type;- Returns:
- the converted value;
-
timestampFormat
-
cleanTimestamp
Clean input timestamp to yyyy-mm-dd hh:mm:ss[.fffffffff] format- Parameters:
s
- input timestamp- Returns:
- cleaned timestamp
-
replaceFirstNonNumericSubstring
Replace the first non-numeric substring- Parameters:
s
- the original stringstartIndex
- the beginning index, inclusivec
- the new character- Returns:
-
stripCharacterSetIntroducer
-