Class Conditional

java.lang.Object
  extended by Conditional
All Implemented Interfaces:
Expression

public class Conditional
extends java.lang.Object
implements Expression

A Conditional is an if-then-else expression.


Constructor Summary
Conditional(Expression test, Expression ifTrue, Expression ifFalse)
          Creates a Conditional with the specified components.
 
Method Summary
 java.lang.Object eval(Environment env)
          Evaluate this expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Conditional

public Conditional(Expression test,
                   Expression ifTrue,
                   Expression ifFalse)
Creates a Conditional with the specified components.

Parameters:
test - an expression which evaluates to true or false
ifTrue - the expression to evaluate if the test returns true
ifFalse - the expression to evaluate if the test returns false
Method Detail

eval

public java.lang.Object eval(Environment env)
Description copied from interface: Expression
Evaluate this expression. When an Expression is evaluated, this must happen in some particular environment. For example, evaluating the variable x in one environment might produce a totally different value than evaluating it in another environment.

Specified by:
eval in interface Expression
Parameters:
env - the environment in which the expression should be evaluated
Returns:
the value produced by the expression