org.modeshape.sequencer.ddl.dialect.derby

## Class DerbyDdlParser

- java.lang.Object
- - org.modeshape.sequencer.ddl.StandardDdlParser
  - - org.modeshape.sequencer.ddl.dialect.derby.DerbyDdlParser

- All Implemented Interfaces:
    DdlConstants, DdlConstants.StatementStartPhrases, DdlParser, DerbyDdlConstants, DerbyDdlConstants.DerbyStatementStartPhrases

      public class DerbyDdlParser
      extends StandardDdlParser
      implements DerbyDdlConstants, DerbyDdlConstants.DerbyStatementStartPhrases

  Derby-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.derby.DerbyDdlConstants

      `DerbyDdlConstants.DerbyDataTypes, DerbyDdlConstants.DerbyStatementStartPhrases`

    - ### 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
    Modifier and Type | Field and Description
    --- | ---
    `protected static List<String[]>` | `derbyDataTypeStrings`
    `static String` | `ID` The Derby parser identifier.

    - ### Fields inherited from interface org.modeshape.sequencer.ddl.dialect.derby.DerbyDdlConstants

      `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, NOT, NULL, 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.derby.DerbyDdlConstants.DerbyStatementStartPhrases

      `ALTER_PHRASES, CREATE_PHRASES, DROP_PHRASES, MISC_PHRASES, SET_PHRASES, STMT_CREATE_FUNCTION, STMT_CREATE_INDEX, STMT_CREATE_PROCEDURE, STMT_CREATE_ROLE, STMT_CREATE_SYNONYM, STMT_CREATE_TRIGGER, STMT_CREATE_UNIQUE_INDEX, STMT_DECLARE_GLOBAL_TEMP_TABLE, STMT_DROP_FUNCTION, STMT_DROP_INDEX, STMT_DROP_PROCEDURE, STMT_DROP_ROLE, STMT_DROP_SYNONYM, STMT_DROP_TRIGGER, STMT_LOCK_TABLE, STMT_RENAME_INDEX, STMT_RENAME_TABLE, STMT_SET_CURRENT_ISOLATION, STMT_SET_CURRENT_SCHEMA, STMT_SET_CURRENT_SQLID, STMT_SET_ISOLATION, STMT_SET_ROLE, STMT_SET_SCHEMA, 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

    Constructors
    Constructor and Description
    `DerbyDdlParser()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `protected String[]` | `getValidSchemaChildTypes()`
    `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` | `parseAlterTableStatement(DdlTokenStream tokens, AstNode parentNode)` Parses DDL ALTER TABLE `AstNode` based on SQL 92 specifications.
    `protected void` | `parseColumnDefinition(DdlTokenStream tokens, AstNode tableNode, boolean isAlterTable)` Utility method to parse the actual column definition.
    `protected void` | `parseColumns(DdlTokenStream tokens, AstNode tableNode, boolean isAlterTable)` Utility method designed to parse columns within an ALTER TABLE ADD statement.
    `protected AstNode` | `parseCreateFunction(DdlTokenStream tokens, AstNode parentNode)` Parses DDL CREATE FUNCTION statement
    `protected AstNode` | `parseCreateIndex(DdlTokenStream tokens, AstNode parentNode)` Parses DDL CREATE INDEX
    `protected AstNode` | `parseCreateProcedure(DdlTokenStream tokens, AstNode parentNode)` Parses DDL CREATE PROCEDURE statement
    `protected AstNode` | `parseCreateRole(DdlTokenStream tokens, AstNode parentNode)` Parses DDL CREATE ROLE statement
    `protected AstNode` | `parseCreateStatement(DdlTokenStream tokens, AstNode parentNode)` Parses DDL CREATE statement based 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 void` | `parseGrantPrivileges(DdlTokenStream tokens, List<AstNode> privileges)`
    `protected AstNode` | `parseGrantStatement(DdlTokenStream tokens, AstNode parentNode)` Parses DDL GRANT statement `AstNode` based on SQL 92 specifications.

    - ### Methods inherited from class org.modeshape.sequencer.ddl.StandardDdlParser

      `addProblem, addProblem, areNextTokensCreateTableOptions, attachNewProblem, computeScore, consumeComment, consumeIdentifier, consumeParenBoundedTokens, doUseTerminator, equals, getCurrentMarkedPosition, getDatatypeParser, getDataTypeStartWords, getIdentifyingKeywords, getProblems, getRootNode, getStatementTypeName, getTableElementsString, getTerminator, handleUnknownToken, hashCode, integer, isColumnDefinitionStart, isComment, isMissingTerminatorNode, isTableConstraint, isTerminator, isTestMode, isValidSchemaChild, markEndOfStatement, markStartOfStatement, mergeNodes, missingTerminatorNode, nodeFactory, parse, parseAlterStatement, parseCollateClause, parseColumnConstraint, parseColumnNameList, parseColumnsAndConstraints, parseConstraintAttributes, parseCreateAssertionStatement, parseCreateCharacterSetStatement, parseCreateCollationStatement, parseCreateDomainStatement, parseCreateSchemaStatement, parseCreateTableOptions, parseCreateTableStatement, parseCreateTranslationStatement, parseCreateViewStatement, parseDefaultClause, parseIgnorableStatement, parseIgnorableStatement, parseInsertStatement, parseName, parseNameList, parseNextCreateTableOption, parseNextStatement, parseReferences, parseRevokeStatement, parseSetStatement, parseSingleTerminatedColumnDefinition, parseStatement, parseTableConstraint, parseUntilCommaOrTerminator, parseUntilSemiColon, parseUntilTerminator, parseUntilTerminatorIgnoreEmbeddedStatements, postProcess, removeMissingTerminatorNodes, rewrite, 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`

