Class AbstractSingleColumnSqlRedoPreambleParser

java.lang.Object
io.debezium.connector.oracle.logminer.parser.AbstractSingleColumnSqlRedoPreambleParser
All Implemented Interfaces:
SingleColumnSqlRedoPreambleParser
Direct Known Subclasses:
AbstractSelectSingleColumnSqlRedoPreambleParser, ExtendedStringParser

public abstract class AbstractSingleColumnSqlRedoPreambleParser extends Object implements SingleColumnSqlRedoPreambleParser
A common abstract base class for SingleColumnSqlRedoPreambleParser implementations.
Author:
Chris Cranford
  • Field Details

  • Constructor Details

    • AbstractSingleColumnSqlRedoPreambleParser

      public AbstractSingleColumnSqlRedoPreambleParser()
  • Method Details

    • getSchemaName

      public String getSchemaName()
      Description copied from interface: SingleColumnSqlRedoPreambleParser
      Get the schema name of the parsed statement.
      Specified by:
      getSchemaName in interface SingleColumnSqlRedoPreambleParser
      Returns:
      the schema name
    • getTableName

      public String getTableName()
      Description copied from interface: SingleColumnSqlRedoPreambleParser
      Get the table name of the parsed statement.
      Specified by:
      getTableName in interface SingleColumnSqlRedoPreambleParser
      Returns:
      the table name
    • getColumnName

      public String getColumnName()
      Description copied from interface: SingleColumnSqlRedoPreambleParser
      Get the name of the parsed column
      Specified by:
      getColumnName in interface SingleColumnSqlRedoPreambleParser
      Returns:
      the column name
    • reset

      protected void reset()
    • parse

      public LogMinerDmlEntry parse(String sql, Table table) throws ParsingException
      Description copied from interface: SingleColumnSqlRedoPreambleParser
      Parses the redo SQL. Must be called before fetching state from the parser.
      Specified by:
      parse in interface SingleColumnSqlRedoPreambleParser
      Parameters:
      sql - the redo SQL to be parsed, can be null
      table - the table the redo SQL is related to, should not be null
      Returns:
      the preamble parse data
      Throws:
      ParsingException - if the parser failed to parse the redo SQL
    • parseInternal

      protected abstract void parseInternal(String sql, Table table)
      An internal parse handler that handles the unique logic per parser implementation.
      Parameters:
      sql - the SQL to be parsed, should not be null
      table - the relational table model, should not be null
    • parseQuotedValue

      protected static int parseQuotedValue(String sql, int index, Consumer<String> collector)
      Parses a quoted SQL value.
      Parameters:
      sql - the SQL to be parsed
      index - the position in the SQL where the parse starts
      collector - the consumer functor to receive the parsed value
      Returns:
      the index where the quoted value token ends
    • parseOperator

      protected int parseOperator(String sql, int index)
      Parses a SQL operator at the specified offset.
      Parameters:
      sql - the SQL to be parsed
      index - the position in the SQL where the operator parse starts
      Returns:
      the index where the operator ends
    • parseColumnValue

      protected int parseColumnValue(String sql, int index, int columnIndex)
      Parses a column value from the given SQL.
      Parameters:
      sql - the SQL to be parsed
      index - the position in the SQL where the column value parsing starts
      columnIndex - the column index position in the columnValues array to populate
      Returns:
      the index where the column value token ends
    • parseWhereClause

      protected int parseWhereClause(String sql, int index, Table table)
      Parses the SQL where-clause
      Parameters:
      sql - the SQL to be parsed
      index - the position in the SQL where the parsing starts
      table - the expected relational table being parsed
      Returns:
      the index where the where-clause parsing ends
    • createDmlEntryForColumnValues

      protected abstract LogMinerDmlEntry createDmlEntryForColumnValues(Object[] columnValues)
      Creates the LogMinerDmlEntry for the column values.
      Parameters:
      columnValues - the column values array
      Returns:
      the DML entry that represents the parsed statement
    • startsWithAtIndex

      protected static boolean startsWithAtIndex(String startsWithValue, int index, String value)
      Checks that the specified value starts with the given value startsWithValue at the given index.
      Parameters:
      startsWithValue - the value to match against
      index - the position to start the matching
      value - the value to search within for the match
      Returns:
      true if the match was found, false otherwise
    • startsWithAtIndexThrow

      protected static boolean startsWithAtIndexThrow(String startsWith, int index, String value)
      Checks that the specified value starts with the given value startsWithValue at the given index.
      Parameters:
      startsWith - the value to match against
      index - the position to start the matching
      value - the value to search within for the match
      Returns:
      true if the match was found, false otherwise
      Throws:
      IllegalStateException - if the match is not found
    • indexOfThrow

      protected static int indexOfThrow(String findValue, String value, int fromIndex)
      Performs an String.indexOf(int, int) on the given value, throwing an exception if not found.
      Parameters:
      findValue - the text to find within the string value
      value - the string value to operate on
      fromIndex - the index where the find starts
      Returns:
      the index of the found string
      Throws:
      IllegalStateException - if the indexOf operation returns -1