@NotThreadSafe public class StandardDdlParser extends Object implements DdlParser, DdlConstants, DdlConstants.StatementStartPhrases
DdlConstants.AstNodeNames, DdlConstants.DataTypes, DdlConstants.DropBehavior, DdlConstants.MatchType, DdlConstants.Problems, DdlConstants.ReferencialAction, DdlConstants.StatementStartPhrases
Modifier and Type | Field and Description |
---|---|
static String |
ID
The Standard DDL parser identifier.
|
ALTER, CHECK, COLUMN, COMMA, CONSTRAINT, CONSTRAINT_C, CONSTRAINT_FK, CONSTRAINT_PK, CONSTRAINT_UC, CREATE, DECLARE, DEFAULT_TERMINATOR, DELETE, DROP, FOREIGN, FOREIGN_KEY, GIGA, GRANT, INDEX, INSERT, KEY, KILO, L_PAREN, L_SQUOTE, LS_BRACE, MEGA, MISSING_TERMINATOR_NODE_LITERAL, NOT, NULL, OFF, ON, PERIOD, PRIMARY, PRIMARY_KEY, R_PAREN, REVOKE, RS_BRACE, SCHEMA, SELECT, SEMICOLON, SET, SPACE, SQL_92_RESERVED_WORDS, TABLE, UNIQUE, UPDATE, VIEW
SQL_92_ALL_PHRASES, STMT_ALTER_DOMAIN, STMT_ALTER_TABLE, STMT_CREATE_ASSERTION, STMT_CREATE_CHARACTER_SET, STMT_CREATE_COLLATION, STMT_CREATE_DOMAIN, STMT_CREATE_GLOBAL_TEMPORARY_TABLE, STMT_CREATE_LOCAL_TEMPORARY_TABLE, STMT_CREATE_OR_REPLACE_VIEW, STMT_CREATE_SCHEMA, STMT_CREATE_TABLE, STMT_CREATE_TRANSLATION, STMT_CREATE_VIEW, STMT_DROP_ASSERTION, STMT_DROP_CHARACTER_SET, STMT_DROP_COLLATION, STMT_DROP_DOMAIN, STMT_DROP_SCHEMA, STMT_DROP_TABLE, STMT_DROP_TRANSLATION, STMT_DROP_VIEW, STMT_GRANT, STMT_INSERT_INTO, STMT_REVOKE, STMT_SET_DEFINE, VALID_SCHEMA_CHILD_TYPES
Constructor and Description |
---|
StandardDdlParser() |
Modifier and Type | Method and Description |
---|---|
void |
addProblem(DdlParserProblem problem) |
void |
addProblem(DdlParserProblem problem,
AstNode node) |
protected boolean |
areNextTokensCreateTableOptions(DdlTokenStream tokens) |
void |
attachNewProblem(DdlParserProblem problem,
AstNode parentNode) |
protected void |
computeScore(DdlTokenStream tokens,
DdlParserScorer scorer) |
protected boolean |
consumeComment(DdlTokenStream tokens)
Consumes an an end-of-line comment or in-line comment
|
protected String |
consumeIdentifier(DdlTokenStream tokens)
Consumes an token identifier which can be of the form of a simple string or a double-quoted string.
|
protected String |
consumeParenBoundedTokens(DdlTokenStream tokens,
boolean includeParens)
Simple method which parses, consumes and returns a string representing text found between parenthesis (i.e. '()') If
parents don't exist, method returns NULL;
|
boolean |
doUseTerminator()
Returns if parser is using statement terminator or not.
|
boolean |
equals(Object obj) |
Position |
getCurrentMarkedPosition() |
protected List<String> |
getCustomDataTypeStartWords()
Returns a list of custom data type start words which can be used to help identify a column definition sub-statement.
|
DataTypeParser |
getDatatypeParser()
Returns the data type parser instance.
|
protected List<String> |
getDataTypeStartWords()
Returns a list of data type start words which can be used to help identify a column definition sub-statement.
|
String |
getId()
Get the identifier for this parser.
|
String[] |
getIdentifyingKeywords() |
List<DdlParserProblem> |
getProblems() |
AstNode |
getRootNode() |
String |
getStatementTypeName(String[] stmtPhrase) |
protected String |
getTableElementsString(DdlTokenStream tokens,
boolean useTerminator)
Method which extracts the table element string from a CREATE TABLE statement.
|
protected String |
getTerminator()
Returns current terminator
|
protected String[] |
getValidSchemaChildTypes() |
AstNode |
handleUnknownToken(DdlTokenStream tokens,
String tokenValue)
Utility method subclasses can override to check unknown tokens and perform additional node manipulation.
|
int |
hashCode() |
protected void |
initializeTokenStream(DdlTokenStream tokens)
Method called by
score(String, String, DdlParserScorer) and parse(String, AstNode, Object) to initialize
the token stream , giving subclasses a chance to register
key words and statement start phrases . |
protected int |
integer(String value)
Returns the integer value of the input string.
|
protected boolean |
isColumnDefinitionStart(DdlTokenStream tokens)
This utility method provides this parser the ability to distinguish between a CreateTable Constrain and a ColumnDefinition
Definition which are the only two statement segment types allowed within the CREATE TABLE parenthesis ( xxxxxx );
|
protected boolean |
isComment(DdlTokenStream tokens)
Checks if next token is of type comment.
|
boolean |
isMissingTerminatorNode(AstNode node) |
protected boolean |
isTableConstraint(DdlTokenStream tokens)
This utility method provides this parser the ability to distinguish between a CreateTable Constraint and a ColumnDefinition
Definition which are the only two statement segment types allowed within the CREATE TABLE parenthesis ( xxxxxx );
|
protected boolean |
isTerminator(DdlTokenStream tokens)
Utility method to determine if next token is a terminator.
|
boolean |
isTestMode() |
boolean |
isValidSchemaChild(AstNode node) |
void |
markEndOfStatement(DdlTokenStream tokens,
AstNode statementNode)
Marks the end of a statement by consuming the terminator (if exists).
|
void |
markStartOfStatement(DdlTokenStream tokens)
Marks the token stream with the current position to help track statement scope within the original input string.
|
void |
mergeNodes(DdlTokenStream tokens,
AstNode firstNode,
AstNode secondNode)
Merges second node into first node by re-setting expression source and length.
|
AstNode |
missingTerminatorNode(AstNode parentNode)
Constructs a terminator AstNode as child of root node
|
AstNodeFactory |
nodeFactory()
Method to access the node utility class.
|
void |
parse(String ddl,
AstNode rootNode,
Object scoreReturnObject)
Parses a DDL string, adding child
AstNode s and properties to the supplied root. |
protected AstNode |
parseAlterStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL ALTER statement based on SQL 92 specifications.
|
protected AstNode |
parseAlterTableStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL ALTER TABLE
AstNode based on SQL 92 specifications. |
protected boolean |
parseCollateClause(DdlTokenStream tokens,
AstNode columnNode)
Parses the default clause for a column and sets appropriate properties on the column node.
|
protected boolean |
parseColumnConstraint(DdlTokenStream tokens,
AstNode columnNode,
boolean isAlterTable)
Parses an in-line column constraint including NULLABLE value, UNIQUE, PRIMARY KEY and REFERENCES to a Foreign Key.
|
protected void |
parseColumnDefinition(DdlTokenStream tokens,
AstNode tableNode,
boolean isAlterTable)
Utility method to parse the actual column definition.
|
protected boolean |
parseColumnNameList(DdlTokenStream tokens,
AstNode parentNode,
String referenceType)
Adds column reference nodes to a parent node.
|
protected void |
parseColumnsAndConstraints(DdlTokenStream tokens,
AstNode tableNode)
Utility method to parse columns and table constraints within either a CREATE TABLE statement.
|
protected void |
parseConstraintAttributes(DdlTokenStream tokens,
AstNode constraintNode)
Parses the attributes associated with any in-line column constraint definition or a table constrain definition.
|
protected AstNode |
parseCreateAssertionStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL CREATE ASSERTION
AstNode based on SQL 92 specifications. |
protected AstNode |
parseCreateCharacterSetStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL CREATE CHARACTER SET
AstNode based on SQL 92 specifications. |
protected AstNode |
parseCreateCollationStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL CREATE COLLATION
AstNode based on SQL 92 specifications. |
protected AstNode |
parseCreateDomainStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL CREATE DOMAIN
AstNode based on SQL 92 specifications. |
protected AstNode |
parseCreateSchemaStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL CREATE SCHEMA
AstNode based on SQL 92 specifications. |
protected AstNode |
parseCreateStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL CREATE statement based on SQL 92 specifications.
|
protected void |
parseCreateTableOptions(DdlTokenStream tokens,
AstNode tableNode) |
protected AstNode |
parseCreateTableStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL CREATE TABLE
AstNode based on SQL 92 specifications. |
protected AstNode |
parseCreateTranslationStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL CREATE TRANSLATION
AstNode based on SQL 92 specifications. |
protected AstNode |
parseCreateViewStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL CREATE VIEW
AstNode basedregisterStatementStartPhrase on SQL 92 specifications. |
protected AstNode |
parseCustomStatement(DdlTokenStream tokens,
AstNode parentNode)
Catch-all method to parse unknown (not registered or handled by sub-classes) statements.
|
protected boolean |
parseDefaultClause(DdlTokenStream tokens,
AstNode columnNode)
Parses the default clause for a column and sets appropriate properties on the column node.
|
protected AstNode |
parseDropStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL DROP
AstNode based on SQL 92 specifications. |
protected void |
parseGrantPrivileges(DdlTokenStream tokens,
List<AstNode> privileges) |
protected AstNode |
parseGrantStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL GRANT statement
AstNode based on SQL 92 specifications. |
protected AstNode |
parseIgnorableStatement(DdlTokenStream tokens,
String name,
AstNode parentNode)
Utility method to parse a statement that can be ignored.
|
protected AstNode |
parseIgnorableStatement(DdlTokenStream tokens,
String name,
AstNode parentNode,
String mixinType)
Utility method to parse a statement that can be ignored.
|
protected AstNode |
parseInsertStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL INSERT
AstNode based on SQL 92 specifications. |
protected String |
parseName(DdlTokenStream tokens)
Method to parse fully qualified schema, table and column names that are defined with '.' separator and optionally bracketed
with square brackets Example: partsSchema.supplier Example: [partsSchema].
|
protected List<String> |
parseNameList(DdlTokenStream tokens)
Parses a comma separated list of names.
|
protected void |
parseNextCreateTableOption(DdlTokenStream tokens,
AstNode tableNode) |
protected AstNode |
parseNextStatement(DdlTokenStream tokens,
AstNode node)
Performs token match checks for initial statement type and delegates to specific parser methods.
|
protected void |
parseReferences(DdlTokenStream tokens,
AstNode constraintNode) |
protected AstNode |
parseRevokeStatement(DdlTokenStream tokens,
AstNode parentNode) |
protected AstNode |
parseSetStatement(DdlTokenStream tokens,
AstNode parentNode)
Parses DDL SET
AstNode based on SQL 92 specifications. |
protected void |
parseSingleTerminatedColumnDefinition(DdlTokenStream tokens,
AstNode tableNode,
boolean isAlterTable)
Utility method to parse the actual column definition.
|
protected AstNode |
parseStatement(DdlTokenStream tokens,
String[] stmt_start_phrase,
AstNode parentNode,
String mixinType)
Utility method to parse a generic statement given a start phrase and statement mixin type.
|
protected void |
parseTableConstraint(DdlTokenStream tokens,
AstNode tableNode,
boolean isAlterTable)
Parses full table constraint definition including the "CONSTRAINT" token Examples: CONSTRAINT P_KEY_2a UNIQUE
(PERMISSIONUID)
|
protected String |
parseUntilCommaOrTerminator(DdlTokenStream tokens) |
protected String |
parseUntilSemiColon(DdlTokenStream tokens)
Utility method which parses tokens until a semicolon is found or there are no more tokens.
|
protected String |
parseUntilTerminator(DdlTokenStream tokens)
Utility method which parses tokens until a terminator is found, another statement is identified or there are no more
tokens.
|
protected String |
parseUntilTerminatorIgnoreEmbeddedStatements(DdlTokenStream tokens)
Utility method which parses tokens until a terminator is found or there are no more tokens.
|
void |
postProcess(AstNode rootNode)
Allows parsers to post process the
AstNode tree given the supplied root. |
protected void |
removeMissingTerminatorNodes(AstNode parentNode) |
protected void |
rewrite(DdlTokenStream tokens,
AstNode rootNode) |
Object |
score(String ddl,
String fileName,
DdlParserScorer scorer)
Determine this parser's score for the given DDL string.
|
boolean |
setAsSchemaChildNode(AstNode statementNode,
boolean stmtIsMissingTerminator) |
void |
setDatatypeParser(DataTypeParser datatypeParser) |
void |
setDoUseTerminator(boolean useTerminator)
Sets the value of the use terminator flag for the parser.
|
void |
setRootNode(AstNode rootNode) |
protected boolean |
setTerminator(String terminator) |
void |
setTestMode(boolean testMode) |
protected void |
testPrint(String str) |
AstNode |
unknownTerminatedNode(AstNode parentNode)
Constructs a terminator AstNode as child of root node
|
public static final String ID
public DataTypeParser getDatatypeParser()
DataTypeParser
public void setDatatypeParser(DataTypeParser datatypeParser)
datatypeParser
- public AstNodeFactory nodeFactory()
AstNodeFactory
node utility classpublic AstNode getRootNode()
public void setRootNode(AstNode rootNode)
rootNode
- Sets rootNode to the specified value.public Object score(String ddl, String fileName, DdlParserScorer scorer) throws ParsingException
DdlParser.parse(String, AstNode, Object)
method.score
in interface DdlParser
ddl
- the input string to parse; may not be nullfileName
- the name of the DDL content, which may be used to improve the score; may be null if not knownscorer
- the scorer that should be used to record the score; may not be nullDdlParser.parse(String, AstNode,Object)
methodParsingException
- if there is an error parsing the supplied DDL contentDdlParser.score(java.lang.String, java.lang.String,
org.modeshape.sequencer.ddl.DdlParserScorer)
protected void computeScore(DdlTokenStream tokens, DdlParserScorer scorer)
public String[] getIdentifyingKeywords()
public void parse(String ddl, AstNode rootNode, Object scoreReturnObject) throws ParsingException
AstNode
s and properties to the supplied root. This method instantiates the
tokenizer, calls a method to allow subclasses to register keywords and statement start phrases with the tokenizer and
finally performs the tokenizing (i.e. tokens.start()) before calling the actual parse method.parse
in interface DdlParser
ddl
- the input string to parse; may not be nullrootNode
- the top level AstNode
; may not be nullscoreReturnObject
- the object returned from DdlParser.score(String, String, DdlParserScorer)
for the same DDL content;
may be null if the DdlParser.score(String, String, DdlParserScorer)
method was not calledParsingException
- if there is an error parsing the supplied DDL contentDdlParser.parse(java.lang.String, org.modeshape.sequencer.ddl.node.AstNode,
java.lang.Object)
protected void initializeTokenStream(DdlTokenStream tokens)
score(String, String, DdlParserScorer)
and parse(String, AstNode, Object)
to initialize
the token stream
, giving subclasses a chance to register
key words
and statement start phrases
.tokens
- the stream of tokensprotected AstNode parseNextStatement(DdlTokenStream tokens, AstNode node)
StandardDdlParser
.parseCustomStatement() method is designed to allow for parsing db-specific statement types.tokens
- the tokenized DdlTokenStream
of the DDL input content; may not be nullnode
- the top level AstNode
; may not be nullpublic final void addProblem(DdlParserProblem problem, AstNode node)
public final void addProblem(DdlParserProblem problem)
public final List<DdlParserProblem> getProblems()
public final void attachNewProblem(DdlParserProblem problem, AstNode parentNode)
protected void rewrite(DdlTokenStream tokens, AstNode rootNode)
protected void removeMissingTerminatorNodes(AstNode parentNode)
public void mergeNodes(DdlTokenStream tokens, AstNode firstNode, AstNode secondNode)
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullfirstNode
- the node to merge into; may not be nullsecondNode
- the node to merge into first node; may not be nullpublic AstNode handleUnknownToken(DdlTokenStream tokens, String tokenValue) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nulltokenValue
- the string value of the unknown token; never nullParsingException
protected AstNode parseCreateStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullAstNode
ParsingException
protected AstNode parseAlterStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullAstNode
ParsingException
protected AstNode parseAlterTableStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
AstNode
based on SQL 92 specifications.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullAstNode
ParsingException
protected AstNode parseDropStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
AstNode
based on SQL 92 specifications.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullAstNode
ParsingException
protected AstNode parseInsertStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
AstNode
based on SQL 92 specifications.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullAstNode
ParsingException
protected AstNode parseSetStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
AstNode
based on SQL 92 specifications.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullAstNode
ParsingException
protected AstNode parseGrantStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
AstNode
based on SQL 92 specifications.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullAstNode
ParsingException
protected void parseGrantPrivileges(DdlTokenStream tokens, List<AstNode> privileges) throws ParsingException
ParsingException
protected AstNode parseRevokeStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
ParsingException
protected AstNode parseCreateDomainStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
AstNode
based on SQL 92 specifications.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullAstNode
ParsingException
protected AstNode parseCreateCollationStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
AstNode
based on SQL 92 specifications.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullAstNode
ParsingException
protected AstNode parseCreateTranslationStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
AstNode
based on SQL 92 specifications.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullAstNode
ParsingException
protected AstNode parseCreateCharacterSetStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
AstNode
based on SQL 92 specifications.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullAstNode
ParsingException
protected AstNode parseCustomStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullAstNode
ParsingException
protected AstNode parseCreateTableStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
AstNode
based on SQL 92 specifications.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullAstNode
ParsingException
protected void parseCreateTableOptions(DdlTokenStream tokens, AstNode tableNode) throws ParsingException
ParsingException
protected void parseNextCreateTableOption(DdlTokenStream tokens, AstNode tableNode) throws ParsingException
ParsingException
protected boolean areNextTokensCreateTableOptions(DdlTokenStream tokens) throws ParsingException
ParsingException
protected void parseColumnsAndConstraints(DdlTokenStream tokens, AstNode tableNode) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nulltableNode
- ParsingException
protected void parseColumnDefinition(DdlTokenStream tokens, AstNode tableNode, boolean isAlterTable) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nulltableNode
- isAlterTable
- true if in-line constraint is part of add column in alter table statementParsingException
protected void parseSingleTerminatedColumnDefinition(DdlTokenStream tokens, AstNode tableNode, boolean isAlterTable) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nulltableNode
- the alter or create table statement node; may not be nullisAlterTable
- true if in-line constraint is part of add column in alter table statementParsingException
protected String getTableElementsString(DdlTokenStream tokens, boolean useTerminator) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nulluseTerminator
- ParsingException
protected String consumeParenBoundedTokens(DdlTokenStream tokens, boolean includeParens) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullincludeParens
- ParsingException
protected boolean parseColumnConstraint(DdlTokenStream tokens, AstNode columnNode, boolean isAlterTable) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullcolumnNode
- the column definition being created; may not be nullisAlterTable
- true if in-line constraint is part of add column in alter table statementParsingException
protected void parseTableConstraint(DdlTokenStream tokens, AstNode tableNode, boolean isAlterTable) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nulltableNode
- isAlterTable
- true if in-line constraint is part of add column in alter table statementParsingException
protected void parseConstraintAttributes(DdlTokenStream tokens, AstNode constraintNode) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullconstraintNode
- ParsingException
protected void parseReferences(DdlTokenStream tokens, AstNode constraintNode) throws ParsingException
ParsingException
protected AstNode parseCreateViewStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
AstNode
basedregisterStatementStartPhrase on SQL 92 specifications. Initial implementation
here does not parse the statement in detail.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullParsingException
protected AstNode parseCreateSchemaStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
AstNode
based on SQL 92 specifications. Initial implementation here does not parse the
statement in detail.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullParsingException
protected AstNode parseCreateAssertionStatement(DdlTokenStream tokens, AstNode parentNode) throws ParsingException
AstNode
based on SQL 92 specifications. Initial implementation here does not parse the
statement's search condition in detail.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent AstNode
node; may not be nullParsingException
protected AstNode parseIgnorableStatement(DdlTokenStream tokens, String name, AstNode parentNode)
AstNode
will contain all
text between starting token and either the terminator (if defined) or the next statement start token. NOTE: This method
does NOT mark and add consumed fragment to parent node.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullname
- parentNode
- the parent AstNode
node; may not be nullAstNode
ParsingException
protected AstNode parseIgnorableStatement(DdlTokenStream tokens, String name, AstNode parentNode, String mixinType)
AstNode
will contain all
text between starting token and either the terminator (if defined) or the next statement start token. NOTE: This method
does NOT mark and add consumed fragment to parent node.tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullname
- parentNode
- the parent AstNode
node; may not be nullmixinType
- AstNode
ParsingException
protected AstNode parseStatement(DdlTokenStream tokens, String[] stmt_start_phrase, AstNode parentNode, String mixinType)
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullstmt_start_phrase
- the string array statement start phraseparentNode
- the parent of the newly created node.mixinType
- the mixin type of the newly created statement nodepublic final AstNode unknownTerminatedNode(AstNode parentNode)
parentNode
- the parent AstNode
node; may not be nullpublic final AstNode missingTerminatorNode(AstNode parentNode)
parentNode
- the parent AstNode
node; may not be nullpublic final boolean isMissingTerminatorNode(AstNode node)
public final boolean isValidSchemaChild(AstNode node)
public final boolean setAsSchemaChildNode(AstNode statementNode, boolean stmtIsMissingTerminator)
protected String getTerminator()
protected boolean setTerminator(String terminator)
terminator
- the string value used as the statement terminator for the ddl dialectprotected String[] getValidSchemaChildTypes()
protected boolean isComment(DdlTokenStream tokens) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullParsingException
protected boolean consumeComment(DdlTokenStream tokens) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullParsingException
protected boolean isTableConstraint(DdlTokenStream tokens) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullParsingException
protected boolean isColumnDefinitionStart(DdlTokenStream tokens) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullParsingException
protected List<String> getDataTypeStartWords()
protected List<String> getCustomDataTypeStartWords()
protected String parseName(DdlTokenStream tokens)
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullprotected String consumeIdentifier(DdlTokenStream tokens) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullParsingException
protected boolean isTerminator(DdlTokenStream tokens) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullParsingException
protected boolean parseColumnNameList(DdlTokenStream tokens, AstNode parentNode, String referenceType)
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullparentNode
- the parent nodereferenceType
- the type of the reference node to createprotected List<String> parseNameList(DdlTokenStream tokens) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullnull
)ParsingException
protected String parseUntilTerminator(DdlTokenStream tokens) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullParsingException
protected String parseUntilTerminatorIgnoreEmbeddedStatements(DdlTokenStream tokens) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullParsingException
protected String parseUntilSemiColon(DdlTokenStream tokens) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullParsingException
protected String parseUntilCommaOrTerminator(DdlTokenStream tokens) throws ParsingException
ParsingException
public boolean doUseTerminator()
public void setDoUseTerminator(boolean useTerminator)
useTerminator
- protected boolean parseDefaultClause(DdlTokenStream tokens, AstNode columnNode) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullcolumnNode
- the column node which may contain a default clause; may not be nullParsingException
protected boolean parseCollateClause(DdlTokenStream tokens, AstNode columnNode) throws ParsingException
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullcolumnNode
- the column node which may contain a collate clause; may not be nullParsingException
protected int integer(String value)
NumberFormatException
if a valid integer is not found.value
- the string to be parsed; may not be null and length must be > 0;public final Position getCurrentMarkedPosition()
public final void markStartOfStatement(DdlTokenStream tokens)
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullpublic final void markEndOfStatement(DdlTokenStream tokens, AstNode statementNode)
tokens
- the DdlTokenStream
representing the tokenized DDL content; may not be nullstatementNode
- public void postProcess(AstNode rootNode)
AstNode
tree given the supplied root. Initial use-case would be to allow a
second pass through the tree to resolve any table references (FK's) that were defined out of order in the DDLpostProcess
in interface DdlParser
rootNode
- the top level AstNode
; may not be nullDdlParser.postProcess(org.modeshape.sequencer.ddl.node.AstNode)
protected void testPrint(String str)
public boolean isTestMode()
public void setTestMode(boolean testMode)
testMode
- Sets testMode to the specified value.public String getId()
getId
in interface DdlParser
DdlParser.getId()
public int hashCode()
hashCode
in class Object
Object.hashCode()
public boolean equals(Object obj)
equals
in class Object
Object.equals(java.lang.Object)
Copyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.