org.modeshape.sequencer.ddl.dialect.oracle
Class OracleDdlParser

java.lang.Object
  extended by org.modeshape.sequencer.ddl.StandardDdlParser
      extended by org.modeshape.sequencer.ddl.dialect.oracle.OracleDdlParser
All Implemented Interfaces:
DdlConstants, DdlConstants.StatementStartPhrases, DdlParser, OracleDdlConstants, OracleDdlConstants.OracleStatementStartPhrases

public class OracleDdlParser
extends StandardDdlParser
implements OracleDdlConstants, OracleDdlConstants.OracleStatementStartPhrases

Oracle-specific DDL Parser. Includes custom data types as well as custom DDL statements.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.modeshape.sequencer.ddl.dialect.oracle.OracleDdlConstants
OracleDdlConstants.OracleDataTypes, OracleDdlConstants.OracleStatementStartPhrases
 
Nested classes/interfaces inherited from interface org.modeshape.sequencer.ddl.DdlConstants
DdlConstants.AstNodeNames, DdlConstants.DataTypes, DdlConstants.DropBehavior, DdlConstants.MatchType, DdlConstants.Problems, DdlConstants.ReferencialAction, DdlConstants.StatementStartPhrases
 
Field Summary
 
Fields inherited from interface org.modeshape.sequencer.ddl.dialect.oracle.OracleDdlConstants
CUSTOM_KEYWORDS
 
Fields inherited from interface org.modeshape.sequencer.ddl.DdlConstants
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, MEGA, 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
 
Fields inherited from interface org.modeshape.sequencer.ddl.dialect.oracle.OracleDdlConstants.OracleStatementStartPhrases
ALTER_PHRASES, COMPLEX_STMT_TYPES, CREATE_PHRASES, DROP_PHRASES, MISC_PHRASES, SET_PHRASES, SLASHED_STMT_PHRASES, STMT_ALTER_CLUSTER, STMT_ALTER_DATABASE, STMT_ALTER_DIMENSION, STMT_ALTER_DISKGROUP, STMT_ALTER_FUNCTION, STMT_ALTER_INDEX, STMT_ALTER_INDEXTYPE, STMT_ALTER_JAVA, STMT_ALTER_MATERIALIZED, STMT_ALTER_OPERATOR, STMT_ALTER_OUTLINE, STMT_ALTER_PACKAGE, STMT_ALTER_PROCEDURE, STMT_ALTER_PROFILE, STMT_ALTER_RESOURCE, STMT_ALTER_ROLE, STMT_ALTER_ROLLBACK, STMT_ALTER_SEQUENCE, STMT_ALTER_SESSION, STMT_ALTER_SYSTEM, STMT_ALTER_TABLESPACE, STMT_ALTER_TRIGGER, STMT_ALTER_TYPE, STMT_ALTER_USER, STMT_ALTER_VIEW, STMT_ANALYZE, STMT_ASSOCIATE_STATISTICS, STMT_AUDIT, STMT_COMMENT_ON, STMT_COMMIT, STMT_COMMIT_FORCE, STMT_COMMIT_WORK, STMT_COMMIT_WRITE, STMT_CREATE_BITMAP_INDEX, STMT_CREATE_CLUSTER, STMT_CREATE_CONTEXT, STMT_CREATE_CONTROLFILE, STMT_CREATE_DATABASE, STMT_CREATE_DIMENSION, STMT_CREATE_DIRECTORY, STMT_CREATE_DISKGROUP, STMT_CREATE_FUNCTION, STMT_CREATE_INDEX, STMT_CREATE_INDEXTYPE, STMT_CREATE_JAVA, STMT_CREATE_LIBRARY, STMT_CREATE_MATERIALIZED_VEIW_LOG, STMT_CREATE_MATERIALIZED_VIEW, STMT_CREATE_OPERATOR, STMT_CREATE_OR_REPLACE_DIRECTORY, STMT_CREATE_OR_REPLACE_FUNCTION, STMT_CREATE_OR_REPLACE_LIBRARY, STMT_CREATE_OR_REPLACE_OUTLINE, STMT_CREATE_OR_REPLACE_PACKAGE, STMT_CREATE_OR_REPLACE_PRIVATE_OUTLINE, STMT_CREATE_OR_REPLACE_PROCEDURE, STMT_CREATE_OR_REPLACE_PUBLIC_OUTLINE, STMT_CREATE_OR_REPLACE_PUBLIC_SYNONYM, STMT_CREATE_OR_REPLACE_SYNONYM, STMT_CREATE_OR_REPLACE_TRIGGER, STMT_CREATE_OR_REPLACE_TYPE, STMT_CREATE_OUTLINE, STMT_CREATE_PACKAGE, STMT_CREATE_PFILE, STMT_CREATE_PROCEDURE, STMT_CREATE_PROFILE, STMT_CREATE_PUBLIC_DATABASE, STMT_CREATE_PUBLIC_ROLLBACK, STMT_CREATE_PUBLIC_SYNONYM, STMT_CREATE_ROLE, STMT_CREATE_ROLLBACK, STMT_CREATE_SEQUENCE, STMT_CREATE_SPFILE, STMT_CREATE_SYNONYM, STMT_CREATE_TABLESPACE, STMT_CREATE_TRIGGER, STMT_CREATE_TYPE, STMT_CREATE_UNIQUE_INDEX, STMT_CREATE_USER, STMT_DISASSOCIATE_STATISTICS, STMT_DROP_CLUSTER, STMT_DROP_CONTEXT, STMT_DROP_DATABASE, STMT_DROP_DIMENSION, STMT_DROP_DIRECTORY, STMT_DROP_DISKGROUP, STMT_DROP_FUNCTION, STMT_DROP_INDEX, STMT_DROP_INDEXTYPE, STMT_DROP_JAVA, STMT_DROP_LIBRARY, STMT_DROP_MATERIALIZED, STMT_DROP_OPERATOR, STMT_DROP_OUTLINE, STMT_DROP_PACKAGE, STMT_DROP_PROCEDURE, STMT_DROP_PROFILE, STMT_DROP_PUBLIC_DATABASE, STMT_DROP_PUBLIC_SYNONYM, STMT_DROP_ROLE, STMT_DROP_ROLLBACK, STMT_DROP_SEQUENCE, STMT_DROP_SYNONYM, STMT_DROP_TABLESPACE, STMT_DROP_TRIGGER, STMT_DROP_TYPE, STMT_DROP_USER, STMT_EXPLAIN_PLAN, STMT_FLASHBACK, STMT_LOCK_TABLE, STMT_MERGE, STMT_NOAUDIT, STMT_PURGE, STMT_RENAME, STMT_ROLLBACK, STMT_ROLLBACK_TO_SAVEPOINT, STMT_ROLLBACK_WORK, STMT_SAVEPOINT, STMT_SET_CONSTRAINT, STMT_SET_CONSTRAINTS, STMT_SET_ROLE, STMT_SET_TRANSACTION, STMT_TRUNCATE, VALID_SCHEMA_CHILD_STMTS
 
