org.modeshape.sequencer.ddl

## Class DdlParsers

- java.lang.Object
- - org.modeshape.sequencer.ddl.DdlParsers

-     @Immutable
      public class DdlParsers
      extends Object

  A set of parsers capable of understanding DDL file content. This class can be used directly to create an `AstNode` tree representing nodes and properties for DDL statement components.

  You can also provide an input or parent `AstNode` node as the starting point for your tree.

  The parser is based on the SQL-92 and extended by specific dialects. These dialect-specific parsers provide db-specific parsing of db-specific statements of statement extensions, features or properties.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `class` | `DdlParsers.ParsingResult` Represents a parsing result of one parser parsing one DDL input.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static List<DdlParser>` | `BUILTIN_PARSERS`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DdlParsers()` Create an instance that uses all of the `built-in parsers`.
    `DdlParsers(List<DdlParser> parsers)` Create an instance that uses the supplied parsers, in order.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `DdlParser` | `getParser(String id)`
    `Set<DdlParser>` | `getParsers()`
    `AstNode` | `parse(String ddl, String fileName)` Parse the supplied DDL content and return the `root node` of the AST representation.
    `AstNode` | `parseUsing(String ddl, String parserId)`
    `List<DdlParsers.ParsingResult>` | `parseUsing(String ddl, String firstParserId, String secondParserId, String... additionalParserIds)` Parse the supplied DDL using multiple parsers, returning the result of each parser with its score in the order of highest scoring to lowest scoring.
    `List<DdlParsers.ParsingResult>` | `parseUsingAll(String ddl)` Parse the supplied DDL using all registered parsers, returning the result of each parser with its score in the order of highest scoring to lowest scoring.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### BUILTIN_PARSERS

          public static final List<DdlParser> BUILTIN_PARSERS

  - ### Constructor Detail

    - #### DdlParsers

          public DdlParsers()

      Create an instance that uses all of the `built-in parsers`.

    - #### DdlParsers

          public DdlParsers(List<DdlParser> parsers)

      Create an instance that uses the supplied parsers, in order.
      Parameters:
        `parsers` - the list of parsers; may be empty or null if the `built-in parsers` should be used

  - ### Method Detail

    - #### getParser

          public DdlParser getParser(String id)

      Parameters:
        `id` - the identifier of the parser being requested (cannot be `null` or empty)
      Returns:
        the parser or `null` if not found

    - #### getParsers

          public Set<DdlParser> getParsers()

      Returns:
        a copy of the DDL parsers used in this instance (never `null` or empty)

    - #### parseUsing

          public AstNode parseUsing(String ddl,
                           String parserId)
                             throws ParsingException

      Parameters:
        `ddl` - the DDL being parsed (cannot be `null` or empty)
        `parserId` - the identifier of the parser to use (can be `null` or empty if best matched parser should be used)
      Returns:
        the root tree `AstNode`
      Throws:
        `ParsingException` - if there is an error parsing the supplied DDL content
        `IllegalArgumentException` - if a parser with the specified identifier cannot be found

    - #### parseUsing

          public List<DdlParsers.ParsingResult> parseUsing(String ddl,
                                                  String firstParserId,
                                                  String secondParserId,
                                                  String... additionalParserIds)
                                                    throws ParsingException

      Parse the supplied DDL using multiple parsers, returning the result of each parser with its score in the order of highest scoring to lowest scoring.
      Parameters:
        `ddl` - the DDL being parsed (cannot be `null` or empty)
        `firstParserId` - the identifier of the first parser to use (cannot be `null` or empty)
        `secondParserId` - the identifier of the second parser to use (cannot be `null` or empty)
        `additionalParserIds` - the identifiers of additional parsers that should be used; may be empty but not contain a null identifier value
      Returns:
        the list of `DdlParsers.ParsingResult` instances, one for each parser, ordered from highest score to lowest score (never `null` or empty)
      Throws:
        `ParsingException` - if there is an error parsing the supplied DDL content
        `IllegalArgumentException` - if a parser with the specified identifier cannot be found

    - #### parseUsingAll

          public List<DdlParsers.ParsingResult> parseUsingAll(String ddl)
                                                       throws ParsingException

      Parse the supplied DDL using all registered parsers, returning the result of each parser with its score in the order of highest scoring to lowest scoring.
      Parameters:
        `ddl` - the DDL being parsed (cannot be `null` or empty)
      Returns:
        the list or `DdlParsers.ParsingResult` instances, one for each parser, ordered from highest score to lowest score
      Throws:
        `ParsingException` - if there is an error parsing the supplied DDL content
        `IllegalArgumentException` - if a parser with the specified identifier cannot be found

    - #### parse

          public AstNode parse(String ddl,
                      String fileName)
                        throws ParsingException

      Parse the supplied DDL content and return the `root node` of the AST representation.
      Parameters:
        `ddl` - content string; may not be null
        `fileName` - the approximate name of the file containing the DDL content; may be null if this is not known
      Returns:
        the root tree `AstNode`
      Throws:
        `ParsingException` - if there is an error parsing the supplied DDL content

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