com.google.visualization.datasource.query.scalarfunction
Interface ScalarFunction

All Known Implementing Classes:
Constant, CurrentDateTime, DateDiff, Difference, Lower, Product, Quotient, Sum, TimeComponentExtractor, ToDate, Upper

public interface ScalarFunction

A scalar function. A scalar function can have any arity, including 0, and can also have dynamic arity. It must always produce a single value. The return type of such a function may depend on the number and types of its arguments but never on their values. An instance of a class that implements this interface can be used within a ScalarFunctionColumn.

Author:
Liron L.

Method Summary
 Value evaluate(java.util.List<Value> values)
          Executes the scalar function on the given list of values, and returns the Value which is the result of the execution the function.
 java.lang.String getFunctionName()
          Returns the function's name.
 ValueType getReturnType(java.util.List<ValueType> types)
          Returns the return type of the function, given specific types for its parameters.
 java.lang.String toQueryString(java.util.List<java.lang.String> argumentQueryStrings)
          Returns a string that when given to the query parser will yield a similar scalar function.
 void validateParameters(java.util.List<ValueType> types)
          Validates that the number and types of the function parameters are valid.
 

Method Detail

getFunctionName

java.lang.String getFunctionName()
Returns the function's name.

Returns:
The function's name.

evaluate

Value evaluate(java.util.List<Value> values)
Executes the scalar function on the given list of values, and returns the Value which is the result of the execution the function.

Parameters:
values - The given list of parameter values for the scalar function.
Returns:
A Value which is the result of the executing the function.

getReturnType

ValueType getReturnType(java.util.List<ValueType> types)
Returns the return type of the function, given specific types for its parameters. Some functions can be polymorphic, i.e., their return type changes according to the types of their parameters.

Parameters:
types - A list of the types of the function's parameters.
Returns:
The return type of the function.

validateParameters

void validateParameters(java.util.List<ValueType> types)
                        throws InvalidQueryException
Validates that the number and types of the function parameters are valid. Throws an exception if they are not valid.

Parameters:
types - The given types of the function's parameters.
Throws:
InvalidQueryException - Thrown when the parameters are invalid.

toQueryString

java.lang.String toQueryString(java.util.List<java.lang.String> argumentQueryStrings)
Returns a string that when given to the query parser will yield a similar scalar function. Takes as arguments the query strings of the arguments.

Parameters:
argumentQueryStrings - The query strings of the actual arguments.
Returns:
The query string.


Copyright © 2009 Google. All Rights Reserved.