Fields inherited from interface org.modeshape.sequencer.ddl.DdlConstants.StatementStartPhrases
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 Summary
OracleDdlParser()
           
 
Method Summary
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.
 String getId()
          Get the identifier for this parser.
 String[] getIdentifyingKeywords()
          
protected  Name[] getValidSchemaChildTypes()
          
 AstNode handleUnknownToken(DdlTokenStream tokens, String tokenValue)
          Utility method subclasses can override to check unknown tokens and perform additional node manipulation.
protected  void initializeTokenStream(DdlTokenStream tokens)
          Method called by StandardDdlParser.score(String, String, DdlParserScorer) and StandardDdlParser.parse(String, AstNode, Object) to initialize the token stream, giving subclasses a chance to register key words and statement start phrases.
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  void parseColumns(DdlTokenStream tokens, AstNode tableNode, boolean isAlterTable)
          Utility method designed to parse columns within an ALTER TABLE ADD statement.
protected  AstNode parseCreateFunctionStatement(DdlTokenStream tokens, AstNode parentNode)
          Parses DDL CREATE FUNCTION statement
protected  AstNode parseCreateProcedureStatement(DdlTokenStream tokens, AstNode parentNode)
          Parses DDL CREATE PROCEDURE statement
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  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  AstNode parseDropStatement(DdlTokenStream tokens, AstNode parentNode)
          Parses DDL DROP AstNode based on SQL 92 specifications.
protected  AstNode parseGrantStatement(DdlTokenStream tokens, AstNode parentNode)
          Parses DDL GRANT statement AstNode based on SQL 92 specifications.
