org.nfunk.jep.function
Class If

java.lang.Object
  extended byorg.nfunk.jep.function.PostfixMathCommand
      extended byorg.nfunk.jep.function.If
All Implemented Interfaces:
PostfixMathCommandI, SpecialEvaluationI

public class If
extends PostfixMathCommand
implements SpecialEvaluationI

The if(condExpr,posExpr,negExpr) function. The value of trueExpr will be returned if condExpr is >0 (true) and value of negExpr will be returned if condExpr is <= 0 (false).

This function performs lazy evaluation so that only posExpr or negExpr will be evaluated. For Complex numbers only the real part is used.

An alternate form if(condExpr,posExpr,negExpr,zeroExpr) is also availiable. Note most computations are carried out over floating point doubles so testing for zero can be dangerous.

This function implements the SpecialEvaluationI interface so that it handles setting the value of a variable.

Author:
Rich Morris Created on 18-Nov-2003

Field Summary
 
Fields inherited from class org.nfunk.jep.function.PostfixMathCommand
curNumberOfParameters, numberOfParameters
 
Constructor Summary
If()
           
 
Method Summary
 java.lang.Object evaluate(Node node, java.lang.Object data, ParserVisitor pv, java.util.Stack inStack)
          For assignment
 
Methods inherited from class org.nfunk.jep.function.PostfixMathCommand
checkStack, getNumberOfParameters, run, setCurNumberOfParameters
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

If

public If()
Method Detail

evaluate

public java.lang.Object evaluate(Node node,
                                 java.lang.Object data,
                                 ParserVisitor pv,
                                 java.util.Stack inStack)
                          throws ParseException
For assignment

Specified by:
evaluate in interface SpecialEvaluationI
Parameters:
node - The current node
data - The data passed to visitor, typically not used
pv - The visitor, can be used evaluate the children
inStack - The stack of the evaluator
Returns:
the value after evaluation
Throws:
ParseException


http://www.singularsys.com/jep Copyright © 2004 Singular Systems