public abstract class AbstractDdlParser extends Object implements DdlParser
| Modifier and Type | Field and Description |
|---|---|
private String |
currentSchema |
protected DdlChanges |
ddlChanges |
protected org.slf4j.Logger |
logger |
protected boolean |
skipViews |
protected SystemVariables |
systemVariables |
private String |
terminator |
| Constructor and Description |
|---|
AbstractDdlParser(String terminator)
Create a new parser that uses the supplied
DataTypeParser, but that does not include view definitions. |
AbstractDdlParser(String terminator,
boolean includeViews)
Create a new parser that uses the supplied
DataTypeParser. |
| Modifier and Type | Method and Description |
|---|---|
protected Collection<ParsingException> |
accumulateParsingFailure(MultipleParsingExceptions e,
Collection<ParsingException> list)
Utility method to accumulate a parsing exception.
|
static Collection<ParsingException> |
accumulateParsingFailure(ParsingException e,
Collection<ParsingException> list)
Utility method to accumulate a parsing exception.
|
protected void |
commentParsed(String comment) |
protected Column |
createColumnFromConstant(String columnName,
String constantValue) |
protected abstract SystemVariables |
createNewSystemVariablesInstance() |
String |
currentSchema()
Get the name of the current schema.
|
protected void |
debugParsed(String statement) |
protected void |
debugSkipped(String statement) |
DdlChanges |
getDdlChanges() |
static boolean |
isQuote(char c)
Check if the char is quote.
|
static boolean |
isQuoted(String possiblyQuoted)
Check if the string is enclosed in quotes.
|
protected String |
removeLineFeeds(String input)
Removes line feeds from input string.
|
TableId |
resolveTableId(String schemaName,
String tableName)
Create a
TableId from the supplied schema and table names. |
void |
setCurrentDatabase(String databaseName) |
void |
setCurrentSchema(String schemaName)
Set the name of the current schema.
|
protected void |
setTypeInfoForConstant(String constantValue,
ColumnEditor column) |
protected void |
signalAlterDatabase(String databaseName,
String previousDatabaseName,
String statement)
Signal an alter database event to ddl changes listener.
|
protected void |
signalAlterTable(TableId id,
TableId previousId,
String statement)
Signal an alter table event to ddl changes listener.
|
protected void |
signalAlterView(TableId id,
TableId previousId,
String statement)
Signal an alter view event to ddl changes listener.
|
protected void |
signalChangeEvent(DdlParserListener.Event event)
Signal an event to ddl changes listener.
|
protected void |
signalCreateDatabase(String databaseName,
String statement)
Signal a create database event to ddl changes listener.
|
protected void |
signalCreateIndex(String indexName,
TableId id,
String statement)
Signal a create index event to ddl changes listener.
|
protected void |
signalCreateTable(TableId id,
String statement)
Signal a create table event to ddl changes listener.
|
protected void |
signalCreateView(TableId id,
String statement)
Signal a create view event to ddl changes listener.
|
protected void |
signalDropDatabase(String databaseName,
String statement)
Signal a drop database event to ddl changes listener.
|
protected void |
signalDropIndex(String indexName,
TableId id,
String statement)
Signal a drop index event to ddl changes listener.
|
protected void |
signalDropTable(TableId id,
String statement)
Signal a drop table event to ddl changes listener.
|
protected void |
signalDropView(TableId id,
String statement)
Signal a drop view event to ddl changes listener.
|
protected void |
signalSetVariable(String variableName,
String variableValue,
String statement) |
protected void |
signalTruncateTable(TableId id,
String statement)
Signal a truncate table event to ddl changes listener.
|
protected void |
signalUseDatabase(String statement) |
protected boolean |
skipComments()
Determine whether parsing should exclude comments from the token stream.
|
SystemVariables |
systemVariables() |
String |
terminator()
The token used to terminate a DDL statement.
|
static String |
withoutQuotes(String possiblyQuoted)
Cut out the string surrounded with single, double and reversed quotes.
|
private final String terminator
protected final boolean skipViews
protected DdlChanges ddlChanges
protected SystemVariables systemVariables
protected final org.slf4j.Logger logger
private String currentSchema
public AbstractDdlParser(String terminator)
DataTypeParser, but that does not include view definitions.terminator - the terminator character sequence; may be null if the default terminator (;) should be usedpublic AbstractDdlParser(String terminator, boolean includeViews)
DataTypeParser.terminator - the terminator character sequence; may be null if the default terminator (;) should be usedincludeViews - true if view definitions should be included, or false if they should be skippedpublic void setCurrentSchema(String schemaName)
DdlParsersetCurrentSchema in interface DdlParserschemaName - the name of the current schema; may be nullpublic void setCurrentDatabase(String databaseName)
setCurrentDatabase in interface DdlParserpublic final String terminator()
DdlParserterminator in interface DdlParserpublic DdlChanges getDdlChanges()
getDdlChanges in interface DdlParserpublic SystemVariables systemVariables()
systemVariables in interface DdlParserprotected abstract SystemVariables createNewSystemVariablesInstance()
public String currentSchema()
setpublic TableId resolveTableId(String schemaName, String tableName)
TableId from the supplied schema and table names. By default, this method uses the supplied schema name
as the TableId's catalog, which often matches the catalog name in JDBC database metadata.schemaName - the name of the schema; may be null if not specifiedtableName - the name of the table; should not be nullprotected boolean skipComments()
true.true if comments should be skipped/excluded, or false if they should not be skippedprotected void signalChangeEvent(DdlParserListener.Event event)
event - the event; may not be nullprotected void signalSetVariable(String variableName, String variableValue, String statement)
protected void signalUseDatabase(String statement)
protected void signalCreateDatabase(String databaseName, String statement)
databaseName - the database name; may not be nullstatement - the DDL statement; may not be nullprotected void signalAlterDatabase(String databaseName, String previousDatabaseName, String statement)
databaseName - the database name; may not be nullpreviousDatabaseName - the previous name of the database if it was renamed, or null if it was not renamedstatement - the DDL statement; may not be nullprotected void signalDropDatabase(String databaseName, String statement)
databaseName - the database name; may not be nullstatement - the DDL statement; may not be nullprotected void signalCreateTable(TableId id, String statement)
id - the table identifier; may not be nullstatement - the DDL statement; may not be nullprotected void signalAlterTable(TableId id, TableId previousId, String statement)
id - the table identifier; may not be nullpreviousId - the previous name of the view if it was renamed, or null if it was not renamedstatement - the DDL statement; may not be nullprotected void signalDropTable(TableId id, String statement)
id - the table identifier; may not be nullstatement - the statement; may not be nullprotected void signalTruncateTable(TableId id, String statement)
id - the table identifier; may not be nullstatement - the statement; may not be nullprotected void signalCreateView(TableId id, String statement)
id - the table identifier; may not be nullstatement - the DDL statement; may not be nullprotected void signalAlterView(TableId id, TableId previousId, String statement)
id - the table identifier; may not be nullpreviousId - the previous name of the view if it was renamed, or null if it was not renamedstatement - the DDL statement; may not be nullprotected void signalDropView(TableId id, String statement)
id - the table identifier; may not be nullstatement - the statement; may not be nullprotected void signalCreateIndex(String indexName, TableId id, String statement)
indexName - the name of the index; may not be nullid - the table identifier; may be null if the index does not apply to a single tablestatement - the DDL statement; may not be nullprotected void signalDropIndex(String indexName, TableId id, String statement)
indexName - the name of the index; may not be nullid - the table identifier; may not be nullstatement - the DDL statement; may not be nullprotected String removeLineFeeds(String input)
input - input with possible line feedspublic static String withoutQuotes(String possiblyQuoted)
possiblyQuoted - string with possible quotespublic static boolean isQuoted(String possiblyQuoted)
possiblyQuoted - string with possible quotespublic static boolean isQuote(char c)
c - possible quote charpublic static Collection<ParsingException> accumulateParsingFailure(ParsingException e, Collection<ParsingException> list)
e - the parsing exceptionlist - the list of previous parsing exceptions; may be nulle is null then always list, but otherwise non-null listprotected Collection<ParsingException> accumulateParsingFailure(MultipleParsingExceptions e, Collection<ParsingException> list)
e - the multiple parsing exceptionslist - the list of previous parsing exceptions; may be nulle is null then always list, but otherwise non-null listprotected Column createColumnFromConstant(String columnName, String constantValue)
protected void setTypeInfoForConstant(String constantValue, ColumnEditor column)
protected void debugParsed(String statement)
protected void debugSkipped(String statement)
protected void commentParsed(String comment)
Copyright © 2020 JBoss by Red Hat. All rights reserved.