com.google.visualization.datasource.query
Class ScalarFunctionColumn

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

public class ScalarFunctionColumn
extends AbstractColumn

A scalar function column (e.g. year(Date1)). The values in a scalar function column are the result of executing the function on the columns that are given as parameters, so for example year(Date1) column values will have the year of the corresponding value in Date1 column.

Author:
Liron L.

Field Summary
static java.lang.String COLUMN_COLUMN_SEPARATOR
          When creating the ID of the column, this is used as a separator between the columns on which the function is performed.
static java.lang.String COLUMN_FUNCTION_TYPE_SEPARATOR
          A separator between function type and the columns on which it operates.
 
Constructor Summary
ScalarFunctionColumn(java.util.List<AbstractColumn> columns, ScalarFunction scalarFunction)
          Creates a new instance of this class with the given columns list and function type.
 
Method Summary
 boolean equals(java.lang.Object o)
           
 java.util.List<AggregationColumn> getAllAggregationColumns()
          Returns a list of all aggregation columns including the columns that are inside scalar function columns (e.g., the column year(date(max(d1))) will return max(d1)).
 java.util.List<ScalarFunctionColumn> getAllScalarFunctionColumns()
          Returns a list of all scalar function columns.
 java.util.List<java.lang.String> getAllSimpleColumnIds()
          Returns a list of the inner simple column IDs of the scalar function column (i.e., the columns on which the function is performed).
 java.util.List<SimpleColumn> getAllSimpleColumns()
          Returns a list of all simple columns.
 TableCell getCell(ColumnLookup lookup, TableRow row)
          Returns the cell of the column in the given row.
 java.util.List<AbstractColumn> getColumns()
          Returns a list of the columns on which the function is performed.
 ScalarFunction getFunction()
          Returns the function of the scalar function column.
 java.lang.String getId()
          Returns the ID of the scalar function column.
 ValueType getValueType(DataTable dataTable)
          Returns the value type of the column after evaluating the scalar function.
 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 that the column is valid.
 
Methods inherited from class com.google.visualization.datasource.query.AbstractColumn
getValue
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COLUMN_FUNCTION_TYPE_SEPARATOR

public static final java.lang.String COLUMN_FUNCTION_TYPE_SEPARATOR
A separator between function type and the columns on which it operates. Used for creating the column ID.

See Also:
Constant Field Values

COLUMN_COLUMN_SEPARATOR

public static final java.lang.String COLUMN_COLUMN_SEPARATOR
When creating the ID of the column, this is used as a separator between the columns on which the function is performed.

See Also:
Constant Field Values
Constructor Detail

ScalarFunctionColumn

public ScalarFunctionColumn(java.util.List<AbstractColumn> columns,
                            ScalarFunction scalarFunction)
Creates a new instance of this class with the given columns list and function type.

Parameters:
columns - The list of columns on which the function is performed.
scalarFunction - The function type.
Method Detail

getId

public java.lang.String getId()
Returns the ID of the scalar function column. THe ID is constructed from the function's name and the IDs of the inner columns on which the function is performed.

Specified by:
getId in class AbstractColumn
Returns:
The ID of the scalar function column.

getAllSimpleColumnIds

public java.util.List<java.lang.String> getAllSimpleColumnIds()
Returns a list of the inner simple column IDs of the scalar function column (i.e., the columns on which the function is performed).

Specified by:
getAllSimpleColumnIds in class AbstractColumn
Returns:
A list of the inner simple column IDs.

getFunction

public ScalarFunction getFunction()
Returns the function of the scalar function column.

Returns:
The function of the scalar function column.

getColumns

public java.util.List<AbstractColumn> getColumns()
Returns a list of the columns on which the function is performed.

Returns:
A list of the columns on which the function is performed.

getCell

public TableCell getCell(ColumnLookup lookup,
                         TableRow row)
Returns the cell of the column in the given row. If the given column lookup contains this column, returns the cell in the given row using the lookup. Otherwise, recursively gets the inner column values and uses them to evaluate the value and create a cell based on that value. The base of the recursion is a simple column, aggregation column or another scalar function column that exists in the column lookup (i.e., its value was already calculated).

Overrides:
getCell in class AbstractColumn
Parameters:
row - The given row.
lookup - The column lookup.
Returns:
The cell of the column in the given row.

getAllSimpleColumns

public java.util.List<SimpleColumn> getAllSimpleColumns()
Returns a list of all simple columns. This includes simple columns that are inside scalar function columns (e.g, year(a1)), but does not include simple columns that are inside aggregation columns (e.g., sum(a1)).

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 including the columns that are inside scalar function columns (e.g., the column year(date(max(d1))) will return max(d1)).

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. Returns itself and other inner scalar function columns (if there are any). e.g., the column max(year(a1), year(a2)) will return the 3 columns: max(year(a1), year(a2)), year(a1), year(a2).

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

validateColumn

public void validateColumn(DataTable dataTable)
                    throws InvalidQueryException
Checks that the column is valid. Checks the scalar function matches its arguments (inner columns) and all its inner columns are valid too. Throws a ColumnException if the scalar function has invalid arguments.

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

getValueType

public ValueType getValueType(DataTable dataTable)
Returns the value type of the column after evaluating the scalar function. e.g., the value type of year(date1) is NUMBER.

Specified by:
getValueType in class AbstractColumn
Parameters:
dataTable - The table description.
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

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.

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.


Copyright © 2009 Google. All Rights Reserved.