protected  AstNode parseMaterializedViewStatement(DdlTokenStream tokens, AstNode parentNode)
          Parses DDL CREATE MATERIALIZED VIEW statement This could either be a standard view or a VIEW LOG ON statement.
protected  AstNode parseRevokeStatement(DdlTokenStream tokens, AstNode parentNode)
          
protected  AstNode parseSetStatement(DdlTokenStream tokens, AstNode parentNode)
          Parses DDL SET AstNode based on SQL 92 specifications.
protected  AstNode parseSlashedStatement(DdlTokenStream tokens, String[] stmt_start_phrase, AstNode parentNode, Name mixinType)
          Utility method to parse a generic statement given a start phrase and statement mixin type.
protected  void rewrite(DdlTokenStream tokens, AstNode rootNode)
           
 
Methods inherited from class org.modeshape.sequencer.ddl.StandardDdlParser
addProblem, addProblem, areNextTokensCreateTableOptions, attachNewProblem, computeScore, consumeComment, consumeIdentifier, consumeParenBoundedTokens, doUseTerminator, equals, getCurrentMarkedPosition, getDatatypeParser, getDataTypeStartWords, getProblems, getRootNode, getStatementTypeName, getTableElementsString, getTerminator, hashCode, integer, isColumnDefinitionStart, isComment, isMissingTerminatorNode, isTableConstraint, isTerminator, isTestMode, isValidSchemaChild, markEndOfStatement, markStartOfStatement, mergeNodes, missingTerminatorNode, nodeFactory, parse, parseCollateClause, parseColumnConstraint, parseColumnDefinition, parseColumnNameList, parseColumnNameList, parseColumnsAndConstraints, parseConstraintAttributes, parseCreateAssertionStatement, parseCreateCharacterSetStatement, parseCreateCollationStatement, parseCreateDomainStatement, parseCreateTableOptions, parseCreateTableStatement, parseCreateTranslationStatement, parseDefaultClause, parseGrantPrivileges, parseIgnorableStatement, parseIgnorableStatement, parseInsertStatement, parseName, parseNextCreateTableOption, parseNextStatement, parseReferences, parseSingleTerminatedColumnDefinition, parseStatement, parseTableConstraint, parseUntilCommaOrTerminator, parseUntilSemiColon, parseUntilTerminator, parseUntilTerminatorIgnoreEmbeddedStatements, removeMissingTerminatorNodes, score, setAsSchemaChildNode, setDatatypeParser, setDoUseTerminator, setRootNode, setTerminator, setTestMode, testPrint, unknownTerminatedNode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OracleDdlParser

public OracleDdlParser()
Method Detail

getId

public String getId()
Get the identifier for this parser.

Specified by:
getId in interface DdlParser
Overrides:
getId in class StandardDdlParser
Returns:
the parser's identifier; never null
See Also:
StandardDdlParser.getId()

getIdentifyingKeywords

public String[] getIdentifyingKeywords()

Overrides:
getIdentifyingKeywords in class StandardDdlParser
See Also:
StandardDdlParser.getIdentifyingKeywords()

initializeTokenStream

protected void initializeTokenStream(DdlTokenStream tokens)
Method called by StandardDdlParser.score(String, String, DdlParserScorer) and StandardDdlParser.parse(String, AstNode, Object) to initialize the token stream, giving subclasses a chance to register key words and statement start phrases.

Overrides:
initializeTokenStream in class StandardDdlParser
Parameters:
tokens - the stream of tokens
See Also:
StandardDdlParser.initializeTokenStream(org.modeshape.sequencer.ddl.DdlTokenStream)

rewrite

protected void rewrite(DdlTokenStream tokens,
                       AstNode rootNode)
Overrides:
rewrite in class StandardDdlParser

handleUnknownToken

public AstNode handleUnknownToken(DdlTokenStream tokens,
                                  String tokenValue)
                           throws ParsingException
Utility method subclasses can override to check unknown tokens and perform additional node manipulation. Example would be in Oracle dialect for CREATE FUNCTION statements that can end with an '/' character because statement can contain multiple statements.

Overrides:
handleUnknownToken in class StandardDdlParser
Parameters:
tokens - the DdlTokenStream representing the tokenized DDL content; may not be null
tokenValue - the string value of the unknown token; never null
Returns:
the new node
Throws:
ParsingException
See Also:
StandardDdlParser.handleUnknownToken(org.modeshape.sequencer.ddl.DdlTokenStream, java.lang.String)

parseCreateSchemaStatement

