com.continuent.tungsten.replicator.database
Interface SqlCommentEditor

All Known Implementing Classes:
MySQLCommentEditor

public interface SqlCommentEditor

Denotes an interface to set and fetch comments in SQL statements.

Version:
1.0
Author:
Robert Hodges

Method Summary
 java.lang.String addComment(java.lang.String statement, SqlOperation sqlOperation, java.lang.String comment)
          Inserts a comment safely into a SQL statement.
 java.lang.String fetchComment(java.lang.String baseStatement, SqlOperation sqlOperation)
          Fetches the first comment string that matches the regex.
 java.lang.String formatAppendableComment(SqlOperation sqlOperation, java.lang.String comment)
          Formats an appendable comment if this works.
 void setCommentEditingEnabled(boolean enabled)
          If true, comment editing is enabled.
 void setCommentRegex(java.lang.String regex)
          Set comment regex.
 

Method Detail

setCommentEditingEnabled

void setCommentEditingEnabled(boolean enabled)
If true, comment editing is enabled. If false, comment editing is ignored and we just return the current statement.


addComment

java.lang.String addComment(java.lang.String statement,
                            SqlOperation sqlOperation,
                            java.lang.String comment)
Inserts a comment safely into a SQL statement.

Parameters:
statement - Statement that requires a comment to be inserted.
sqlOperation - Metadata from parsing statement, if any
comment - Comment string to be added.
Returns:
Query with comment added

formatAppendableComment

java.lang.String formatAppendableComment(SqlOperation sqlOperation,
                                         java.lang.String comment)
Formats an appendable comment if this works.

Parameters:
sqlOperation - Metadata from parsing statement
comment - Comment string to be added.
Returns:
Appendable comment or null if such comments are not safe for current statement

setCommentRegex

void setCommentRegex(java.lang.String regex)
Set comment regex. This is used to fetch out specific parts of the comment and is set once to avoid regex recompilation.


fetchComment

java.lang.String fetchComment(java.lang.String baseStatement,
                              SqlOperation sqlOperation)
Fetches the first comment string that matches the regex.

Parameters:
baseStatement - Statement to search
Returns:
Matching comment string or null if not found.