com.canoo.webtest.util
Class Expression

java.lang.Object
  extended by com.canoo.webtest.util.Expression

public class Expression
extends Object

Evaluates a mathematical expression.

Author:
Paul King, Rob Nielsen

Constructor Summary
Expression()
          Constructs a new blank expression
Expression(Evaluator eval)
          Constructor for the Expression object
 
Method Summary
 double evaluate(String exp)
          Evaluates the expression string and returns the result (which is also available with getValue()).
static double evaluateExpression(String s)
          Evaluates a string expression without requiring the creation of an instance.
static double evaluateExpression(String s, Evaluator eval)
          Evaluates a string expression without requiring the creation of an instance.
protected  double evaluateString(String s)
          Evaluates a string found in the expression which isn't an arithmetic expression.
 void setEvaluator(Evaluator evaluator)
          Sets the Evaluator attribute of the Expression object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Expression

public Expression()
Constructs a new blank expression


Expression

public Expression(Evaluator eval)
Constructor for the Expression object

Parameters:
eval - the fEvaluator to use for unknown expressions
Method Detail

setEvaluator

public void setEvaluator(Evaluator evaluator)
Sets the Evaluator attribute of the Expression object

Parameters:
evaluator - The new Evaluator value

evaluate

public double evaluate(String exp)
Evaluates the expression string and returns the result (which is also available with getValue()). Any parse errors will throw a IllegalArgumentException

Parameters:
exp - the string to parse
Returns:
the double value of the expression
Throws:
IllegalArgumentException

evaluateString

protected double evaluateString(String s)
Evaluates a string found in the expression which isn't an arithmetic expression. Calls out to the given fEvaluator.

Parameters:
s - the substring to evaluate
Returns:
the double value of the evaluation

evaluateExpression

public static double evaluateExpression(String s)
Evaluates a string expression without requiring the creation of an instance.

Parameters:
s - the expression to evaluate
Returns:
the double value of the expression

evaluateExpression

public static double evaluateExpression(String s,
                                        Evaluator eval)
Evaluates a string expression without requiring the creation of an instance.

Parameters:
s - the expression to evaluate
eval - the fEvaluator to parse special values
Returns:
the double value of the expression

Copyright © 2001-2007 Canoo Engineering AG, Basel. All rights reserved.