isql.predicate
Class WhereView

java.lang.Object
  extended by isql.predicate.WhereView

public class WhereView
extends java.lang.Object

Contains the tables involved in a predicate (a section of the where clause) with the indices of their rows that are resulting from the predicate filter. For example the predicate: user.name = 'brian' will return a view containing, for the table user, the indices of all the rows that have the field name content equal to the text "brian". You can see the content of the object as a view in the database, where instead to have all the values that have been filtered and joined for the view, you have the indices of the tables rows

Author:
SHZ Oct 12, 2007

Field Summary
static java.lang.Integer NO_ROW
          since WhereView is equivalent to a VIEW in the database, the row of the view must have values for each involved table, even if the table rows don't match the filter.
 
Method Summary
 void addAll(WhereView otherView)
          Adds the content of another view to this one
 void addEmptyTable(java.lang.String table)
          Adds a table (if it does not already exist) in the view, without any index
 void addEmptyTables(java.lang.String[] arrTable)
          add tables without any index
 void addRowIndex(int index)
          Adds a single row index for each table of the view
 void addTableWithRowIndices(java.lang.String table, java.util.List<java.lang.Integer> lstRowIndices)
          Adds a table to the view with all the indices
static WhereView fromColumns(ColumnValues values)
          Builds the view from the column values.
static WhereView fromExpression(IExpression exp)
          Builds a view from an expression (the expression contains the involved columns, and therefore the involved tables).
 java.util.List<java.lang.Integer> getIndicesInTable(java.lang.String table)
          Returns the indices for one specific table in this view
 int getRowsNumber()
          Since all the tables have by definition the same number of rows (possibly empty) the number of rows of the view is the same as the number of rows of the first table
 java.lang.String[] getTableNames()
          Retursn the names of the tables that are included in the view
static java.lang.String[] getTablesFromColumnKeys(java.util.Collection<ColumnKey> colKey)
          column keys identifies columns and they are composed by the table and column name.
 boolean hasTable(java.lang.String table)
          Checks if a table already exists in the view
static WhereView none(java.lang.String[] arrTable)
          Builds a view that, for all tables, does not contain any row index
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_ROW

public static final java.lang.Integer NO_ROW
since WhereView is equivalent to a VIEW in the database, the row of the view must have values for each involved table, even if the table rows don't match the filter. In this case we say that the table does not have value for that row (equivalent to the NULL value in the database)

Method Detail

fromColumns

public static WhereView fromColumns(ColumnValues values)
Builds the view from the column values. Remember that at the start of the evaluation the column values can have different size, since they can be seen as different tables (which have different length)

Parameters:
values - the column values
Returns:
the view containing the tables indexes

none

public static WhereView none(java.lang.String[] arrTable)
Builds a view that, for all tables, does not contain any row index

Parameters:
arrTable - the tables
Returns:
the view

fromExpression

public static WhereView fromExpression(IExpression exp)
Builds a view from an expression (the expression contains the involved columns, and therefore the involved tables). The view is just a set of table without row indexes

Parameters:
exp - the expression
Returns:
the view

addAll

public void addAll(WhereView otherView)
Adds the content of another view to this one

Parameters:
otherView - the other view

addRowIndex

public void addRowIndex(int index)
Adds a single row index for each table of the view

Parameters:
index - the row index

addTableWithRowIndices

public void addTableWithRowIndices(java.lang.String table,
                                   java.util.List<java.lang.Integer> lstRowIndices)
Adds a table to the view with all the indices

Parameters:
table -
lstRowIndices -

getIndicesInTable

public java.util.List<java.lang.Integer> getIndicesInTable(java.lang.String table)
Returns the indices for one specific table in this view

Parameters:
table - the table to get the indices for
Returns:
the indicess

addEmptyTables

public void addEmptyTables(java.lang.String[] arrTable)
add tables without any index

Parameters:
arrTable -

getTableNames

public java.lang.String[] getTableNames()
Retursn the names of the tables that are included in the view

Returns:
an array with the tables names

addEmptyTable

public void addEmptyTable(java.lang.String table)
Adds a table (if it does not already exist) in the view, without any index

Parameters:
table - the name of the table to add

hasTable

public boolean hasTable(java.lang.String table)
Checks if a table already exists in the view

Parameters:
table - the name of the table to check
Returns:
true if the table exists, false otherwise

getTablesFromColumnKeys

public static java.lang.String[] getTablesFromColumnKeys(java.util.Collection<ColumnKey> colKey)
column keys identifies columns and they are composed by the table and column name. This method extracts the table names for all columns

Parameters:
colKey - a collection of column keys
Returns:
the table names of the columns, without repetition

getRowsNumber

public int getRowsNumber()
                  throws ISQLException
Since all the tables have by definition the same number of rows (possibly empty) the number of rows of the view is the same as the number of rows of the first table

Returns:
the number of rows in the view
Throws:
ISQLException