com.google.visualization.datasource.query
Class AggregationColumn

java.lang.Object
  extended by com.google.visualization.datasource.query.AbstractColumn
      extended by com.google.visualization.datasource.query.AggregationColumn

public class AggregationColumn
extends AbstractColumn

A column that is referred to by an aggregation, for example, min(c1).

Author:
Yonatan B.Y.

Field Summary
static java.lang.String COLUMN_AGGRGATION_TYPE_SEPARATOR
          When creating the ID of the column, this separates the column on which aggregation is performed and the type of aggregation performed on it.
 
Constructor Summary
AggregationColumn(SimpleColumn aggregatedColumn, AggregationType aggregationType)
          Creates a new instance of this class with the given column and aggregation type.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 SimpleColumn getAggregatedColumn()
          Returns the column to aggregate.
 AggregationType getAggregationType()
          Returns the requested aggregation type.
 java.util.List<AggregationColumn> getAllAggregationColumns()
          Returns a list of all aggregation columns.
 java.util.List<ScalarFunctionColumn> getAllScalarFunctionColumns()
          Returns a list of all scalar function columns.
 java.util.List<java.lang.String> getAllSimpleColumnIds()
          Returns a list of all simple (primitive) column IDs included in this AbstractColumn.
 java.util.List<SimpleColumn> getAllSimpleColumns()
          Returns a list of all simple columns.
 java.lang.String getId()
          Creates a string to act as ID for this column.
 ValueType getValueType(DataTable dataTable)
          Returns the value type of the column.
 int hashCode()
           
 java.lang.String toQueryString()
          Returns a string that when parsed by the query parser, should return an identical column.
 java.lang.String toString()
          This is for debug and error messages, not for ID generation.
 void validateColumn(DataTable dataTable)
          Checks whether it makes sense to have the aggregation type on the aggregated column.
 
Methods inherited from class com.google.visualization.datasource.query.AbstractColumn
getCell, getValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COLUMN_AGGRGATION_TYPE_SEPARATOR

public static final java.lang.String COLUMN_AGGRGATION_TYPE_SEPARATOR
When creating the ID of the column, this separates the column on which aggregation is performed and the type of aggregation performed on it.

See Also:
Constant Field Values
Constructor Detail

AggregationColumn

public AggregationColumn(SimpleColumn aggregatedColumn,
                         AggregationType aggregationType)
Creates a new instance of this class with the given column and aggregation type.

Parameters:
aggregatedColumn - The column.
aggregationType - The aggregation type.
Method Detail

getId

public java.lang.String getId()
Creates a string to act as ID for this column. Constructed from the aggregation type and the column ID, separated by a separator.

Specified by:
getId in class AbstractColumn
Returns:
A string to act as ID for this column.

getAggregatedColumn

public SimpleColumn getAggregatedColumn()
Returns the column to aggregate.

Returns:
The column to aggregate.

getAllSimpleColumnIds

public java.util.List<java.lang.String> getAllSimpleColumnIds()
Description copied from class: AbstractColumn
Returns a list of all simple (primitive) column IDs included in this AbstractColumn. This is a list to support calculated columns in the future. For example, a simple column would just return a list containing its own ID. An aggregation column would just return a list containing the ID of its aggregated column. In future, when calculated columns are introduced, a calculated column will return a list with more than one element.

Specified by:
getAllSimpleColumnIds in class AbstractColumn
Returns:
A list of all simple column IDs included in this AbstractColumn.

getAllSimpleColumns

public java.util.List<SimpleColumn> getAllSimpleColumns()
Returns a list of all simple columns. In this case, returns an empty list.

Specified by:
getAllSimpleColumns in class AbstractColumn
Returns:
A list of all simple columns.

getAllAggregationColumns

public java.util.List<AggregationColumn> getAllAggregationColumns()
Returns a list of all aggregation columns. In this case, returns only itself.

Specified by:
getAllAggregationColumns in class AbstractColumn
Returns:
A list of all aggregation columns.

getAllScalarFunctionColumns

public java.util.List<ScalarFunctionColumn> getAllScalarFunctionColumns()
Returns a list of all scalar function columns. In this case, returns an empty list.

Specified by:
getAllScalarFunctionColumns in class AbstractColumn
Returns:
A list of all scalar function columns.

getAggregationType

public AggregationType getAggregationType()
Returns the requested aggregation type.

Returns:
The requested aggregation type.

validateColumn

public void validateColumn(DataTable dataTable)
                    throws InvalidQueryException
Checks whether it makes sense to have the aggregation type on the aggregated column. The type of the column is taken from the given table description. Throws a column exception if the column is invald.

Specified by:
validateColumn in class AbstractColumn
Parameters:
dataTable - The data table.
Throws:
InvalidQueryException - Thrown if the column is invalid.

getValueType

public ValueType getValueType(DataTable dataTable)
Returns the value type of the column. In this case returns the value type of the column after evaluating the aggregation function.

Specified by:
getValueType in class AbstractColumn
Parameters:
dataTable - The data table.
Returns:
The value type of the column.

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in class AbstractColumn

hashCode

public int hashCode()
Specified by:
hashCode in class AbstractColumn

toString

public java.lang.String toString()
This is for debug and error messages, not for ID generation.

Overrides:
toString in class java.lang.Object
Returns:
A string describing this AggregationColumn.

toQueryString

public java.lang.String toQueryString()
Returns a string that when parsed by the query parser, should return an identical column.

Specified by:
toQueryString in class AbstractColumn
Returns:
A string form of this column.


Copyright © 2009 Google. All Rights Reserved.