com.google.visualization.datasource.query
Class CompoundFilter

java.lang.Object
  extended by com.google.visualization.datasource.query.QueryFilter
      extended by com.google.visualization.datasource.query.CompoundFilter

public class CompoundFilter
extends QueryFilter

A compound filter. This filter is a logical aggregation of other filters. Currently, union (OR) and intersection (AND) are supported. An OR complex filter matches if any of its sub-filters match. An AND complex filter matches if all of its sub-filters match.

Author:
Yonatan B.Y.

Nested Class Summary
static class CompoundFilter.LogicalOperator
          The available types of CompoundFilter.
 
Constructor Summary
CompoundFilter(CompoundFilter.LogicalOperator operator, java.util.List<QueryFilter> subFilters)
          Constructs a compound filter of the given type, with the given sub-filters.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
protected  java.util.List<AggregationColumn> getAggregationColumns()
          
 java.util.Set<java.lang.String> getAllColumnIds()
          Returns all the columnIds this filter uses, in this case the union of all the results of getAllColumnIds() of all its subfilters.
 CompoundFilter.LogicalOperator getOperator()
          Returns the logical operator associated with this CompoundFilter.
 java.util.List<ScalarFunctionColumn> getScalarFunctionColumns()
          Returns a list of all scalarFunctionColumns this filter uses, in this case the union of all the results of getScalarFunctionColumns() of all its sub-filters.
 java.util.List<QueryFilter> getSubFilters()
          Returns the list of sub-filters associated with this CompoundFilter.
 int hashCode()
           
 boolean isMatch(DataTable table, TableRow row)
          Implements isMatch (from the QueryFilter interface) by recursively calling isMatch on each of the sub-filters, and using the compound filter type to determine the result.
 java.lang.String toQueryString()
          Returns a string that, when parsed by the query parser, should return an identical filter.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompoundFilter

public CompoundFilter(CompoundFilter.LogicalOperator operator,
                      java.util.List<QueryFilter> subFilters)
Constructs a compound filter of the given type, with the given sub-filters.

Parameters:
operator - The type of this compound filter.
subFilters - The collection of all sub-filters of this compound filter.
Method Detail

isMatch

public boolean isMatch(DataTable table,
                       TableRow row)
Implements isMatch (from the QueryFilter interface) by recursively calling isMatch on each of the sub-filters, and using the compound filter type to determine the result. Note: 1. This uses short-circuit evaluation, i.e., an OR filter decides on a true result the moment it finds a true result among its sub-filters, without continuing to check the rest of the sub-filters; and dually for an AND filter. 2. The sub-filters are evaluated in order. 3. If the collection of sub-filters is empty, a RuntimeException is thrown.

Specified by:
isMatch in class QueryFilter
Parameters:
table - The table containing this row.
row - The row to check.
Returns:
true if this row should be part of the result set, false otherwise.

getAllColumnIds

public java.util.Set<java.lang.String> getAllColumnIds()
Returns all the columnIds this filter uses, in this case the union of all the results of getAllColumnIds() of all its subfilters.

Specified by:
getAllColumnIds in class QueryFilter
Returns:
All the columnIds this filter uses.

getScalarFunctionColumns

public java.util.List<ScalarFunctionColumn> getScalarFunctionColumns()
Returns a list of all scalarFunctionColumns this filter uses, in this case the union of all the results of getScalarFunctionColumns() of all its sub-filters.

Specified by:
getScalarFunctionColumns in class QueryFilter
Returns:
A list of all scalarFunctionColumns this filter uses.

getAggregationColumns

protected java.util.List<AggregationColumn> getAggregationColumns()

Specified by:
getAggregationColumns in class QueryFilter
Returns:
A list of all aggregation columns this filter uses.

getSubFilters

public java.util.List<QueryFilter> getSubFilters()
Returns the list of sub-filters associated with this CompoundFilter.

Returns:
The list of sub-filters associated with this CompoundFilter.

getOperator

public CompoundFilter.LogicalOperator getOperator()
Returns the logical operator associated with this CompoundFilter.

Returns:
The logical operator associated with this CompoundFilter.

toQueryString

public java.lang.String toQueryString()
Returns a string that, when parsed by the query parser, should return an identical filter. The string returned does not contain the WHERE keyword.

Specified by:
toQueryString in class QueryFilter
Returns:
A string form of this filter.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object


Copyright © 2009 Google. All Rights Reserved.