org.modeshape.sequencer.ddl.dialect.mysql

## Class MySqlDdlParser

- java.lang.Object
- - org.modeshape.sequencer.ddl.StandardDdlParser
  - - org.modeshape.sequencer.ddl.dialect.mysql.MySqlDdlParser

- All Implemented Interfaces:
    DdlConstants, DdlConstants.StatementStartPhrases, DdlParser, MySqlDdlConstants, MySqlDdlConstants.MySqlStatementStartPhrases

      public class MySqlDdlParser
      extends StandardDdlParser
      implements MySqlDdlConstants, MySqlDdlConstants.MySqlStatementStartPhrases

  MySql-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.mysql.MySqlDdlConstants

      `MySqlDdlConstants.MySqlDataTypes, MySqlDdlConstants.MySqlStatementStartPhrases`

    - ### 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
    --- | ---
    `static String` | `ID` The MySQL parser identifier.

    - ### Fields inherited from interface org.modeshape.sequencer.ddl.dialect.mysql.MySqlDdlConstants

      `CUSTOM_KEYWORDS, DTYPE_BIGINT, DTYPE_BINARY, DTYPE_BLOB, DTYPE_BOOL, DTYPE_BOOLEAN, DTYPE_DATETIME, DTYPE_DOUBLE, DTYPE_ENUM, DTYPE_FIXED, DTYPE_LONGBLOB, DTYPE_LONGTEXT, DTYPE_MEDIUMBLOB, DTYPE_MEDIUMINT, DTYPE_MEDIUMTEXT, DTYPE_NATIONAL_VARCHAR, DTYPE_SET, DTYPE_TEXT, DTYPE_TINYBLOB, DTYPE_TINYINT, DTYPE_TINYTEXT, DTYPE_VARBINARY, DTYPE_YEAR, STMT_ALTER_ALGORITHM, STMT_ALTER_DATABASE, STMT_ALTER_DEFINER, STMT_ALTER_EVENT, STMT_ALTER_FUNCTION, STMT_ALTER_IGNORE_TABLE, STMT_ALTER_LOGFILE_GROUP, STMT_ALTER_OFFLINE_IGNORE_TABLE, STMT_ALTER_OFFLINE_TABLE, STMT_ALTER_ONLINE_IGNORE_TABLE, STMT_ALTER_ONLINE_TABLE, STMT_ALTER_PROCEDURE, STMT_ALTER_SCHEMA, STMT_ALTER_SERVER, STMT_ALTER_SQL_SECURITY, STMT_ALTER_TABLESPACE`

    - ### 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.mysql.MySqlDdlConstants.MySqlStatementStartPhrases

      `ALTER_PHRASES, CREATE_PHRASES, DROP_PHRASES, MISC_PHRASES, SET_PHRASES, STMT_CREATE_DATABASE, STMT_CREATE_DEFINER, STMT_CREATE_EVENT, STMT_CREATE_FUNCTION, STMT_CREATE_INDEX, STMT_CREATE_LOGFILE_GROUP, STMT_CREATE_PROCEDURE, STMT_CREATE_SERVER, STMT_CREATE_TABLESPACE, STMT_CREATE_TRIGGER, STMT_CREATE_UNIQUE_INDEX, STMT_DROP_DATABASE, STMT_DROP_EVENT, STMT_DROP_FUNCTION, STMT_DROP_INDEX, STMT_DROP_LOGFILE_GROUP, STMT_DROP_OFFLINE_INDEX, STMT_DROP_ONLINE_INDEX, STMT_DROP_PROCEDURE, STMT_DROP_SERVER, STMT_DROP_TABLESPACE, STMT_DROP_TRIGGER, STMT_RENAME_DATABASE, STMT_RENAME_SCHEMA, STMT_RENAME_TABLE`

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

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

    - ### 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, getValidSchemaChildTypes, handleUnknownToken, hashCode, integer, isColumnDefinitionStart, isComment, isMissingTerminatorNode, isTableConstraint, isTerminator, isTestMode, isValidSchemaChild, markEndOfStatement, markStartOfStatement, mergeNodes, missingTerminatorNode, nodeFactory, parse, parseCollateClause, parseColumnConstraint, parseColumnDefinition, parseColumnNameList, parseColumnsAndConstraints, parseConstraintAttributes, parseCreateAssertionStatement, parseCreateCharacterSetStatement, parseCreateCollationStatement, parseCreateDomainStatement, parseCreateSchemaStatement, parseCreateTableOptions, parseCreateTableStatement, parseCreateTranslationStatement, parseCreateViewStatement, parseDefaultClause, parseGrantPrivileges, parseGrantStatement, 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 MySQL parser identifier.
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### MySqlDdlParser

          public MySqlDdlParser()

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

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

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

    - #### parseAlterStatement

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

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

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

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

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

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