KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > reportcalculator > arithmetic > VariableArithmeticExp


1 package com.calipso.reportgenerator.reportcalculator.arithmetic;
2
3 import com.calipso.reportgenerator.reportcalculator.arithmetic.ValueArithmeticExp;
4 import com.calipso.reportgenerator.reportcalculator.SharedFloat;
5
6 import java.util.Map JavaDoc;
7 import java.util.Collection JavaDoc;
8 import java.io.Serializable JavaDoc;
9
10 /**
11  * Representa una variable de la expresion a resolver.
12  */

13
14 public class VariableArithmeticExp extends ValueArithmeticExp implements Serializable JavaDoc{
15   private String JavaDoc name;
16
17   /**
18    * Crea una instancia de <code>VariableArithmeticExp</code>.
19    * @param name
20    */

21   public VariableArithmeticExp(String JavaDoc name) {
22     this.name = name;
23   }
24
25   /**
26    * Retorna un valor float a partir de un nombre.
27    * @param context
28    * @return
29    */

30   public float value(Map JavaDoc context) {
31     return ((SharedFloat) context.get(name)).floatValue();
32   }
33
34   /**
35    * Metodo toString de la clase.
36    * @return
37    */

38   public String JavaDoc toString() {
39     return "#" + name;
40   }
41
42   /**
43    * Agrega un nombre a la coleccion.
44    * @param variables
45    */

46   public void getVariables(Collection JavaDoc variables) {
47     variables.add(name);
48   }
49 }
50
Popular Tags