http://www.eteks.com

com.eteks.parser.node
Class FunctionNode

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

public class FunctionNode
extends java.lang.Object
implements ParameterizedNode

Node matching a function call.

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

Constructor Summary
FunctionNode(Function function, boolean recursiveCall)
          Creates the node of a function.
 
Method Summary
 void addParameter(ExpressionNode parameter)
          Adds the node parameter to the list of parameters or operands of this node.
 double computeExpression(double[] parametersValue)
          Returns the double value of this function call.
 java.lang.Object computeExpression(Interpreter interpreter, java.lang.Object[] parametersValue)
          Returns the value returned by the getFunctionValue () method of interpreter with the instance of Function of this node and the computed value of its parameters as parameters of getFunctionValue ().
 Function getFunction()
          Returns the function of this node.
 ExpressionNode getParameter(int index)
          Returns the expression at index index that will be passed as parameter to this function.
 int getParameterCount()
          Returns the current count of parameters or operands stored by this node.
 boolean isRecursiveCall()
          Returns true if this is a recursive call.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FunctionNode

public FunctionNode(Function function,
                    boolean recursiveCall)
Creates the node of a function.
Parameters:
function - a previously compiled function or any instance of a Java written class implementing the Function interface.
recursiveCall - true if this is a recursive call.
Method Detail

getFunction

public Function getFunction()
Returns the function of this node.
Returns:
a Function instance.

isRecursiveCall

public boolean isRecursiveCall()
Returns true if this is a recursive call.
Returns:
true or false.

addParameter

public void addParameter(ExpressionNode parameter)
Description copied from interface: ParameterizedNode
Adds the node parameter to the list of parameters or operands of this node.
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.

getParameter

public ExpressionNode getParameter(int index)
Returns the expression at index index that will be passed as parameter to this function.
Returns:
the expression stored at index index.

computeExpression

public java.lang.Object computeExpression(Interpreter interpreter,
                                          java.lang.Object[] parametersValue)
Returns the value returned by the getFunctionValue () method of interpreter with the instance of Function of this node and the computed value of its parameters as parameters of getFunctionValue ().
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 this function. The type of the returned value depends on the implementation of the interpreter.
See Also:
Interpreter.getFunctionValue(com.eteks.parser.Function, java.lang.Object[], boolean)

computeExpression

public double computeExpression(double[] parametersValue)
Returns the double value of this function call. If the called function isn't an instance of CompiledFunction, an instance of DoubleInterpreter is passed to the computeFunction () of the function to compute its value.
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 this function.

&cp; 1998-2003 eTeks - All rights reserved