net.christopherschultz.evaluator.function
Class IfFunction

java.lang.Object
  extended by net.christopherschultz.evaluator.function.IfFunction
All Implemented Interfaces:
Function

public class IfFunction
extends Object
implements Function

Implements an if-then-else construct as a function.

Usage: if(predicate, then-expression, else-expression)

This function returns the result of the then-expression if the predicate evaluates to true, or returns the result of the else-expression if predicate evaluates to false. null is returned if the predicate returns null.

Version:
$Revision: 1.2 $ $Date: 2008-06-20 22:58:48 $
Author:
Chris Schultz

Constructor Summary
IfFunction()
          Creates a new IfFunction object.
 
Method Summary
 Object call(EvaluationContext ec, String functionName, List argumentExpressions)
          Invokes the function with the specified argument expressions in the specified evaluation context.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IfFunction

public IfFunction()
Creates a new IfFunction object.

Method Detail

call

public Object call(EvaluationContext ec,
                   String functionName,
                   List argumentExpressions)
            throws EvaluationException
Description copied from interface: Function
Invokes the function with the specified argument expressions in the specified evaluation context.

Specified by:
call in interface Function
Parameters:
ec - The EvaluationContext in which this function is being called.
functionName - The name of the function being called.
argumentExpressions - The expressions which, when evaluated, result in the arguments to the function.
Returns:
The result of the function.
Throws:
EvaluationException - If there is a problem evaluating any of the arguments' expressions, or if there is an error during function execution.

toString

public String toString()
Overrides:
toString in class Object