KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jmock > examples > calculator > expression > VariableReference


1 /* Copyright (c) 2000-2004 jMock.org
2  */

3 package org.jmock.examples.calculator.expression;
4
5 import org.jmock.examples.calculator.CalculatorException;
6 import org.jmock.examples.calculator.Environment;
7 import org.jmock.examples.calculator.Expression;
8
9
10 public class VariableReference implements Expression
11 {
12
13     private String JavaDoc variableName;
14
15     public VariableReference( String JavaDoc variableName ) {
16         this.variableName = variableName;
17     }
18
19     public double evaluate( Environment environment )
20             throws CalculatorException {
21         return environment.getVariable(variableName).evaluate(environment);
22     }
23 }
24
Popular Tags