- - ### Field Detail

    - #### ID

          public static final String ID

      The Derby parser identifier.
      See Also:
        Constant Field Values

    - #### derbyDataTypeStrings

          protected static final List<String[]> derbyDataTypeStrings

  - ### Constructor Detail

    - #### DerbyDdlParser

          public DerbyDdlParser()

  - ### Method Detail

    - #### 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)`

    - #### 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()`

    - #### getValidSchemaChildTypes

          protected String[] getValidSchemaChildTypes()

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

    - #### 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

      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`
      See Also:
        `StandardDdlParser.parseCreateStatement(org.modeshape.sequencer.ddl.DdlTokenStream, org.modeshape.sequencer.ddl.node.AstNode)`

    - #### parseCreateIndex

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

      Parses DDL CREATE INDEX
      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 INDEX
      Throws:
        `ParsingException`

    - #### parseCreateFunction

          protected AstNode parseCreateFunction(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`

    - #### parseCreateProcedure

          protected AstNode parseCreateProcedure(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`

    - #### parseCreateRole

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

      Parses DDL CREATE ROLE 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 ROLE statement node
      Throws:
        `ParsingException`

    - #### parseDropStatement

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

      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`
      See Also:
        `StandardDdlParser.parseDropStatement(org.modeshape.sequencer.ddl.DdlTokenStream, org.modeshape.sequencer.ddl.node.AstNode)`

    - #### parseGrantStatement

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

      Parses DDL GRANT statement `AstNode` based on SQL 92 specifications. Syntax for tables GRANT privilege-type ON [TABLE] { table-Name | view-Name } TO grantees Syntax for routines GRANT EXECUTE ON { FUNCTION | PROCEDURE } routine-designator TO grantees Syntax for roles GRANT roleName [ {, roleName }* ] TO grantees privilege-types ALL PRIVILEGES | privilege-list privilege-list table-privilege {, table-privilege }* table-privilege DELETE | INSERT | REFERENCES [column list] | SELECT [column list] | TRIGGER | UPDATE [column list] column list ( column-identifier {, column-identifier}* ) GRANT
      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`
      See Also:
        `StandardDdlParser.parseGrantStatement(org.modeshape.sequencer.ddl.DdlTokenStream, org.modeshape.sequencer.ddl.node.AstNode)`

    - #### parseGrantPrivileges

          protected void parseGrantPrivileges(DdlTokenStream tokens,
                                  List<AstNode> privileges)
                                       throws ParsingException

      Overrides:
        `parseGrantPrivileges` in class `StandardDdlParser`
      Throws:
        `ParsingException`
      See Also:
        `StandardDdlParser.parseGrantPrivileges(org.modeshape.sequencer.ddl.DdlTokenStream, java.util.List)`

    - #### parseAlterTableStatement

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

      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`
      See Also:
        `StandardDdlParser.parseAlterTableStatement(org.modeshape.sequencer.ddl.DdlTokenStream, org.modeshape.sequencer.ddl.node.AstNode)`

    - #### parseColumnDefinition

          protected void parseColumnDefinition(DdlTokenStream tokens,
                                   AstNode tableNode,
                                   boolean isAlterTable)
                                        throws ParsingException

      Utility method to parse the actual column definition. SQL-92 Structural Specification ::= { | } [ ] [ ... ] [ ]
      Overrides:
        `parseColumnDefinition` in class `StandardDdlParser`
      Parameters:
        `tokens` - the `DdlTokenStream` representing the tokenized DDL content; may not be null
        `isAlterTable` - true if in-line constraint is part of add column in alter table statement
      Throws:
        `ParsingException`
      See Also:
        `StandardDdlParser.parseColumnDefinition(org.modeshape.sequencer.ddl.DdlTokenStream, org.modeshape.sequencer.ddl.node.AstNode, boolean)`

    - #### 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`

    - #### 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-2014 JBoss, a division of Red Hat. All Rights Reserved.