01: package com.calipso.reportgenerator.reportcalculator.arithmetic;
02:
03: import com.calipso.reportgenerator.reportcalculator.arithmetic.ValueArithmeticExp;
04: import com.calipso.reportgenerator.reportcalculator.SharedFloat;
05:
06: import java.util.Map;
07: import java.util.Collection;
08: import java.io.Serializable;
09:
10: /**
11: * Representa una variable de la expresion a resolver.
12: */
13:
14: public class VariableArithmeticExp extends ValueArithmeticExp implements
15: Serializable {
16: private String name;
17:
18: /**
19: * Crea una instancia de <code>VariableArithmeticExp</code>.
20: * @param name
21: */
22: public VariableArithmeticExp(String name) {
23: this .name = name;
24: }
25:
26: /**
27: * Retorna un valor float a partir de un nombre.
28: * @param context
29: * @return
30: */
31: public float value(Map context) {
32: return ((SharedFloat) context.get(name)).floatValue();
33: }
34:
35: /**
36: * Metodo toString de la clase.
37: * @return
38: */
39: public String toString() {
40: return "#" + name;
41: }
42:
43: /**
44: * Agrega un nombre a la coleccion.
45: * @param variables
46: */
47: public void getVariables(Collection variables) {
48: variables.add(name);
49: }
50: }
|