isql
Class ClausesBuilder

java.lang.Object
  extended by isql.ClausesBuilder

public class ClausesBuilder
extends java.lang.Object

Builds the structures to execute the SQL query for all the SQL query parts (SELECT, WHERE, GROUP BY...)

Author:
SHZ Dec 6, 2007

Constructor Summary
ClausesBuilder(ILogger log)
          Constructor
 
Method Summary
 Groups buildGroupBy(java.util.List<ISQLSelectParser.TableColumn> lstGroupByTableColumn, ColumnValuesWithRowsNumber values)
          Builds a Groups structure (containing the group by relationships) from the grammars output
 java.util.Map<java.lang.String,IExpression> buildSelect(java.util.List<ISQLSelectParser.SelectItem> lstSelect, ColumnValues values, Groups groups)
          Builds a map alias -> result expression from the select clause.
 ColumnValuesWithRowsNumber buildViewAfterWhere(ColumnValues values, WhereView whereView)
          from the result of the where clause (where view) and the original column values builds a new set of column values
 IPredicate buildWhere(ColumnValues valuesOriginal, ISQLSelectParser.ISearchCondition where)
          Returns the where clause in form of a predicate tree
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClausesBuilder

public ClausesBuilder(ILogger log)
Constructor

Parameters:
log - the logger
Method Detail

buildGroupBy

public Groups buildGroupBy(java.util.List<ISQLSelectParser.TableColumn> lstGroupByTableColumn,
                           ColumnValuesWithRowsNumber values)
                    throws ISQLException
Builds a Groups structure (containing the group by relationships) from the grammars output

Parameters:
lstGroupByTableColumn - the columns part of the GROUP BY clause (from ANTLR)
values - the result set at this point in the query evaluation
Returns:
the Groups structure
Throws:
ISQLException

buildSelect

public java.util.Map<java.lang.String,IExpression> buildSelect(java.util.List<ISQLSelectParser.SelectItem> lstSelect,
                                                               ColumnValues values,
                                                               Groups groups)
                                                        throws ISQLException
Builds a map alias -> result expression from the select clause. To do that it applies the GROUP BY clause to the current result set

Parameters:
lstSelect - the list of select items
values - the result set at this point of the query evaluation
groups - the structure defining the groups of the GROUP BY clause
Returns:
the map alias -> result expression
Throws:
ISQLException

buildViewAfterWhere

public ColumnValuesWithRowsNumber buildViewAfterWhere(ColumnValues values,
                                                      WhereView whereView)
                                               throws ISQLException
from the result of the where clause (where view) and the original column values builds a new set of column values

Parameters:
values - the column in the tables with their values. Since they are of different tables, they can still have different size
whereView - the view resulting from the application of the where clause to the column values
Returns:
the result set after the where
Throws:
ISQLException

buildWhere

public IPredicate buildWhere(ColumnValues valuesOriginal,
                             ISQLSelectParser.ISearchCondition where)
                      throws ISQLException
Returns the where clause in form of a predicate tree

Parameters:
valuesOriginal - the column in the tables with their values. Since they are of different tables, they can still have different size
where - the where condition extracted from ANTLR
Returns:
the resulting predicate tree
Throws:
ISQLException