| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.eclipse.datatools.sqltools.parsers.sql.query.postparse.TableReferenceResolver
public class TableReferenceResolver
The TableReferenceResolver resolves references between columns
 and tables as well as tables and schemas. It also populates tables with the
 columns they expose and their datatypes.
| Field Summary | |
|---|---|
| static java.lang.String | ERROR_CODE_COLUMN_AMBIGUOUSError code constant - not a message, column exists in multiple tables | 
| static java.lang.String | ERROR_CODE_COLUMN_UNRESOLVEDError code constant - not a message, column reference unresolved | 
| static java.lang.String | ERROR_CODE_DATABASE_SCHEMAS_NOTLOADEDError code constant - not a message, database schemas not loaded | 
| static java.lang.String | ERROR_CODE_NONEXISTENT_COLUMNError code constant - not a message, column not existent in table | 
| static java.lang.String | ERROR_CODE_TABLE_UNRESOLVEDError code constant - not a message, table reference unresolved | 
| Constructor Summary | |
|---|---|
| TableReferenceResolver()Note: use TableReferenceResolver(Database, String)if theDatabaseis available and the defaultSchemais know in order to properly resolve table references! | |
| TableReferenceResolver(boolean logError)Note: use TableReferenceResolver(Database, String)if theDatabaseis available and the defaultSchemais know in order to properly resolve table references! | |
| TableReferenceResolver(Database aDB,
                       java.lang.String aDefaultSchemaName)Constructs a new TableReferenceResolverwith theDatabaseconnected to which table references and column
 references inTableInDatabasewill be resolved. | |
| TableReferenceResolver(Database aDB,
                       java.lang.String aDefaultSchemaName,
                       boolean logError)Constructs a new TableReferenceResolverwith theDatabaseconnected to which table references and column
 references inTableInDatabasewill be resolved. | |
| Method Summary | |
|---|---|
|  void | config(PostParseProcessorConfiguration config)Configures this TableReferenceResolverwith theDatabaseand defaultSchemaname. | 
|  Database | getDatabase() | 
|  java.lang.String | getDefaultSchemaName() | 
|  java.util.Map | getParsedObjectsReplacementMap()Returns a Map containing parsed SQLQueryObjects mapped to
 either theSQLQueryObjectthat replaces it, or is mapped tonull, if that parsed object simply is to be removed. | 
|  java.lang.Class[] | getProcessCandidateTypes()This TableReferenceResolver's candidate types are:QueryStatementTableExpression*QuerySelectTableJoinedTableWithSpecificationTableInDatabaseValueExpressionColumn* even though TableExpressionincludes some of the other
 candidate types, more special processing steps will be executed for its
 subtypes, that are listed here separately | 
|  java.util.List | process(SQLQueryObject sqlQuery)The call back method invoked for each of the SQLQueryObjects in theSQLQueryObjectmodel
 instance returned by the parser, if theSQLQueryObjectcomplies with one of the types in theClass[]returned by
 thisPostParseProcessor.getProcessCandidateTypes() | 
|  void | resetState()If this PostParseProcessoris stateful within the context of
 oneQueryStatement, this method should reset the state, as
 it might be used for post parse processing of more than oneQueryStatement. | 
|  void | setDatabase(Database database) | 
|  void | setDefaultSchemaName(java.lang.String defaultSchemaName) | 
| Methods inherited from class java.lang.Object | 
|---|
| equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final java.lang.String ERROR_CODE_DATABASE_SCHEMAS_NOTLOADED
public static final java.lang.String ERROR_CODE_COLUMN_UNRESOLVED
public static final java.lang.String ERROR_CODE_TABLE_UNRESOLVED
public static final java.lang.String ERROR_CODE_NONEXISTENT_COLUMN
public static final java.lang.String ERROR_CODE_COLUMN_AMBIGUOUS
| Constructor Detail | 
|---|
public TableReferenceResolver()
TableReferenceResolver(Database, String) if the
 Database is available and the default Schema
 is know in order to properly resolve table references!  
 Constructs a new TableReferenceResolver without the
 Database connected to which table references and column
 references in TableInDatabase will be resolved.
 For resolving of table and column references with the database tables and
 columns use constructor TableReferenceResolver(Database,String).
TableReferenceResolver(Database, String)public TableReferenceResolver(boolean logError)
TableReferenceResolver(Database, String) if the
 Database is available and the default Schema
 is know in order to properly resolve table references!  
 Constructs a new TableReferenceResolver without the
 Database connected to which table references and column
 references in TableInDatabase will be resolved.
 For resolving of table and column references with the database tables and
 columns use constructor TableReferenceResolver(Database,String).
logError - if true errors will be logged to the console,
   default is trueTableReferenceResolver(Database, String)
public TableReferenceResolver(Database aDB,
                              java.lang.String aDefaultSchemaName)
TableReferenceResolver with the
 Database connected to which table references and column
 references in TableInDatabase will be resolved. If the optional
 default Schema name is given the unqualified table
 references (((TableInDatabase) 
 tableRef).getDatabaseTable().getSchema() == null)
 are resolved only within the context of the Schema with the
 given name aDefaultSchemaName in the Database.
 
 Note: If the parser also is provided a current default
 Schema name
 (
 org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager#parse(String, SQLQuerySourceFormat),
 SQLQuerySourceFormat.getOmitSchema()
 ),
 which will be associated with all unqualified
 table references in the SQL source parsed, the given default
 Schema name for this TableReferenceResolver
 will not have the expected effect if it the two names are different!
 
