com.google.visualization.datasource.query
Class QueryLabels

java.lang.Object
  extended by com.google.visualization.datasource.query.QueryLabels

public class QueryLabels
extends Object

Describes the labels of a Query, as passed in the query under the "label" clause. A label can optionally be specified for each column. If not specified, each column type has a default label.

Author:
Itai R.

Constructor Summary
QueryLabels()
          Default empty constructor, with no labels.
 
Method Summary
 void addLabel(AbstractColumn column, String label)
          Adds a column label.
 boolean equals(Object obj)
           
 List<AggregationColumn> getAggregationColumns()
          Returns all the columns that are AggregationColumns.
 Set<AbstractColumn> getColumns()
          Returns an immutable set of the columns for which a label was specified.
 String getLabel(AbstractColumn column)
          Returns the label of the specified column, or null if no label was specified.
 List<ScalarFunctionColumn> getScalarFunctionColumns()
          Returns all the columns that are ScalarFunctionColumns including scalar functions columns that are inside other scalar function columns (e.g., sum(year(a), year(b))).
 int hashCode()
           
 String toQueryString()
          Returns a string that when fed into the query parser, produces a QueryLabels equal to this one.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QueryLabels

public QueryLabels()
Default empty constructor, with no labels. Labels can be added later.

Method Detail

addLabel

public void addLabel(AbstractColumn column,
                     String label)
              throws InvalidQueryException
Adds a column label. Validates that the column ID is not already specified.

Parameters:
column - The column to which the label is assigned.
label - The assigned label.
Throws:
InvalidQueryException - Thrown if the column is already specified.

getLabel

public String getLabel(AbstractColumn column)
Returns the label of the specified column, or null if no label was specified.

Parameters:
column - The column for which the label is required.
Returns:
The label, or null if no label was specified for this column.

getColumns

public Set<AbstractColumn> getColumns()
Returns an immutable set of the columns for which a label was specified.

Returns:
An immutable set of the columns for which a label was specified.

getScalarFunctionColumns

public List<ScalarFunctionColumn> getScalarFunctionColumns()
Returns all the columns that are ScalarFunctionColumns including scalar functions columns that are inside other scalar function columns (e.g., sum(year(a), year(b))).

Returns:
all the columns that are ScalarFunctionColumns.

getAggregationColumns

public List<AggregationColumn> getAggregationColumns()
Returns all the columns that are AggregationColumns.

Returns:
All the columns that are AggregationColumns.

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toQueryString

public String toQueryString()
Returns a string that when fed into the query parser, produces a QueryLabels equal to this one. The string returned does not contain the LABEL keyword.

Returns:
The query string.


Copyright © 2012 Google. All Rights Reserved.