01: package com.calipso.reportgenerator.reportcalculator.arithmetic;
02:
03: import com.calipso.reportgenerator.reportcalculator.arithmetic.ArithmeticExpression;
04: import com.calipso.reportgenerator.reportcalculator.arithmetic.ConstantArithmeticExp;
05:
06: import java.io.Serializable;
07:
08: /**
09: * Representa un valor de la expresion.
10: */
11:
12: public abstract class ValueArithmeticExp extends ArithmeticExpression
13: implements Serializable {
14:
15: /**
16: * Crea una variable o una constante dependiendo del String
17: * recibido por parametro.
18: * @param token
19: * @return
20: */
21: public static ArithmeticExpression newValueExpFrom(String token) {
22: if (token.charAt(0) == '#') {
23: return new VariableArithmeticExp(token.substring(1, token
24: .length()));
25: } else {
26: return new ConstantArithmeticExp(Float.valueOf(token)
27: .floatValue());
28: }
29: }
30: }
|