aDB - the Database connected to which table references and
            column references in TableInDatabasewill be resolvedaDefaultSchemaName - -
            optional - name of default
            org.eclipse.wst.rdb.internal.models.sql.schema.Schema,
            if specified the unqualified table references (
            ((TableInDatabase) tableRef).getDatabaseTable().getSchema() == null)
            are resolved only within the context of the
            Schema with the given name
            aDefaultSchemaName in the Database,org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager#parse(String, SQLQuerySourceFormat), 
org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager#parse(String, SQLQuerySourceFormat, List), 
org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager#parseScript(String, SQLQuerySourceFormat), 
org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager#parseScript(String, SQLQuerySourceFormat, List), 
SQLQuerySourceFormat.getOmitSchema()
public TableReferenceResolver(Database aDB,
                              java.lang.String aDefaultSchemaName,
                              boolean logError)
TableReferenceResolver with the
 Database connected to which table references and column
 references in TableInDatabase will be resolved. If the optional
 default Schema name is given the unqualified table
 references (((TableInDatabase) 
 tableRef).getDatabaseTable().getSchema() == null)
 are resolved only within the context of the Schema with the
 given name aDefaultSchemaName in the Database.
 
 Note: If the parser also is provided a current default
 Schema name
 (
 org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager#parse(String, SQLQuerySourceFormat),
 SQLQuerySourceFormat.getOmitSchema()
 ),
 which will be associated with all unqualified
 table references in the SQL source parsed, the given default
 Schema name for this TableReferenceResolver
 will not have the expected effect if it the two names are different!
 
aDB - the Database connected to which table references and
            column references in TableInDatabasewill be resolvedaDefaultSchemaName - -
            optional - name of default
            org.eclipse.wst.rdb.internal.models.sql.schema.Schema,
            if specified the unqualified table references (
            ((TableInDatabase) tableRef).getDatabaseTable().getSchema() == null)
            are resolved only within the context of the
            Schema with the given name
            aDefaultSchemaName in the DatabaselogError - if true errors will be logged to the console,
   default is trueorg.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager#parse(String, SQLQuerySourceFormat), 
org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager#parse(String, SQLQuerySourceFormat, List), 
org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager#parseScript(String, SQLQuerySourceFormat), 
org.eclipse.datatools.sqltools.parsers.sql.query.SQLQueryParserManager#parseScript(String, SQLQuerySourceFormat, List), 
SQLQuerySourceFormat.getOmitSchema()| Method Detail | 
|---|
public Database getDatabase()
public void setDatabase(Database database)
database - The database to set.public java.lang.String getDefaultSchemaName()
public void setDefaultSchemaName(java.lang.String defaultSchemaName)
defaultSchemaName - The defaultSchemaName to set.public java.lang.Class[] getProcessCandidateTypes()
TableReferenceResolver's candidate types are:
 QueryStatementTableExpression*QuerySelectTableJoinedTableWithSpecificationTableInDatabaseValueExpressionColumnTableExpression includes some of the other
 candidate types, more special processing steps will be executed for its
 subtypes, that are listed here separately
getProcessCandidateTypes in interface PostParseProcessorClass[] of SQLObject typesorg.eclipse.datatools.sqltools.parsers.sql.query.postparse.PostParseProcessor#getProcessCandidateTypes()public void config(PostParseProcessorConfiguration config)
TableReferenceResolver with the
 Database and default Schema name.
config in interface PostParseProcessorconfig - the PostParseProcessorConfiguration
        providing the Database and the default
        Schema name
public java.util.List process(SQLQueryObject sqlQuery)
                       throws SQLParserException
PostParseProcessorSQLQueryObjects in the SQLQueryObject model
 instance returned by the parser, if the SQLQueryObject
 complies with one of the types in the Class[] returned by
 this PostParseProcessor.getProcessCandidateTypes()
process in interface PostParseProcessorsqlQuery - instance of one of the types in the Class[]
                 returned by PostParseProcessor.getProcessCandidateTypes()
SQLParseErrorInfo
                 objects, with information about the error encountered,
                 must not be null
SQLParserException - if the error encountered is severe enough to
                 discard the instance of the SQLQueryObject model
                 returned by the parserpublic java.util.Map getParsedObjectsReplacementMap()
PostParseProcessorSQLQueryObjects mapped to
 either the SQLQueryObject that replaces it, or is mapped to
 null, if that parsed object simply is to be removed.
 This method will be invoked after this PostParseProcessor
 is done processing one QueryStatement before the
 PostParseProcessor.resetState() method is called.
 This method should return a mapping, if during the post parse processing
 SQLQueryObjects are found that are determined to have been
 created by the parser mistakenly, because the parser did not have the
 knowledge about context or semantics. This then
 PostParseProcessor might create a substitution for it or
 simply delete it by mapping the original SQLQueryObject to
 null.
 By providing this mapping, invalid SQLQueryObjects can be
 removed from the parser's parsed-element-list and therefore will not be
 subject to further post parse processing of other
 PostParseProcessors.
 
 SQLQueryObject originally created by parserSQLQueryObject created by this
        PostParseProcessor to substitute the originally
                created by the parser
getParsedObjectsReplacementMap in interface PostParseProcessorSQLQueryObjects mapped to
                either the SQLQueryObject that replaces it to
                null, if that parsed object simply is to be removedpublic void resetState()
PostParseProcessorPostParseProcessor is stateful within the context of
 one QueryStatement, this method should reset the state, as
 it might be used for post parse processing of more than one
 QueryStatement.
 This method is invoked after the SQLParserManager
 bottom-up processed the SQLQueryObject elements of a
 QueryStatement up to the top/root-element - the
 QueryStatement object itself.
resetState in interface PostParseProcessororg.eclipse.datatools.sqltools.parsers.sql.query.postparse.PostParseProcessor#resetState()| 
 | ||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||