protected AstNode parseCreateSchemaStatement(DdlTokenStream tokens,
                                             AstNode parentNode)
                                      throws ParsingException
Parses DDL CREATE SCHEMA AstNode based on SQL 92 specifications. Initial implementation here does not parse the statement in detail. The CREATE SCHEMA statement can include CREATE TABLE, CREATE VIEW, and GRANT statements.

Overrides:
parseCreateSchemaStatement in class StandardDdlParser
Parameters:
tokens - the DdlTokenStream representing the tokenized DDL content; may not be null
parentNode - the parent AstNode node; may not be null
Returns:
the parsed schema node
Throws:
ParsingException
See Also:
StandardDdlParser.parseCreateSchemaStatement(org.modeshape.sequencer.ddl.DdlTokenStream, org.modeshape.sequencer.ddl.node.AstNode)

parseCustomStatement

protected AstNode parseCustomStatement(DdlTokenStream tokens,
                                       AstNode parentNode)
                                throws ParsingException
Catch-all method to parse unknown (not registered or handled by sub-classes) statements.

Overrides:
parseCustomStatement in class StandardDdlParser
Parameters:
tokens - the DdlTokenStream representing the tokenized DDL content; may not be null
parentNode - the parent AstNode node; may not be null
Returns:
the AstNode
Throws:
ParsingException
See Also:
StandardDdlParser.parseCustomStatement(org.modeshape.sequencer.ddl.DdlTokenStream, org.modeshape.sequencer.ddl.node.AstNode)

parseCreateStatement

protected AstNode parseCreateStatement(DdlTokenStream tokens,
                                       AstNode parentNode)
                                throws ParsingException
Description copied from class: StandardDdlParser
Parses DDL CREATE statement based on SQL 92 specifications.

Overrides:
parseCreateStatement in class StandardDdlParser
Parameters:
tokens - the DdlTokenStream representing the tokenized DDL content; may not be null
parentNode - the parent AstNode node; may not be null
Returns:
the parsed CREATE AstNode
Throws:
ParsingException

parseCreateFunctionStatement

protected AstNode parseCreateFunctionStatement(DdlTokenStream tokens,
                                               AstNode parentNode)
                                        throws ParsingException
Parses DDL CREATE FUNCTION statement

Parameters:
tokens - the tokenized DdlTokenStream of the DDL input content; may not be null
parentNode - the parent AstNode node; may not be null
Returns:
the parsed CREATE FUNCTION statement node
Throws:
ParsingException

parseCreateProcedureStatement

protected AstNode parseCreateProcedureStatement(DdlTokenStream tokens,
                                                AstNode parentNode)
                                         throws ParsingException
Parses DDL CREATE PROCEDURE statement

Parameters:
tokens - the tokenized DdlTokenStream of the DDL input content; may not be null
parentNode - the parent AstNode node; may not be null
Returns:
the parsed CREATE PROCEDURE statement node
Throws:
ParsingException

parseMaterializedViewStatement

protected AstNode parseMaterializedViewStatement(DdlTokenStream tokens,
                                                 AstNode parentNode)
                                          throws ParsingException
Parses DDL CREATE MATERIALIZED VIEW statement This could either be a standard view or a VIEW LOG ON statement.

Parameters:
tokens - the tokenized DdlTokenStream of the DDL input content; may not be null
parentNode - the parent AstNode node; may not be null
Returns:
the parsed CREATE MATERIALIZED VIEW statement node
Throws:
ParsingException

parseGrantStatement

protected AstNode parseGrantStatement(DdlTokenStream tokens,
                                      AstNode parentNode)
                               throws ParsingException
Description copied from class: StandardDdlParser
Parses DDL GRANT statement AstNode based on SQL 92 specifications.

Overrides:
parseGrantStatement in class StandardDdlParser
Parameters:
tokens - the DdlTokenStream representing the tokenized DDL content; may not be null
parentNode - the parent AstNode node; may not be null
Returns:
the AstNode
Throws:
ParsingException

parseRevokeStatement

protected AstNode parseRevokeStatement(DdlTokenStream tokens,
                                       AstNode parentNode)
                                throws ParsingException

Overrides:
parseRevokeStatement in class StandardDdlParser
Throws:
ParsingException
See Also:
StandardDdlParser.parseRevokeStatement(org.modeshape.sequencer.ddl.DdlTokenStream, org.modeshape.sequencer.ddl.node.AstNode)

