Package com.mckoi.database.interpret
Class FromTableSubQuerySource
- java.lang.Object
-
- com.mckoi.database.interpret.FromTableSubQuerySource
-
- All Implemented Interfaces:
FromTableInterface
public class FromTableSubQuerySource extends java.lang.Object implements FromTableInterface
An implementation of FromTableInterface that wraps around a TableSelectExpression object as a sub-query source.
-
-
Field Summary
Fields Modifier and Type Field Description private booleancase_insensitiveSet to true if this should do case insensitive resolutions.private TableNameend_table_nameThe TableName that this source is generated to (aliased name).private TableExpressionFromSetfrom_setThe fully prepared TableExpressionFromSet object that is used to qualify variables in the table.private TableSelectExpressiontable_expressionThe wrapped object.private java.lang.Stringunique_keyA unique name given to this source that is used to reference it in a TableSet.private Variable[]varsThe list of all variable names in the resultant source.
-
Constructor Summary
Constructors Constructor Description FromTableSubQuerySource(DatabaseConnection connection, java.lang.String unique_key, TableSelectExpression table_expression, TableExpressionFromSet from_set, TableName aliased_table_name)Constructs the source.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Variable[]allColumns()Returns an array of Variable objects that references each column available in this table set item in order from left column to right column.private voidensureVarList()Makes sure the 'vars' list is created correctly.(package private) TableNamegetAliasedName()Returns the aliased table name of this sub-query or null if it is left as-is.(package private) TableExpressionFromSetgetFromSet()Returns the TableExpressionFromSet for this sub-query.(package private) TableSelectExpressiongetTableExpression()Returns the TableSelectExpression for this sub-query.java.lang.StringgetUniqueKey()Returns the unique name of this source.java.lang.StringgetUniqueName()Returns a unique name given to this table source.booleanmatchesReference(java.lang.String catalog, java.lang.String schema, java.lang.String table)Returns true if this source will match the given catalog, schema and table.private booleanmatchesVar(Variable v, java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String column)If the given Variable matches the reference then this method returns true.VariableresolveColumn(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String column)Returns a Variable that is a fully resolved form of the given column in this table set.intresolveColumnCount(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String column)Returns the number of instances we can resolve the given catalog, schema, table and column name to a column or columns within this item.voidsetCaseInsensitive(boolean status)Toggle the case sensitivity flag.private booleanstringCompare(java.lang.String str1, java.lang.String str2)
-
-
-
Field Detail
-
table_expression
private TableSelectExpression table_expression
The wrapped object.
-
from_set
private TableExpressionFromSet from_set
The fully prepared TableExpressionFromSet object that is used to qualify variables in the table.
-
end_table_name
private TableName end_table_name
The TableName that this source is generated to (aliased name). If null, we inherit from the root set.
-
unique_key
private java.lang.String unique_key
A unique name given to this source that is used to reference it in a TableSet.
-
vars
private Variable[] vars
The list of all variable names in the resultant source.
-
case_insensitive
private boolean case_insensitive
Set to true if this should do case insensitive resolutions.
-
-
Constructor Detail
-
FromTableSubQuerySource
public FromTableSubQuerySource(DatabaseConnection connection, java.lang.String unique_key, TableSelectExpression table_expression, TableExpressionFromSet from_set, TableName aliased_table_name)
Constructs the source.
-
-
Method Detail
-
getTableExpression
TableSelectExpression getTableExpression()
Returns the TableSelectExpression for this sub-query.
-
getFromSet
TableExpressionFromSet getFromSet()
Returns the TableExpressionFromSet for this sub-query.
-
getAliasedName
TableName getAliasedName()
Returns the aliased table name of this sub-query or null if it is left as-is.
-
ensureVarList
private void ensureVarList()
Makes sure the 'vars' list is created correctly.
-
getUniqueKey
public java.lang.String getUniqueKey()
Returns the unique name of this source.
-
setCaseInsensitive
public void setCaseInsensitive(boolean status)
Toggle the case sensitivity flag.
-
stringCompare
private boolean stringCompare(java.lang.String str1, java.lang.String str2)
-
matchesVar
private boolean matchesVar(Variable v, java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String column)
If the given Variable matches the reference then this method returns true.
-
getUniqueName
public java.lang.String getUniqueName()
Description copied from interface:FromTableInterfaceReturns a unique name given to this table source. No other sources will share this identifier string.- Specified by:
getUniqueNamein interfaceFromTableInterface
-
matchesReference
public boolean matchesReference(java.lang.String catalog, java.lang.String schema, java.lang.String table)Description copied from interface:FromTableInterfaceReturns true if this source will match the given catalog, schema and table. If any arguments are null then it is not included in the match.Used for 'Part.*' type glob searches.
- Specified by:
matchesReferencein interfaceFromTableInterface
-
resolveColumnCount
public int resolveColumnCount(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String column)Description copied from interface:FromTableInterfaceReturns the number of instances we can resolve the given catalog, schema, table and column name to a column or columns within this item. Note that if catalog, schema, table or column is 'null' then it means it doesn't matter.For example, say we need to resolve the column 'id' the arguments are null, null, null, "id". This may resolve to multiple columns if there is a mixture of tables with "id" as a column.
Note that parameters of 'null, null, null, null', 'null, null, null, not null', 'null, null, not null, not null', 'null, not null, not null, not null', and 'not null, not null, not null, not null' are only accepted.
- Specified by:
resolveColumnCountin interfaceFromTableInterface
-
resolveColumn
public Variable resolveColumn(java.lang.String catalog, java.lang.String schema, java.lang.String table, java.lang.String column)
Description copied from interface:FromTableInterfaceReturns a Variable that is a fully resolved form of the given column in this table set. This method does not have to check whether the parameters reference more than one column. If more than one column is referenced, the actual column returned is implementation specific.- Specified by:
resolveColumnin interfaceFromTableInterface
-
allColumns
public Variable[] allColumns()
Description copied from interface:FromTableInterfaceReturns an array of Variable objects that references each column available in this table set item in order from left column to right column.- Specified by:
allColumnsin interfaceFromTableInterface
-
-