|
||||||||||
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_AMBIGUOUS
Error code constant - not a message, column exists in multiple tables |
static java.lang.String |
ERROR_CODE_COLUMN_UNRESOLVED
Error code constant - not a message, column reference unresolved |
static java.lang.String |
ERROR_CODE_DATABASE_SCHEMAS_NOTLOADED
Error code constant - not a message, database schemas not loaded |
static java.lang.String |
ERROR_CODE_NONEXISTENT_COLUMN
Error code constant - not a message, column not existent in table |
static java.lang.String |
ERROR_CODE_TABLE_UNRESOLVED
Error code constant - not a message, table reference unresolved |
Constructor Summary | |
---|---|
TableReferenceResolver()
Note: use TableReferenceResolver(Database, String) if the
Database is available and the default Schema
is know in order to properly resolve table references! |
|
TableReferenceResolver(boolean logError)
Note: use TableReferenceResolver(Database, String) if the
Database is available and the default Schema
is know in order to properly resolve table references! |
|
TableReferenceResolver(Database aDB,
java.lang.String aDefaultSchemaName)
Constructs a new TableReferenceResolver with the
Database connected to which table references and column
references in TableInDatabase will be resolved. |
|
TableReferenceResolver(Database aDB,
java.lang.String aDefaultSchemaName,
boolean logError)
Constructs a new TableReferenceResolver with the
Database connected to which table references and column
references in TableInDatabase will be resolved. |
Method Summary | |
---|---|
void |
config(PostParseProcessorConfiguration config)
Configures this TableReferenceResolver with the
Database and default Schema name. |
Database |
getDatabase()
|
java.lang.String |
getDefaultSchemaName()
|
java.util.Map |
getParsedObjectsReplacementMap()
Returns a Map containing parsed SQLQueryObject s mapped to
either the SQLQueryObject that replaces it, or is mapped to
null , if that parsed object simply is to be removed. |
java.lang.Class[] |
getProcessCandidateTypes()
This TableReferenceResolver 's candidate types are:
QueryStatement
TableExpression *
QuerySelect
TableJoined
TableWithSpecification
TableInDatabase
ValueExpressionColumn
* even though TableExpression includes 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 SQLQueryObject s 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() |
void |
resetState()
If this PostParseProcessor 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 . |
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 true
TableReferenceResolver(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 TableInDatabase
will 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 TableInDatabase
will 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
logError
- if true
errors will be logged to the console,
default is true
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()
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:
QueryStatement
TableExpression
*QuerySelect
TableJoined
TableWithSpecification
TableInDatabase
ValueExpressionColumn
TableExpression
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 PostParseProcessor
Class[]
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 PostParseProcessor
config
- the PostParseProcessorConfiguration
providing the Database
and the default
Schema
namepublic java.util.List process(SQLQueryObject sqlQuery) throws SQLParserException
PostParseProcessor
SQLQueryObject
s 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 PostParseProcessor
sqlQuery
- 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()
PostParseProcessor
SQLQueryObject
s 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
SQLQueryObject
s 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 SQLQueryObject
s can be
removed from the parser's parsed-element-list and therefore will not be
subject to further post parse processing of other
PostParseProcessor
s.
SQLQueryObject
originally created by parserSQLQueryObject
created by this
PostParseProcessor
to substitute the originally
created by the parser
getParsedObjectsReplacementMap
in interface PostParseProcessor
SQLQueryObject
s mapped to
either the SQLQueryObject
that replaces it to
null
, if that parsed object simply is to be removedpublic void resetState()
PostParseProcessor
PostParseProcessor
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 PostParseProcessor
org.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 |