org.eclipse.datatools.sqltools.parsers.sql.query
Class SQLQueryParserManager

java.lang.Object
  extended by org.eclipse.datatools.sqltools.parsers.sql.SQLParserManager
      extended by org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager
Direct Known Subclasses:
SQLXMLQueryParserManager

public class SQLQueryParserManager
extends SQLParserManager

Author:
ckadner Parse Fascade class providing methods to parse String representations of SQL statements into a structured SQLQueryObject model representations. Options regarding the SQL source code can be provided with a SQLQuerySourceFormat, otherwise the default settings in SQLQuerySourceFormat.SQL_SOURCE_FORMAT_DEFAULT will be used. The whole parsing process can be seen as a two phase process with first the syntactical phase, the actual parse, and second the optional semantical phase, for further, higher level validation and resolving of the parse result. The result of the syntactical phase is an instance of the SQLQueryObject model, if parsing was successful, or a SQLParserException, if the given SQL statement String did not conform to the parser's syntax definition. If the first syntactical phase succeeded into an instance of the SQLQueryObject model, the second semantical phase is started, if the parser is provided a list of PostParseProcessors. The result of the semantical post parse processing is a List of SQLParseErrorInfo objects, in case of less severe semantical errors, or can be a SQLParserException, if a semantical error encountered justifies to discard the SQLQueryObject model as invalid.
See Also:
SQLQuerySourceFormat, PostParseProcessor

Field Summary
static java.util.List DEFAULT_POST_PARSE_PROCESSOR_LIST
          Default list of PostParseProcessors that can be copied and extended for use with #parse(String, SQLQuerySourceFormat, List) or #parseScript(String, SQLQuerySourceFormat, List), DEFAULT_POST_PARSE_PROCESSOR_LIST consists of: TableReferenceResolver DataTypeResolver RoutineReferenceResolver
 
Fields inherited from class org.eclipse.datatools.sqltools.parsers.sql.SQLParserManager
astElementCount, byteCount, debugPerformance, ERROR_DIAGNOSING_NONE, ERROR_DIAGNOSING_NUMBER_MAX_DEFAULT, ERROR_DIAGNOSING_TIME_MAX_DEFAULT, ERROR_DIAGNOSING_UNLIMITED, PRINTER, statementCount, timeCount
 
Constructor Summary
SQLQueryParserManager()
           
SQLQueryParserManager(SQLQuerySourceFormat sourceFormat, java.util.List postParseProcessors)
           
 
Method Summary
 QueryStatement checkSyntaxQuery(java.lang.String stmt)
          Convenience proxy method for SQLParserManager.checkSyntax(String) casting the returned SQLStatement to QueryStatement.
 java.util.List checkSyntaxQueryScript(java.lang.String script)
          Convenience proxy method for SQLParserManager.checkSyntaxScript(String) casting the returned SQLStatements to QueryStatements.
 java.util.List copyDefaultPostParseProcessorList()
          Returns a value-copy of the static list of default PostParseProcessor s returned by SQLParserManager.getDefaultPostParseProcessorList().
 java.util.List getDefaultPostParseProcessorList()
          Returns the static list of default PostParseProcessors that can be used with SQLParserManager.parse(String) or SQLParserManager.parseScript(String).
static SQLQueryParserManager getInstance()
           
 SQLParserFactory getParserFactory()
          Returns this SQLQueryParserManager's SQLQueryParserFactory.
 SQLControlParseResult parseControlStatement(java.lang.String stmt)
          Parses the given control statement string and returns the result of the parse.
 SQLQueryParseResult parseQuery(java.lang.String stmt)
          Convenience proxy method for SQLParserManager.parse(String) casting the returned SQLParseResult to SQLQueryParseResult.
 java.util.List parseQueryScript(java.lang.String script)
          Convenience proxy method for SQLParserManager.parseScript(String) casting the returned SQLParseResults to SQLQueryParseResults.
 void setParserFactory(SQLQueryParserFactory parserFactory)
          Sets this SQLQueryParserManager's parserFactory.
 void setSourceFormat(SQLQuerySourceFormat sourceFormat)
          Sets the SQL source format options for the following parses.
 
Methods inherited from class org.eclipse.datatools.sqltools.parsers.sql.SQLParserManager
checkSyntax, checkSyntaxScript, configParser, configPostParseProcessors, getErrorDiagnosingNumberMax, getErrorDiagnosingTimeMax, getPostParseProcessors, getSourceFormat, parse, parseScript, printAST, printAST, printErrorList, printParseRuntimeException, printSQL, setErrorDiagnosingNumberMax, setErrorDiagnosingTimeMax, setPostParseProcessors
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_POST_PARSE_PROCESSOR_LIST

public static final java.util.List DEFAULT_POST_PARSE_PROCESSOR_LIST
Default list of PostParseProcessors that can be copied and extended for use with #parse(String, SQLQuerySourceFormat, List) or #parseScript(String, SQLQuerySourceFormat, List), DEFAULT_POST_PARSE_PROCESSOR_LIST consists of:
  1. TableReferenceResolver
  2. DataTypeResolver
  3. RoutineReferenceResolver

Constructor Detail

SQLQueryParserManager

public SQLQueryParserManager()

SQLQueryParserManager

public SQLQueryParserManager(SQLQuerySourceFormat sourceFormat,
                             java.util.List postParseProcessors)
