|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.datatools.modelbase.sql.query.helper.TableHelper
public class TableHelper
Provides utility functions related to tables and columns.
Field Summary | |
---|---|
static java.lang.String |
DELIMITED_IDENTIFIER_QUOTE
This is the default quote character to use for delimited identifiers like "Col1". |
Constructor Summary | |
---|---|
TableHelper()
|
Method Summary | |
---|---|
static java.lang.String |
createFromClauseForStatement(QueryStatement stmt)
Creates the From Clause with the tables used in the given SQLStatement. |
static java.lang.String |
createFromClauseForStatement(SQLQueryObject stmt)
Creates the From Clause with the tables used in the given SQLStatement. |
static TableInDatabase |
createTableExpressionForTable(Table table)
Creates and returns a TableInDatabase object for the given
Table object and initializes its list of SQLValueExpressColumn
objects corresponding to each column of the table. |
static java.util.List |
exposeEffectiveResultColumns(QueryExpressionBody qryExprBody)
Adds ValueExpressionColumn objects to the column list of
the given QueryExpressionBody for each named result column of
the query. |
static java.util.List |
exposeEffectiveResultColumns(TableExpression tableExpr)
Populates the given tableExpr 's columnList with
ValueExpressionColumn s, with name ,
dataType and in ordering, so the given
tableExpr can be handled like a TableInDatabase . |
static java.util.List |
exposeEffectiveResultColumns(WithTableReference withTable)
Populates the given withTable 's columnList with
ValueExpressionColumn s, with name ,
dataType and in ordering, so the given
tableExpr can be handled like a TableInDatabase . |
static java.util.Set |
findColumnReferencesInGroupingExpression(GroupingExpression groupingExpr)
Returns a Set containing all ValueExpressionColumn s found
in the given GroupingExpression . |
static java.util.Set |
findColumnReferencesInGroupingSpecification(GroupingSpecification groupingSpec)
Returns a Set containing all ValueExpressionColumn s found
in the given GroupingSpecification . |
static java.util.Set |
findColumnReferencesInGroupingSpecificationList(java.util.List groupingSpecList)
Returns a Set containing all ValueExpressionColumn s found
in the given GroupingSpecification list. |
static java.util.Set |
findColumnReferencesInOrderBySpecification(OrderBySpecification orderBySpec)
Returns a Set containing all ValueExpressionColumn s found
in the given OrderBySpecification . |
static java.util.Set |
findColumnReferencesInOrderBySpecificationList(java.util.List orderBySpecList)
Returns a Set containing all ValueExpressionColumn s found
in the given List of OrderBySpecification . |
static java.util.Set |
findColumnReferencesInPredicate(Predicate predicate)
Returns a Set containing all, not necessarily distinct, ValueExpressionColumn s found in the given
Predicate . |
static java.util.Set |
findColumnReferencesInQueryExpressionBody(QueryExpressionBody queryExprBody)
Returns a Set containing all ValueExpressionColumn s found in
the given QueryExpressionBody . |
static java.util.Set |
findColumnReferencesInQueryExpressionRoot(QueryExpressionRoot queryExprRoot)
Returns a Set containing all ValueExpressionColumn s found in
the given QueryExpressionRoot . |
static java.util.Set |
findColumnReferencesInQueryMergeStatement(QueryMergeStatement mergeStmt)
Returns a set containing all the column value expression objects in the given statement. |
static java.util.Set |
findColumnReferencesInQueryResultSpecification(QueryResultSpecification queryResult)
Returns a Set containing all ValueExpressionColumn s found
in the given QueryResultSpecification . |
static java.util.Set |
findColumnReferencesInQueryResultSpecificationList(java.util.List queryResultSpecList)
Returns a Set containing all ValueExpressionColumn s found
in the given QueryResultSpecification list. |
static java.util.Set |
findColumnReferencesInQuerySelectStatement(QuerySelectStatement querySelect)
Returns a Set containing all ValueExpressionColumn s found
in the given QuerySelectStatement . |
static java.util.Set |
findColumnReferencesInQueryUpdateStatement(QueryUpdateStatement updateStmt)
Returns a Set containing all ValueExpressionColumn s found
in the given QueryUpdateStatement . |
static java.util.Set |
findColumnReferencesInSearchCondition(QuerySearchCondition searchCond)
Returns a Set of not neccessarily distinct ValueExpressionColumn s found in the given
SearchCondition , means you have to expect duplicates regarding
column names. |
static java.util.Set |
findColumnReferencesInTableReference(TableReference tableRef)
Returns a Set containing all the ValueExpressionColumn s found
in the given TableReference . |
static java.util.Set |
findColumnReferencesInTableReferenceList(java.util.List tableRefList)
Returns a Set containing all the ValueExpressionColumn s found
in the given TableReference list. |
static java.util.Set |
findColumnReferencesInUpdateAssignmentExpr(UpdateAssignmentExpression updateAssignmentExpr)
Returns a Set containing all ValueExpressionColumn s found
in the given List of UpdateAssignmentExpression . |
static java.util.Set |
findColumnReferencesInUpdateAssignmentExprList(java.util.List updateAssignmentExprList)
Returns a Set containing all ValueExpressionColumn s found
in the given List of UpdateAssignmentExpression s. |
static java.util.Set |
findColumnReferencesInUpdateSourceExprList(UpdateSourceExprList updateSourceExprList)
Returns a Set containing all ValueExpressionColumn s found
in the given UpdateSourceExprList . |
static java.util.Set |
findColumnReferencesInValueExpression(QueryValueExpression valueExpr)
Returns a Set containing all ValueExpressionColumn s found
in the given QueryValueExpression . |
static java.util.Set |
findColumnReferencesInValueExpressionList(java.util.List valueExprList)
Returns a Set containing all ValueExpressionColumn s found
in the given ValueExpression list. |
static java.util.Set |
findColumnReferencesInValuesRow(ValuesRow valuesRow)
Returns a Set containing all ValueExpressionColumn s found in
the given ValuesRow . |
static java.util.Set |
findColumnReferencesInWithTableSpecification(WithTableSpecification withTableSpec)
Returns a Set containing all the ValueExpressionColumn s found in
the given WithTableSpecification . |
static TableExpression |
findTableExpressionInTableExpressionList(java.lang.String schemaName,
java.lang.String tableName,
java.util.List tableExprList)
Finds in the given List of TableExpression s the one
TableExpression with a name that matches the given
tableName and, if a schemaName is
given, with a Schema whose name matches the
schemaName . |
static TableExpression |
findTableExpressionsByNameOrAlias(java.lang.String tableNameOrAlias,
java.util.List tableExprList,
java.lang.String defaultSchemaName)
Finds in the given List of TableExpression s the
TableExpression with a name that matches the given
tableNameOrAlias or a tableCorrelation with
a name that matches tableNameOrAlias . |
static ValueExpressionColumn |
getColumnExpressionForColumn(TableExpression tableExpr,
Column column)
Gets the SQLValueExpressionColumn corresponding to the given Column, in the given table. |
static ValueExpressionColumn |
getColumnExpressionForName(TableExpression tableExpr,
java.lang.String columnName)
Returns the ValueExpressionColumn from the given
TableExpression , if the ValueExpressionColumn 's
name matches the given column name. |
static ValueExpressionColumn |
getColumnExpressionForName(TableReference tableRef,
java.lang.String columnName)
Returns the ValueExpressionColumn from the given
TableReference matching the given columnName . |
static ValueExpressionColumn |
getColumnExpressionForNameRecursively(TableExpression tableExpr,
java.lang.String columnName)
Returns the ValueExpressionColumn from the given
TableExpression , if the ValueExpressionColumn 's
name matches the given columnName . |
static Column |
getColumnForColumnExpression(TableExpression tableExpr,
ValueExpressionColumn colExpr)
Returns the Column matching the name of the SQLValueExpressionColumn from the given SQLTableExpression. |
static Column |
getColumnForName(TableInDatabase tableInDB,
java.lang.String columnName)
Returns the Column matching the columnName from the given TableInDatabase |
static Column |
getColumnForName(TableReference tableRef,
java.lang.String columnName)
Returns the Column matching the columnName from the given TableReference. |
static Column |
getColumnForName(WithTableReference withTableRef,
java.lang.String columnName)
Returns the Column matching the columnName from the given WithTableReference . |
static java.util.List |
getEffectiveResultColumns(TableReference tableRef)
Returns a List of ValueExpressionColumn s,
with name , dataType and in ordering,
so the given tableRef can be handled like a
TableInDatabase . |
static java.lang.String |
getExposedTableName(TableExpression tableExpr)
Returns the name or the alias name of the given TableExpression tableExpr depending on, whether
or not the tableExpr has a
TableCorrelation . |
static java.util.List |
getForeignKeyColumns(Table table)
Returns the list of Columns that are part of the Foreign key constraint for the given table. |
static java.lang.String |
getFullTableName(Table table)
Returns fully qualified name for the given table. |
static ValueExpressionColumn |
getOrCreateColumnExpression(java.lang.String columnName,
TableExpression tableExpr)
Returns the ValueExpressionColumn with the given
columnName from the given tableExpression 's
columnList or, if the given tableExpression 's
columnList does not contain a
ValueExpressionColumn with the given columnName ,
creates a new ValueExpressionColumn with the given
columnName and returns it. |
static java.util.List |
getPrimaryKeyColumns(Table table)
Returns the list of Columns that are part of the primary key constraint for the given table. |
static ResultColumn |
getResultColumnForAliasOrColumnName(QueryExpressionBody tableQuery,
java.lang.String columnName)
Returns the ResultColumn contained in the
selectClause of the given QueryExpressionBody ,
whose name matches the given columnName
or whose referenced ValueExpression is of type
ValueExpressionColumn and has a name matching
the given columnName . |
static ResultColumn |
getResultColumnForName(QueryExpressionBody tableQuery,
java.lang.String columnName)
Returns the ResultColumn contained in the
selectClause of the given QueryExpressionBody ,
whose name matches the given columnName . |
static java.util.List |
getResultColumnsOfQueryExpression(QueryExpressionBody queryExpr)
Returns the ResultColumn s of the given
QueryExpressionBody queryExpr . |
static Schema |
getSchemaForTableInDatabase(TableInDatabase tableInDB)
|
static java.lang.String |
getSchemaNameForTableExpression(TableExpression tableExpr)
Returns the name of the Schema that the given
TableExpression is part of or null , if the
given TableExpression has no reference to a
Schema or the referenced Schema 's name is
null . |
static TableExpression |
getTableExpressionForNamedColumn(java.lang.String aTableName,
java.lang.String aColName,
java.util.List aTableExprList)
Gets the table object from the given list of table references that is associated with (contains) a column with the given table and column name. |
static TableExpression |
getTableExpressionFromTableExprList(java.lang.String aTableName,
java.util.List aTableExprList)
Gets the TableExpression object from the given list of table references by name or correlation name ("AS"-alias). |
static java.util.List |
getTableExpressionsInTableReference(TableReference tableRef)
Retrieves a List of TableExpression s from the given
TableReference . |
static java.util.List |
getTableExpressionsInTableReferenceList(java.util.List tableReferenceList)
Retrieves a List of TableExpression s from the given List of
TableReference s. |
static Table |
getTableForTableExpression(TableExpression tableExpr)
Returns the Table from the given SQLTableExpression if there is one otherwise return null. |
static java.util.List |
getTableInDatabaseInTableReferenceList(java.util.List tableReferenceList)
Retrieves the TableInDatabase objects contained in the given
List of TableReference s. |
static boolean |
isForeignKey(Column column)
Returns true if the given column is part of Foreign key constraint. |
static boolean |
isForeignKey(ValueExpressionColumn colExpr)
Returns true if the given ValueExpressionColumn is part of Foreign key constraint. |
static boolean |
isPrimaryKey(Column column)
Returns true if the given column is part of a primary key constraint. |
static boolean |
isPrimaryKey(ValueExpressionColumn colExpr)
Returns true if the given ValueExpressionColumn is part of a primary key constraint. |
static boolean |
isTableReferencedByColumnWithName(TableExpression tableExpr,
java.lang.String referencedByColumnName)
Returns the true if the given tableExpr
is referenced by another ValueExpressionColumn
with the same name as the given referencedByColumnName |
static void |
populateTableExpressionColumns(TableInDatabase tableInDB,
Table databaseTable)
Populates the list of ValueExpressionColumn in the given table expression using the columns in the given Table object |
static void |
removeColumnExpressionFromTableIfNotReferenced(ValueExpressionColumn col)
Removes a columnExpression from its tableExpression if it has no other references to objects other than its tableExpression. |
static void |
resolveColumnTableReferences(java.util.Collection unresolvedColumns,
java.util.List aTableRefList)
Link table references in column expressions to tables in the given list of tables (that is, the From clause), copies DataType s as well. |
static void |
resolveResultTableReferences(java.util.List resultTableList,
java.util.List tableExprList)
Resolves the TableReference s of the
ResultTableAllColumns in the given
resultTableList with the TableExpression s
in the given tableExprList . |
static void |
setTableAliasInTableExpression(TableExpression tableExpr,
java.lang.String alias)
Assigns the alias to the given TableExpression. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String DELIMITED_IDENTIFIER_QUOTE
Note: this character can vary depending on the database type, so use of this constant is not recommended. Instead get the identifier quote character from the database configuration.
Constructor Detail |
---|
public TableHelper()
Method Detail |
---|
public static java.lang.String createFromClauseForStatement(QueryStatement stmt)
stmt
- the QueryStatement from which is used to get list of tables
public static java.lang.String createFromClauseForStatement(SQLQueryObject stmt)
stmt
- the QueryStatement from which is used to get list of tables
public static TableInDatabase createTableExpressionForTable(Table table)
TableInDatabase
object for the given
Table
object and initializes its list of SQLValueExpressColumn
objects corresponding to each column of the table.
table
- the Table for which we need a SQLRDBTable
public static java.util.List exposeEffectiveResultColumns(QueryExpressionBody qryExprBody)
ValueExpressionColumn
objects to the column list of
the given QueryExpressionBody
for each named result column of
the query. This is useful in case the given QueryExpressionBody
is used as a nested query, that is, as a table reference within another
QuerySelect
, so that nested query can be treated like
any other table reference with a column list.
qryExprBody
- the query whose columns should be exposed
ValueExpressionColumn
spublic static java.util.List exposeEffectiveResultColumns(TableExpression tableExpr)
tableExpr
's columnList
with
ValueExpressionColumn
s, with name
,
dataType
and in ordering, so the given
tableExpr
can be handled like a TableInDatabase
.
tableExpr
- the table expression whose columns should be expose
ValueExpressionColumn
spublic static java.util.List exposeEffectiveResultColumns(WithTableReference withTable)
withTable
's columnList
with
ValueExpressionColumn
s, with name
,
dataType
and in ordering, so the given
tableExpr
can be handled like a TableInDatabase
.
withTable
- the WITH table whose columns should be exposed
ValueExpressionColumn
spublic static java.util.Set findColumnReferencesInGroupingExpression(GroupingExpression groupingExpr)
ValueExpressionColumn
s found
in the given GroupingExpression
.
public static java.util.Set findColumnReferencesInGroupingSpecification(GroupingSpecification groupingSpec)
ValueExpressionColumn
s found
in the given GroupingSpecification
.
public static java.util.Set findColumnReferencesInGroupingSpecificationList(java.util.List groupingSpecList)
ValueExpressionColumn
s found
in the given GroupingSpecification
list.
public static java.util.Set findColumnReferencesInOrderBySpecification(OrderBySpecification orderBySpec)
ValueExpressionColumn
s found
in the given OrderBySpecification
.
public static java.util.Set findColumnReferencesInOrderBySpecificationList(java.util.List orderBySpecList)
ValueExpressionColumn
s found
in the given List of OrderBySpecification
.
public static java.util.Set findColumnReferencesInPredicate(Predicate predicate)
ValueExpressionColumn
s found in the given
Predicate
. This means you have to expect duplicate
ValueExpressionColumn
s regarding their column names.
predicate
-
public static java.util.Set findColumnReferencesInQueryExpressionBody(QueryExpressionBody queryExprBody)
ValueExpressionColumn
s found in
the given QueryExpressionBody
.
public static java.util.Set findColumnReferencesInQueryExpressionRoot(QueryExpressionRoot queryExprRoot)
ValueExpressionColumn
s found in
the given QueryExpressionRoot
.
public static java.util.Set findColumnReferencesInQueryMergeStatement(QueryMergeStatement mergeStmt)
mergeStmt
- the statement from which column expressions are wanted
public static java.util.Set findColumnReferencesInQueryResultSpecification(QueryResultSpecification queryResult)
ValueExpressionColumn
s found
in the given QueryResultSpecification
.
public static java.util.Set findColumnReferencesInQueryResultSpecificationList(java.util.List queryResultSpecList)
ValueExpressionColumn
s found
in the given QueryResultSpecification
list.
public static java.util.Set findColumnReferencesInQuerySelectStatement(QuerySelectStatement querySelect)
ValueExpressionColumn
s found
in the given QuerySelectStatement
.
public static java.util.Set findColumnReferencesInQueryUpdateStatement(QueryUpdateStatement updateStmt)
ValueExpressionColumn
s found
in the given QueryUpdateStatement
.
public static java.util.Set findColumnReferencesInSearchCondition(QuerySearchCondition searchCond)
ValueExpressionColumn
s found in the given
SearchCondition
, means you have to expect duplicates regarding
column names.
searchCond
-
public static java.util.Set findColumnReferencesInTableReference(TableReference tableRef)
ValueExpressionColumn
s found
in the given TableReference
.
public static java.util.Set findColumnReferencesInTableReferenceList(java.util.List tableRefList)
ValueExpressionColumn
s found
in the given TableReference
list.
public static java.util.Set findColumnReferencesInUpdateAssignmentExpr(UpdateAssignmentExpression updateAssignmentExpr)
ValueExpressionColumn
s found
in the given List of UpdateAssignmentExpression
.
updateAssignmentExpr
- the UpdateAssignmentExpression
to search in
ValueExpressionColumn
s foundpublic static java.util.Set findColumnReferencesInUpdateAssignmentExprList(java.util.List updateAssignmentExprList)
ValueExpressionColumn
s found
in the given List of UpdateAssignmentExpression
s.
updateAssignmentExprList
- the list of UpdateAssignmentExpression
s to search in
ValueExpressionColumn
s foundpublic static java.util.Set findColumnReferencesInUpdateSourceExprList(UpdateSourceExprList updateSourceExprList)
ValueExpressionColumn
s found
in the given UpdateSourceExprList
.
public static java.util.Set findColumnReferencesInValueExpression(QueryValueExpression valueExpr)
ValueExpressionColumn
s found
in the given QueryValueExpression
.
valueExpr
-
ValueExpressionColumn
spublic static java.util.Set findColumnReferencesInValueExpressionList(java.util.List valueExprList)
ValueExpressionColumn
s found
in the given ValueExpression
list.
public static java.util.Set findColumnReferencesInValuesRow(ValuesRow valuesRow)
ValueExpressionColumn
s found in
the given ValuesRow
.
public static java.util.Set findColumnReferencesInWithTableSpecification(WithTableSpecification withTableSpec)
ValueExpressionColumn
s found in
the given WithTableSpecification
.
public static TableExpression findTableExpressionInTableExpressionList(java.lang.String schemaName, java.lang.String tableName, java.util.List tableExprList)
TableExpression
s the one
TableExpression
with a name that matches the given
tableName
and, if a schemaName
is
given, with a Schema
whose name matches the
schemaName
. If no schemaName
is given,
the first TableExpression
found without regard of its
Schema
, will be returned.
schemaName
- optional the schema name of the table to findtableName
- the name of the table to findtableExprList
- the list of TableExpression
s to search
TableExpression
or null
public static TableExpression findTableExpressionsByNameOrAlias(java.lang.String tableNameOrAlias, java.util.List tableExprList, java.lang.String defaultSchemaName)
TableExpression
s the
TableExpression
with a name that matches the given
tableNameOrAlias
or a tableCorrelation
with
a name that matches tableNameOrAlias
. If multiple tables
are found, preference is given to the first. Note: if no table is
found by alias name but more than one table is found by name, the table
that is in the default Schema specified by defaultSchemaName
will be returned, or, if no defaultSchemaName
is given the
table to be returned must have no Schema
reference.
If you are searching for a table with name and schema, use
findTableExpressionInTableExpressionList(String, String, List)
Note: If only one table is found with the given
tableNameOrAlias
, but it is Schema-qualified, it will be
returned also.
Example: tableNameOrAlias = "T1"
and the given tableExprList
contains:
tableExprList* | return |
---|---|
T1 T2 | T1 |
S1.T1 T1 | T1 |
S1.T1 AS T1 S2.T1 | S1.T1 |
S1.T1 S1.T2 | S1.T1 |
S1.T2 S1.T3 | null |
S1.T1 S2.T1 | null |
tableNameOrAlias
- the name of the table to find or its correlation nametableExprList
- the list of TableExpression
s to searchdefaultSchemaName
- optional, if given and no table is found by alias name but
tables, that have no alias are found by name, the table to be
returned has to be in the default Schema
TableExpression
or null
public static ValueExpressionColumn getColumnExpressionForColumn(TableExpression tableExpr, Column column)
tableExpr
- the table to searchcolumn
- the column to be looked for
public static ValueExpressionColumn getColumnExpressionForName(TableExpression tableExpr, java.lang.String columnName)
ValueExpressionColumn
from the given
TableExpression
, if the ValueExpressionColumn
's
name matches the given column name.
NOTE: If there is more than one ValueExpressionColumn
with the same name (both representing one and the same real Column
),
the first one found will be returned.
tableExpr
- the TableReference to search for the matching column namecolumnName
- the name of the ValueExpressionColumn to search for
null
public static ValueExpressionColumn getColumnExpressionForName(TableReference tableRef, java.lang.String columnName)
ValueExpressionColumn
from the given
TableReference
matching the given columnName
.
If the given TableReference
is of type
QueryExpressionBody
ResultColumn
s of the
QuerySelect
statement will be regarded too.
NOTE:
If there is more than one ValueExpressionColumn
with the same
name (both representing one and the same real Column
), the
first one found will be returned.
tableRef
- the TableReference to search for the matching columncolumnName
- the name of the column to search for
null
public static ValueExpressionColumn getColumnExpressionForNameRecursively(TableExpression tableExpr, java.lang.String columnName)
ValueExpressionColumn
from the given
TableExpression
, if the ValueExpressionColumn
's
name matches the given columnName
.
If the given TableExpression
is of type
QueryExpressionBody
, this method will recursively analyze
its effective result columns, e.g. the ResultColumn
s of a
nested QuerySelect
statement will be considered, too.
NOTE: If there is more than one ValueExpressionColumn
with
the same name (both representing one and the same real Column
), the
first one found will be returned.
tableExpr
- the TableReference to search for the matching column namecolumnName
- the name of the ValueExpressionColumn search for
null
public static Column getColumnForColumnExpression(TableExpression tableExpr, ValueExpressionColumn colExpr)
tableExpr
- the SQLTableExpression to search for the matching
SQLValueExpressionColumncolExpr
- the SQLValueExpressionColumn to search for
public static Column getColumnForName(TableInDatabase tableInDB, java.lang.String columnName)
tableInDB
- the TableInDatabase to search for the matching column namecolumnName
- the name of the column to search for
public static Column getColumnForName(TableReference tableRef, java.lang.String columnName)
tableRef
- the TableReference to search for the matching column namecolumnName
- the String name of the column to search
public static Column getColumnForName(WithTableReference withTableRef, java.lang.String columnName)
WithTableReference
.
withTableRef
- the WithTableReference
to search for the
matching column namecolumnName
- the name of the column to search for
public static java.util.List getEffectiveResultColumns(TableReference tableRef)
ValueExpressionColumn
s,
with name
, dataType
and in ordering,
so the given tableRef
can be handled like a
TableInDatabase
.
tableRef
-
ValueExpressionColumn
spublic static java.lang.String getExposedTableName(TableExpression tableExpr)
TableExpression
tableExpr
depending on, whether
or not the tableExpr
has a
TableCorrelation
.
tableExpr
- the TableExpression for which the exposed name is needed
public static java.util.List getForeignKeyColumns(Table table)
table
- the Table for which list of Foreign key columns needed
public static java.lang.String getFullTableName(Table table)
table
- the Table for which the fully qualified name is needed
public static ValueExpressionColumn getOrCreateColumnExpression(java.lang.String columnName, TableExpression tableExpr)
ValueExpressionColumn
with the given
columnName
from the given tableExpression
's
columnList
or, if the given tableExpression
's
columnList
does not contain a
ValueExpressionColumn
with the given columnName
,
creates a new ValueExpressionColumn
with the given
columnName
and returns it.
columnName
- tableExpr
- optional TableExpression
, if provided the
existing ValueExpressionColumn
with the given
columnName
will be returned from the
tableExpr
's columnList
ValueExpressionColumn
- already existing or newly
createdpublic static java.util.List getPrimaryKeyColumns(Table table)
table
- the Table for which list of primary key columns needed
public static ResultColumn getResultColumnForAliasOrColumnName(QueryExpressionBody tableQuery, java.lang.String columnName)
ResultColumn
contained in the
selectClause
of the given QueryExpressionBody
,
whose name
matches the given columnName
or whose referenced ValueExpression
is of type
ValueExpressionColumn
and has a name
matching
the given columnName
.
tableQuery
- the TableReference to search for the matching column namecolumnName
- the name of the ValueExpressionColumn to search
ResultColumn
null
public static ResultColumn getResultColumnForName(QueryExpressionBody tableQuery, java.lang.String columnName)
ResultColumn
contained in the
selectClause
of the given QueryExpressionBody
,
whose name
matches the given columnName
.
tableQuery
- the TableReference to search for the matching column namecolumnName
- the name of the ValueExpressionColumn to search for
null
public static java.util.List getResultColumnsOfQueryExpression(QueryExpressionBody queryExpr)
ResultColumn
s of the given
QueryExpressionBody queryExpr
.
NOTE:
If the given queryExpr
's
QueryResultSpecification
is of type
ResultTableAllColumns
('SELECT * FROM ...') an empty List
will be returned.
queryExpr
- the QueryExpressionBody
for which the
ResultColumn
s will be returned
ResultColumn
s of the given queryExpr
public static Schema getSchemaForTableInDatabase(TableInDatabase tableInDB)
tableInDB
-
public static java.lang.String getSchemaNameForTableExpression(TableExpression tableExpr)
Schema
that the given
TableExpression
is part of or null
, if the
given TableExpression
has no reference to a
Schema
or the referenced Schema
's name is
null
.
tableExpr
-
Schema
name or null
public static TableExpression getTableExpressionForNamedColumn(java.lang.String aTableName, java.lang.String aColName, java.util.List aTableExprList)
aTableName
- a table name to use to search for a table referenceaColName
- a column name to use to search for a table referenceaTableExprList
- a list of table references to search
public static TableExpression getTableExpressionFromTableExprList(java.lang.String aTableName, java.util.List aTableExprList)
aTableName
- a table name or alias name to use to search for a table referenceaTableExprList
- a list of table references to search
public static java.util.List getTableExpressionsInTableReference(TableReference tableRef)
TableExpression
s from the given
TableReference
.
tableRef
-
public static java.util.List getTableExpressionsInTableReferenceList(java.util.List tableReferenceList)
TableExpression
s from the given List of
TableReference
s.
tableReferenceList
-
public static Table getTableForTableExpression(TableExpression tableExpr)
tableExpr
- the SQLTableExpression for which the table is needed
public static java.util.List getTableInDatabaseInTableReferenceList(java.util.List tableReferenceList)
TableInDatabase
objects contained in the given
List of TableReference
s. This method might be useful to
find all the references to database tables in the FROM-clause of a
QuerySelect
.
tableReferenceList
- List of TableReference
s
TableInDatabase
s contained in the given
tableReferenceList
public static boolean isForeignKey(Column column)
column
- the Column that needs to check for the Foreign key constraint
public static boolean isForeignKey(ValueExpressionColumn colExpr)
colExpr
- the ValueExpressionColumn that needs to check for the Foreign key constraint
public static boolean isPrimaryKey(Column column)
column
- the Column that needs to check for the primary key constraint
public static boolean isPrimaryKey(ValueExpressionColumn colExpr)
colExpr
- the ValueExpressionColumn that needs to check for the primary key constraint
public static boolean isTableReferencedByColumnWithName(TableExpression tableExpr, java.lang.String referencedByColumnName)
true
if the given tableExpr
is referenced by another ValueExpressionColumn
with the same name as the given referencedByColumnName
tableExpr
- the TableReference searched for the matching column name referencereferencedByColumnName
- the String name of the ValueExpressionColumn to be searched in the
list of column references to the given tableExpr
true
if another column was found to reference the given tableExpr
public static void populateTableExpressionColumns(TableInDatabase tableInDB, Table databaseTable)
tableInDB
- the TableInDatabase to be populateddatabaseTable
- the Table object used in populating the tableExpressionpublic static void removeColumnExpressionFromTableIfNotReferenced(ValueExpressionColumn col)
columnExpr
- public static void resolveColumnTableReferences(java.util.Collection unresolvedColumns, java.util.List aTableRefList)
DataType
s as well.
Note: the given set of ValueExpressionColumn
s
aColumnSet
will be modified directly. The resolved
columns will be removed from the set.
Note: TableExpression
s directly contained in the given
aTableRefList
will be given preference before
TableExpression
s found contained indeirectly within
TableNested
s or TableJoined
s, when two
TableReference
s with the same name
are found.
unresolvedColumns
- will be modified, see NOTEaTableRefList
- a list of tables to use to resolve column referencespublic static void resolveResultTableReferences(java.util.List resultTableList, java.util.List tableExprList)
TableReference
s of the
ResultTableAllColumns
in the given
resultTableList
with the TableExpression
s
in the given tableExprList
.
resultTableList
- a List of ResultTableAllColumns
tableExprList
- a List of TableExpression
spublic static void setTableAliasInTableExpression(TableExpression tableExpr, java.lang.String alias)
tableExpr
- the TableExpression for which alias needs to be setalias
- the String value for the alias
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |