net.christopherschultz.evaluator
Class FunctionCallExpression

java.lang.Object
  extended by net.christopherschultz.evaluator.Expression
      extended by net.christopherschultz.evaluator.FunctionCallExpression

public class FunctionCallExpression
extends Expression

An Expression representing a function call.

Version:
$Revision: 1.7 $ $Date: 2008-06-20 22:58:48 $
Author:
Chris Schultz

Constructor Summary
FunctionCallExpression(Expression functionExp, List arguments)
          Creates a new FunctionCallExpression where the function to call is determined at evaluation time.
 
Method Summary
 void acceptVisitor(ExpressionVisitor visitor)
          Accepts an ExpressionVisitor.
 boolean equals(Object o)
          Returns true if the specified object is equal to this one.
 Object evaluate(EvaluationContext ec)
          Evaluates this Expression by evaluating all of the arguments' expressions, and then passing their resulting values to the function bound to this FunctionCallExpression's name.
 List getArgumentExpressions()
          Gets the list of argument expressions for this FunctionCallExpression.
 Expression getFunctionExpression()
          Gets the expression which will evaluate to the function to be called by this FunctionCallExpression.
 String getFunctionName()
          Returns the name of the function to be called by this FunctionCallExpression, or <anonymous> if the function will be determined at evaluation-time.
 List getSubExpressions()
          Gets a flattened, depth-first traversal of the expressions in this Expression (including this Expression).
 int hashCode()
           
 String toString()
          Returns a String representation of this FunctionCallExpression.
 
Methods inherited from class net.christopherschultz.evaluator.Expression
getParent, setParent
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FunctionCallExpression

public FunctionCallExpression(Expression functionExp,
                              List arguments)
                       throws EvaluationException

Creates a new FunctionCallExpression where the function to call is determined at evaluation time.

Throws:
EvaluationException
Method Detail

getFunctionName

public String getFunctionName()
Returns the name of the function to be called by this FunctionCallExpression, or <anonymous> if the function will be determined at evaluation-time.

Returns:
The name of the function to be called by this FunctionCallExpression.

getFunctionExpression

public Expression getFunctionExpression()
Gets the expression which will evaluate to the function to be called by this FunctionCallExpression.

Returns:
The expression which, when evaluated, will return the Function to be called by this FunctionCallExpression.

getArgumentExpressions

public List getArgumentExpressions()
Gets the list of argument expressions for this FunctionCallExpression.

Returns:
A List of Expressions objects which are the arguments to this FunctionCallExpression.

getSubExpressions

public List getSubExpressions()
Description copied from class: Expression
Gets a flattened, depth-first traversal of the expressions in this Expression (including this Expression).

Specified by:
getSubExpressions in class Expression
Returns:
A List of sub-expressions for this Expression.

acceptVisitor

public void acceptVisitor(ExpressionVisitor visitor)
Description copied from class: Expression
Accepts an ExpressionVisitor.

Specified by:
acceptVisitor in class Expression

evaluate

public Object evaluate(EvaluationContext ec)
                throws EvaluationException
Evaluates this Expression by evaluating all of the arguments' expressions, and then passing their resulting values to the function bound to this FunctionCallExpression's name.

Specified by:
evaluate in class Expression
Parameters:
ec - The context in which this function call should be evaluated.
Returns:
The result of calling this FunctionVallExpression's function with it's arguments.
Throws:
EvaluationException - If there is an error evaluating any of the argument expressions or calling the function itself.

toString

public String toString()
Returns a String representation of this FunctionCallExpression.

Overrides:
toString in class Object
Returns:
A String representation of this FunctionCallExpression.

equals

public boolean equals(Object o)
Returns true if the specified object is equal to this one.

Overrides:
equals in class Object
Parameters:
o - The object to test for equality.
Returns:
true if the specified object is equal to this one, false otherwise.

hashCode

public int hashCode()
Overrides:
hashCode in class Object