Parameters:
sourceFormat -
postParseProcessors -
Method Detail

getInstance

public static SQLQueryParserManager getInstance()

getParserFactory

public SQLParserFactory getParserFactory()
Returns this SQLQueryParserManager's SQLQueryParserFactory. If this SQLQueryParserManager's parserFactory is null, a new SQLQueryParserFactory will be created for this SQLQueryParserManager and returned. That is, this method never returns null!

Returns:
SQLQueryParserFactory

setParserFactory

public void setParserFactory(SQLQueryParserFactory parserFactory)
Sets this SQLQueryParserManager's parserFactory.

Note: the given parserFactory must be an appropriate instance of SQLQueryParserFactory for the runtime-type of this SQLQueryParserManager.

Throws:
IllegalArgumentException, - if given parserFactory is null or not of the appropriate runtime-type SQLQueryParserFactory

getDefaultPostParseProcessorList

public java.util.List getDefaultPostParseProcessorList()
Description copied from class: SQLParserManager
Returns the static list of default PostParseProcessors that can be used with SQLParserManager.parse(String) or SQLParserManager.parseScript(String). Returned List at least consists of:
  1. TableReferenceResolver
  2. DataTypeResolver

Note: Modifications to the properties of the PostParseProcessor s contained in the returned list, will affect post-parse-process behaviour of SQLParserManager.parse(String) or SQLParserManager.parseScript(String) on a different instance of SQLParserManager using the List of PostParseProcessors returned by invoking this method on that instance, as the List of default PostParseProcessors is hold by a static reference in the specific SQLParserManager.

Specified by:
getDefaultPostParseProcessorList in class SQLParserManager
Returns:
List of PostParseProcessor s
See Also:
SQLParserManager.copyDefaultPostParseProcessorList()

copyDefaultPostParseProcessorList

public java.util.List copyDefaultPostParseProcessorList()
Description copied from class: SQLParserManager
Returns a value-copy of the static list of default PostParseProcessor s returned by SQLParserManager.getDefaultPostParseProcessorList(). That list can be used or be extended for use with SQLParserManager.parse(String) or SQLParserManager.parseScript(String). Returned List consists at least of:
  1. TableReferenceResolver
  2. DataTypeResolver

Modifications to the properties of the PostParseProcessor s contained in this list, will not affect post-parse-process behaviour of SQLParserManager.parse(String) or SQLParserManager.parseScript(String) on a different instance of SQLParserManager using the List of PostParseProcessors returned by invoking this method on that instance.

Specified by:
copyDefaultPostParseProcessorList in class SQLParserManager
Returns:
List of PostParseProcessors

setSourceFormat

public void setSourceFormat(SQLQuerySourceFormat sourceFormat)
Description copied from class: SQLParserManager
Sets the SQL source format options for the following parses.

Note: referential modifications on the given sourceFormat will not be reflected in the parse results, unless this method is called after modifying the SQLQuerySourceFormat and before the parse.

Overrides:
setSourceFormat in class SQLParserManager

checkSyntaxQuery

public QueryStatement checkSyntaxQuery(java.lang.String stmt)
                                throws SQLParserException,
                                       SQLParserInternalException
Convenience proxy method for SQLParserManager.checkSyntax(String) casting the returned SQLStatement to QueryStatement.

Parameters:
stmt - the SQL DML statement
Returns:
(QueryStatement) super.checkSyntax(stmt);
Throws:
SQLParserException
SQLParserInternalException
See Also:
SQLParserManager.checkSyntax(String)

checkSyntaxQueryScript

public java.util.List checkSyntaxQueryScript(java.lang.String script)
                                      throws SQLParserException,
                                             SQLParserInternalException
Convenience proxy method for SQLParserManager.checkSyntaxScript(String) casting the returned SQLStatements to QueryStatements.

Parameters:
script - the SQL DML statements
Returns:
List of QueryStatements
Throws:
SQLParserException
SQLParserInternalException
See Also:
SQLParserManager.checkSyntaxScript(String)

parseQuery

public SQLQueryParseResult parseQuery(java.lang.String stmt)
                               throws SQLParserException,
                                      SQLParserInternalException
Convenience proxy method for SQLParserManager.parse(String) casting the returned SQLParseResult to SQLQueryParseResult.

Parameters:
stmt - the SQL DML statement
Returns:
(SQLQueryParseResult) super.parse(stmt);
Throws:
SQLParserException
SQLParserInternalException
See Also:
SQLParserManager.parse(String)

parseControlStatement

public SQLControlParseResult parseControlStatement(java.lang.String stmt)
                                            throws SQLParserException,
                                                   SQLParserInternalException
Parses the given control statement string and returns the result of the parse. (In ISO SQL, the CALL statement is a "control" statement.)

Parameters:
stmt - the statement string to parse
Returns:
the parse result containing the generated control model or error information
Throws:
SQLParserException - when the statement can't be parsed
SQLParserInternalException - when a parser internal error occurs

parseQueryScript

public java.util.List parseQueryScript(java.lang.String script)
                                throws SQLParserException,
                                       SQLParserInternalException
Convenience proxy method for SQLParserManager.parseScript(String) casting the returned SQLParseResults to SQLQueryParseResults.

Parameters:
script - the SQL DML statements
Returns:
List of SQLQueryParseResults
Throws:
SQLParserException
SQLParserInternalException
See Also:
SQLParserManager.parseScript(String)