com.crystaldecisions.reports.formulas
Interface FormulaFunction

All Superinterfaces:
FormulaFunctionDefinition

public interface FormulaFunction
extends FormulaFunctionDefinition

Provides the main interface to be implemented for each function in the user defined function library. All of the methods in this interface must be implemented. Additionally, the user defined function must behave like a pure function; it must produce the same results each time it is given the same input values. If your function is impure (such as a random number generator), implement this interface as well as the ImpureFormulaFunction interface.


Method Summary
 FormulaValue evaluate(FormulaValueReference[] arguments)
           Evaluates the user defined function with the given arguments.
 void validateArgumentValues(FormulaValueReference[] arguments)
           Validates the argument values at compile-time.
 
Methods inherited from interface com.crystaldecisions.reports.formulas.FormulaFunctionDefinition
getArguments, getIdentifier, getReturnType
 

Method Detail

validateArgumentValues

void validateArgumentValues(FormulaValueReference[] arguments)
                            throws FormulaFunctionCallException

Validates the argument values at compile-time.
Note: Some or all of the argument values may not be available at compile-time, depending on the formula expressions used to supply the argument values. For this reason, validation of the argument values inside the evaluate() method may still be necessary. When an argument value is not available at compile time, the argument's getFormulaValue() method will return NULL, and this method should not throw an exception.

Parameters:
arguments - the arguments to the user defined function
Throws:
FormulaFunctionCallException

evaluate

FormulaValue evaluate(FormulaValueReference[] arguments)
                      throws FormulaFunctionCallException

Evaluates the user defined function with the given arguments.

Note: Some or all of the argument values may be null (i.e. the argument's getFormulaValue() method will return null). The implementation of this method should handle null argument values in such a way that an exception is not thrown. For example, the function could return null in these cases. In the current release, the use of null argument values as input arguments to the evaluate() method is restricted to arguments of type Date, Time, and DateTime. Similarly, the value returned from the evaluate() method may only be null if the function's returnType is Date, Time, or DateTime.

Parameters:
arguments - the arguments to the user defined function
Returns:
the result of the function evaluation as a FormulaValue.
Throws:
FormulaFunctionCallException - if the function could not be evaluated successfully