parseAlterTableStatement

protected AstNode parseAlterTableStatement(DdlTokenStream tokens,
                                           AstNode parentNode)
                                    throws ParsingException
Description copied from class: StandardDdlParser
Parses DDL ALTER TABLE AstNode based on SQL 92 specifications.

Overrides:
parseAlterTableStatement in class StandardDdlParser
Parameters:
tokens - the DdlTokenStream representing the tokenized DDL content; may not be null
parentNode - the parent AstNode node; may not be null
Returns:
the parsed ALTER TABLE AstNode
Throws:
ParsingException

parseAlterStatement

protected AstNode parseAlterStatement(DdlTokenStream tokens,
                                      AstNode parentNode)
                               throws ParsingException
Description copied from class: StandardDdlParser
Parses DDL ALTER statement based on SQL 92 specifications.

Overrides:
parseAlterStatement in class StandardDdlParser
Parameters:
tokens - the DdlTokenStream representing the tokenized DDL content; may not be null
parentNode - the parent AstNode node; may not be null
Returns:
the parsed ALTER AstNode
Throws:
ParsingException

parseCreateViewStatement

protected AstNode parseCreateViewStatement(DdlTokenStream tokens,
                                           AstNode parentNode)
                                    throws ParsingException
Parses DDL CREATE VIEW AstNode basedregisterStatementStartPhrase on SQL 92 specifications. Initial implementation here does not parse the statement in detail.

Overrides:
parseCreateViewStatement in class StandardDdlParser
Parameters:
tokens - the DdlTokenStream representing the tokenized DDL content; may not be null
parentNode - the parent AstNode node; may not be null
Returns:
the Create View node
Throws:
ParsingException
See Also:
StandardDdlParser.parseCreateViewStatement(org.modeshape.sequencer.ddl.DdlTokenStream, org.modeshape.sequencer.ddl.node.AstNode)

parseSetStatement

protected AstNode parseSetStatement(DdlTokenStream tokens,
                                    AstNode parentNode)
                             throws ParsingException
Description copied from class: StandardDdlParser
Parses DDL SET AstNode based on SQL 92 specifications.

Overrides:
parseSetStatement in class StandardDdlParser
Parameters:
tokens - the DdlTokenStream representing the tokenized DDL content; may not be null
parentNode - the parent AstNode node; may not be null
Returns:
the AstNode
Throws:
ParsingException

parseDropStatement

protected AstNode parseDropStatement(DdlTokenStream tokens,
                                     AstNode parentNode)
                              throws ParsingException
Description copied from class: StandardDdlParser
Parses DDL DROP AstNode based on SQL 92 specifications.

Overrides:
parseDropStatement in class StandardDdlParser
Parameters:
tokens - the DdlTokenStream representing the tokenized DDL content; may not be null
parentNode - the parent AstNode node; may not be null
Returns:
the parsed DROP AstNode
Throws:
ParsingException

parseColumns

protected void parseColumns(DdlTokenStream tokens,
                            AstNode tableNode,
                            boolean isAlterTable)
                     throws ParsingException
Utility method designed to parse columns within an ALTER TABLE ADD statement.

Parameters:
tokens - the tokenized DdlTokenStream of the DDL input content; may not be null
tableNode -
isAlterTable -
Throws:
ParsingException

parseSlashedStatement

protected AstNode parseSlashedStatement(DdlTokenStream tokens,
                                        String[] stmt_start_phrase,
                                        AstNode parentNode,
                                        Name mixinType)
Utility method to parse a generic statement given a start phrase and statement mixin type.

Parameters:
tokens - the tokenized DdlTokenStream of the DDL input content; may not be null
stmt_start_phrase - the string array statement start phrase
parentNode - the parent AstNode node; may not be null
mixinType - the mixin type of the newly created statement node
Returns:
the new node

getValidSchemaChildTypes

protected Name[] getValidSchemaChildTypes()

Overrides:
getValidSchemaChildTypes in class StandardDdlParser
See Also:
StandardDdlParser.getValidSchemaChildTypes()

getCustomDataTypeStartWords

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. Sub-classes should override this method to contribute DB-specific data types.

Overrides:
getCustomDataTypeStartWords in class StandardDdlParser
Returns:
list of data type start words
See Also:
StandardDdlParser.getDataTypeStartWords()


Copyright © 2008-2012 JBoss, a division of Red Hat. All Rights Reserved.