com.google.visualization.datasource.query.scalarfunction
Class Quotient

java.lang.Object
  extended by com.google.visualization.datasource.query.scalarfunction.Quotient
All Implemented Interfaces:
ScalarFunction

public class Quotient
extends java.lang.Object
implements ScalarFunction

The binary scalar function quotient(). Returns the quotient of two values. Division by zero returns a null number value.

Author:
Liron L.

Method Summary
 Value evaluate(java.util.List<Value> values)
          Executes the scalar function quotient() on the given values.
 java.lang.String getFunctionName()
          Returns the function's name.
static Quotient getInstance()
          Returns the singleton instance of this class.
 ValueType getReturnType(java.util.List<ValueType> types)
          Returns the return type of the function.
 java.lang.String toQueryString(java.util.List<java.lang.String> argumentsQueryStrings)
          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 all function parameters are of type NUMBER, and that there are exactly 2 parameters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static Quotient getInstance()
Returns the singleton instance of this class.

Returns:
The singleton instance of this class.

getFunctionName

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

Specified by:
getFunctionName in interface ScalarFunction
Returns:
The function's name.

evaluate

public Value evaluate(java.util.List<Value> values)
Executes the scalar function quotient() on the given values. Returns the quotient of the given values. All values are number values. Division by zero returns a null number value. The method does not validate the parameters, the user must check the parameters before calling this method.

Specified by:
evaluate in interface ScalarFunction
Parameters:
values - A list of values on which the scalar function is performed.
Returns:
Value with the quotient of all given values, or number null value if one of the values is null or if one of the denominators is zero.

getReturnType

public ValueType getReturnType(java.util.List<ValueType> types)
Returns the return type of the function. In this case, NUMBER. The method does not validate the parameters, the user must check the parameters before calling this method.

Specified by:
getReturnType in interface ScalarFunction
Parameters:
types - A list of the types of the scalar function parameters.
Returns:
The type of the returned value: Number.

validateParameters

public void validateParameters(java.util.List<ValueType> types)
                        throws InvalidQueryException
Validates that all function parameters are of type NUMBER, and that there are exactly 2 parameters. Throws a ScalarFunctionException otherwise.

Specified by:
validateParameters in interface ScalarFunction
Parameters:
types - A list with parameters types.
Throws:
InvalidQueryException - Thrown if the parameters are invalid.

toQueryString

public java.lang.String toQueryString(java.util.List<java.lang.String> argumentsQueryStrings)
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.

Specified by:
toQueryString in interface ScalarFunction
Parameters:
argumentsQueryStrings - The query strings of the actual arguments.
Returns:
The query string.


Copyright © 2009 Google. All Rights Reserved.