http://www.eteks.com

com.eteks.parser.node
Class BinaryOperatorNode

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

public class BinaryOperatorNode
extends ConstantNode
implements ParameterizedNode

Node matching a binary operator.

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

Fields inherited from class com.eteks.parser.node.ConstantNode
FALSE_DOUBLE, TRUE_DOUBLE
 
Constructor Summary
BinaryOperatorNode(java.lang.Object operatorKey)
          Creates the node of a binary operator.
 
Method Summary
 void addParameter(ExpressionNode parameter)
          Stores the operands of this operator.
 double computeExpression(double[] parametersValue)
          Returns the double value of this operator node operating on its operands.
 java.lang.Object computeExpression(Interpreter interpreter, java.lang.Object[] parametersValue)
          Returns the value returned by the getBinaryOperatorValue () method of interpreter with the key of this operator and the computed value of its operands as parameters.
 ExpressionNode getFirstOperand()
          Returns the node matching the first operand.
 int getParameterCount()
          Returns the current count of parameters or operands stored by this node.
 ExpressionNode getSecondOperand()
          Returns the node matching the second operand.
 
Methods inherited from class com.eteks.parser.node.ConstantNode
getKey
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryOperatorNode

public BinaryOperatorNode(java.lang.Object operatorKey)
Creates the node of a binary operator.
Parameters:
operatorKey - the key of a binary operator of Syntax.
Method Detail

addParameter

public void addParameter(ExpressionNode parameter)
Stores the operands of this operator.
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.

getFirstOperand

public ExpressionNode getFirstOperand()
Returns the node matching the first operand.
Returns:
the node of an expression.

getSecondOperand

public ExpressionNode getSecondOperand()
Returns the node matching the second operand.
Returns:
the node of an expression.

computeExpression

public java.lang.Object computeExpression(Interpreter interpreter,
                                          java.lang.Object[] parametersValue)
Returns the value returned by the getBinaryOperatorValue () method of interpreter with the key of this operator and the computed value of its operands as parameters.
Specified by:
computeExpression in interface ExpressionNode
Overrides:
computeExpression in class ConstantNode
Parameters:
interpreter - runtime interpreter.
parametersValue - the value of parameters passed to compute a compiled function.
Returns:
the computed value of this operator. The type of the returned value depends on the implementation of the interpreter.
See Also:
Interpreter.getBinaryOperatorValue(java.lang.Object, java.lang.Object, java.lang.Object)

computeExpression

public double computeExpression(double[] parametersValue)
Returns the double value of this operator node operating on its operands.
Specified by:
computeExpression in interface ExpressionNode
Overrides:
computeExpression in class ConstantNode
Parameters:
parametersValue - the value of parameters passed to compute a compiled function.
Returns:
the value of this operator.

&cp; 1998-2003 eTeks - All rights reserved