org.jacorb.idl

Class ConstExprEvaluator

public class ConstExprEvaluator extends Object

Based on the MathEvaluator class by The-Son LAI, Lts@writeme.com Expression evaluator for IDL constant expression Supports the following functions: +, -, *, /, ^, %, ^, | , <<, >>
When the getValue() is called, a Double object is returned. If it returns null, an error occured.

Version: $Id: ConstExprEvaluator.java,v 1.6 2006/06/02 13:02:56 alphonse.bendt Exp $

Author: Gerald Brose, The-Son LAI Lts@writeme.com

Nested Class Summary
protected classConstExprEvaluator.Node
protected classConstExprEvaluator.Operator
Field Summary
protected static ConstExprEvaluator.Operator[]operators
Constructor Summary
ConstExprEvaluator()
creates an empty ConstExprEvaluator.
ConstExprEvaluator(String s)
creates a ConstExprEvaluator and assign the expression string.
Method Summary
protected ConstExprEvaluator.Operator[]getOperators()
DoublegetValue()
evaluates and returns the value of the expression
DoublegetVariable(String s)
gets the variable's value that was assigned previously
voidreset()
resets the evaluator
voidsetExpression(String s)
sets the expression

Field Detail

operators

protected static ConstExprEvaluator.Operator[] operators

Constructor Detail

ConstExprEvaluator

public ConstExprEvaluator()
creates an empty ConstExprEvaluator. You need to use setExpression(String s) to assign an expression string to it.

ConstExprEvaluator

public ConstExprEvaluator(String s)
creates a ConstExprEvaluator and assign the expression string.

Method Detail

getOperators

protected ConstExprEvaluator.Operator[] getOperators()

getValue

public Double getValue()
evaluates and returns the value of the expression

getVariable

public Double getVariable(String s)
gets the variable's value that was assigned previously

reset

public void reset()
resets the evaluator

setExpression

public void setExpression(String s)
sets the expression