@Immutable public class DdlParsers extends Object
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.
Modifier and Type | Class and Description |
---|---|
class |
DdlParsers.ParsingResult
Represents a parsing result of one parser parsing one DDL input.
|
Modifier and Type | Field and Description |
---|---|
static List<DdlParser> |
BUILTIN_PARSERS |
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.
|
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.
|
public DdlParsers()
built-in parsers
.public DdlParsers(List<DdlParser> parsers)
parsers
- the list of parsers; may be empty or null if the built-in parsers
should be usedpublic DdlParser getParser(String id)
id
- the identifier of the parser being requested (cannot be null
or empty)null
if not foundpublic Set<DdlParser> getParsers()
null
or empty)public AstNode parseUsing(String ddl, String parserId) throws ParsingException
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)AstNode
ParsingException
- if there is an error parsing the supplied DDL contentIllegalArgumentException
- if a parser with the specified identifier cannot be foundpublic List<DdlParsers.ParsingResult> parseUsing(String ddl, String firstParserId, String secondParserId, String... additionalParserIds) throws ParsingException
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 valueDdlParsers.ParsingResult
instances, one for each parser, ordered from highest score to lowest score (never
null
or empty)ParsingException
- if there is an error parsing the supplied DDL contentIllegalArgumentException
- if a parser with the specified identifier cannot be foundpublic List<DdlParsers.ParsingResult> parseUsingAll(String ddl) throws ParsingException
ddl
- the DDL being parsed (cannot be null
or empty)DdlParsers.ParsingResult
instances, one for each parser, ordered from highest score to lowest scoreParsingException
- if there is an error parsing the supplied DDL contentIllegalArgumentException
- if a parser with the specified identifier cannot be foundpublic AstNode parse(String ddl, String fileName) throws ParsingException
root node
of the AST representation.ddl
- content string; may not be nullfileName
- the approximate name of the file containing the DDL content; may be null if this is not knownAstNode
ParsingException
- if there is an error parsing the supplied DDL contentCopyright © 2008–2016 JBoss, a division of Red Hat. All rights reserved.