|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jboss.dna.sequencer.ddl.StandardDdlParser
public class StandardDdlParser
Standard SQL 92 DDL file content parser.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.jboss.dna.sequencer.ddl.DdlConstants |
---|
DdlConstants.AstNodeNames, DdlConstants.DataTypes, DdlConstants.DropBehavior, DdlConstants.MatchType, DdlConstants.Problems, DdlConstants.ReferencialAction, DdlConstants.StatementStartPhrases |
Field Summary |
---|
Fields inherited from interface org.jboss.dna.sequencer.ddl.DdlConstants |
---|
ALTER, CHECK, COLUMN, COMMA, CONSTRAINT, CONSTRAINT_C, CONSTRAINT_FK, CONSTRAINT_PK, CONSTRAINT_UC, CREATE, DECLARE, DEFAULT_ID_CURRENT_USER, DEFAULT_ID_DATETIME, DEFAULT_ID_LITERAL, DEFAULT_ID_NULL, DEFAULT_ID_SESSION_USER, DEFAULT_ID_SYSTEM_USER, DEFAULT_ID_UNDEFINED, DEFAULT_ID_USER, DEFAULT_TERMINATOR, DELETE, DROP, FOREIGN, FOREIGN_KEY, GRANT, INDEX, INSERT, KEY, L_PAREN, L_SQUOTE, MISSING_TERMINATOR_NODE_LITERAL, OFF, ON, PERIOD, PRIMARY, PRIMARY_KEY, R_PAREN, REVOKE, SCHEMA, SELECT, SEMICOLON, SET, SPACE, SQL_92_RESERVED_WORDS, TABLE, UNIQUE, UPDATE, VIEW |
Constructor Summary | |
---|---|
StandardDdlParser()
|
Method Summary | |
---|---|
void |
addProblem(DdlParserProblem problem)
|
void |
addProblem(DdlParserProblem problem,
AstNode node)
|
void |
attachNewProblem(DdlParserProblem problem,
AstNode parentNode)
|
boolean |
doUseTerminator()
Returns if parser is using statement terminator or not. |
Position |
getCurrentMarkedPosition()
|
DataTypeParser |
getDatatypeParser()
Returns the data type parser instance. |
String |
getId()
|
int |
getNumberOfKeyWords(DdlTokenStream tokens)
|
List<DdlParserProblem> |
getProblems()
|
AstNode |
getRootNode()
|
String |
getStatementTypeName(String[] stmtPhrase)
|
AstNode |
handleUnknownToken(DdlTokenStream tokens,
String tokenValue)
Utility method subclasses can override to check unknown tokens and perform additional node manipulation. |
boolean |
isMissingTerminatorNode(AstNode node)
|
boolean |
isTestMode()
|
boolean |
isType(String ddl)
|
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. |
boolean |
parse(DdlTokenStream tokens,
AstNode rootNode)
Parses DDL content from the DdlTokenStream provided. |
boolean |
parse(String ddl,
AstNode rootNode)
Parses a DDL string and adds discovered child AstNode s and properties. |
void |
registerKeyWords(List<String> keywords)
Adds the provided key words list to the list of registered key words. |
void |
registerKeyWords(String[] keywords)
Adds the provided key words array to the list of registered key words. |
void |
registerStatementStartPhrase(String[] phrase)
Adds the provided statement start phrase to the list of registered phrases. |
void |
registerStatementStartPhrase(String[][] phrases)
Adds the provided statement start phrases to the list of registered phrases. |
void |
registerWords(DdlTokenStream tokens)
Method provide means for DB-specific Statement implementations can contribute DDL Start Phrases and Keywords. |
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)
|
void |
setTestMode(boolean testMode)
|
AstNode |
unknownTerminatedNode(AstNode parentNode)
Constructs a terminator AstNode as child of root node |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public StandardDdlParser()
Method Detail |
---|
public void registerWords(DdlTokenStream tokens)
registerWords
in interface DdlParser
tokens
- the token stream containing the tokenized DDL content. may not be nullpublic 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 int getNumberOfKeyWords(DdlTokenStream tokens)
getNumberOfKeyWords
in interface DdlParser
DdlParser.getNumberOfKeyWords(org.jboss.dna.sequencer.ddl.DdlTokenStream)
public boolean parse(String ddl, AstNode rootNode) throws ParsingException
AstNode
s and properties. 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 null
ParsingException
public boolean parse(DdlTokenStream tokens, AstNode rootNode) throws ParsingException
DdlTokenStream
provided. Parsed data is converted to an AST via AstNode
s. This
tree, represents all recognizable statements and properties within a DDL file. Note that db-specific dialects will need to
override many methods, as well as add methods to fully parse their specific DDL.
parse
in interface DdlParser
tokens
- the tokenized DdlTokenStream
of the DDL input content; may not be nullrootNode
- the top level AstNode
; may not be null
ParsingException
public 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)
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 null
ParsingException
public final AstNode unknownTerminatedNode(AstNode parentNode)
parentNode
- the parent AstNode
node; may not be null
public final AstNode missingTerminatorNode(AstNode parentNode)
parentNode
- the parent AstNode
node; may not be null
public final boolean isMissingTerminatorNode(AstNode node)
public final boolean isValidSchemaChild(AstNode node)
public final boolean setAsSchemaChildNode(AstNode statementNode, boolean stmtIsMissingTerminator)
public void registerKeyWords(String[] keywords)
keywords
- public void registerKeyWords(List<String> keywords)
keywords
- public void registerStatementStartPhrase(String[] phrase)
phrase
- public void registerStatementStartPhrase(String[][] phrases)
phrases
- public boolean doUseTerminator()
public void setDoUseTerminator(boolean useTerminator)
useTerminator
- public String getStatementTypeName(String[] stmtPhrase)
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 boolean isTestMode()
public void setTestMode(boolean testMode)
testMode
- Sets testMode to the specified value.public String getId()
getId
in interface DdlParser
public boolean isType(String ddl)
isType
in interface DdlParser
DdlParser.isType(String)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |