http://www.eteks.com

com.eteks.parser.node
Class ConditionNode

java.lang.Object
  |
  +--com.eteks.parser.node.ConditionNode
All Implemented Interfaces:
ExpressionNode, ParameterizedNode, java.io.Serializable

public class ConditionNode
extends java.lang.Object
implements ParameterizedNode

Node matching a condition.

Since:
Jeks 1.0
Version:
1.0
Author:
Emmanuel Puybaret
See Also:
Serialized Form

Constructor Summary
ConditionNode()
           
 
Method Summary
 void addParameter(ExpressionNode parameter)
          Stores the if, then and else expressions of this condition.
 double computeExpression(double[] parametersValue)
          Returns the computed value of then or else expressions depending on the computed value of the if expression.
 java.lang.Object computeExpression(Interpreter interpreter, java.lang.Object[] parametersValue)
          Returns the result of this condition.
 ExpressionNode getElseExpression()
          Returns the node matching the else expression.
 ExpressionNode getIfExpression()
          Returns the node matching the if expression.
 int getParameterCount()
          Returns the current count of parameters or operands stored by this node.
 ExpressionNode getThenExpression()
          Returns the node matching the then expression.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConditionNode

public ConditionNode()
Method Detail

addParameter

public void addParameter(ExpressionNode parameter)
Stores the if, then and else expressions of this condition.
Specified by:
addParameter in interface ParameterizedNode
Following copied from interface: com.eteks.parser.node.ParameterizedNode
Parameters:
parameter - the node of an expression used as parameter or operand.

getParameterCount

public int getParameterCount()
Description copied from interface: ParameterizedNode
Returns the current count of parameters or operands stored by this node.
Specified by:
getParameterCount in interface ParameterizedNode
Following copied from interface: com.eteks.parser.node.ParameterizedNode
Returns:
the count of parameters of this node.

getIfExpression

public ExpressionNode getIfExpression()
Returns the node matching the if expression.
Returns:
the node of an expression.

getThenExpression

public ExpressionNode getThenExpression()
Returns the node matching the then expression.
Returns:
the node of an expression.

getElseExpression

public ExpressionNode getElseExpression()
Returns the node matching the else expression.
Returns:
the node of an expression.

computeExpression

public java.lang.Object computeExpression(Interpreter interpreter,
                                          java.lang.Object[] parametersValue)
Returns the result of this condition.
If the supportsRecursiveCall () method of the interpreter returns true, the computed value of then or else expressions is returned depending on whether the isTrue () method of the interpreter returning true or not. The computed value of the if expression is passed as parameter to the isTrue () method.
If the supportsRecursiveCall () method returns false, this method returns the result of the getConditionValue () method of interpreter with the computed value of the if, then and else expressions as parameters.
Specified by:
computeExpression in interface ExpressionNode
Parameters:
interpreter - runtime interpreter.
parametersValue - the value of parameters passed to compute a compiled function.
Returns:
the computed value of the condition. The type of the returned value depends on the implementation of the interpreter.
See Also:
Interpreter.isTrue(java.lang.Object), Interpreter.getConditionValue(java.lang.Object, java.lang.Object, java.lang.Object)

computeExpression

public double computeExpression(double[] parametersValue)
Returns the computed value of then or else expressions depending on the computed value of the if expression. The if expression is compared to ConstantNode.FALSE_DOUBLE.
Specified by:
computeExpression in interface ExpressionNode
Parameters:
parametersValue - the value of parameters passed to compute a compiled function.
Returns:
the computed value of the condition.

&cp; 1998-2003 eTeks - All rights reserved