org.jacorb.idl

Class ConstExprEvaluator


public class ConstExprEvaluator
extends java.lang.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.4 2004/05/06 12:39:58 nicolas Exp $

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

Nested Class Summary

protected class
ConstExprEvaluator.Node
protected class
ConstExprEvaluator.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()
Double
getValue()
evaluates and returns the value of the expression
Double
getVariable(String s)
gets the variable's value that was assigned previously
void
reset()
resets the evaluator
void
setExpression(String s)
sets the expression

Field Details

operators

protected static ConstExprEvaluator.Operator[] operators

Constructor Details

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 Details

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