1 package com.calipso.reportgenerator.reportcalculator.expression; 2 3 import java.util.Set ; 4 import java.util.HashSet ; 5 import java.io.Serializable ; 6 7 10 public class ConstantExp extends Expression implements Serializable { 11 12 13 public ConstantExp() { 14 } 15 16 Object value; 17 18 22 public ConstantExp(Object value) { 23 this.value = value; 24 } 25 26 31 public static ConstantExp forValue(Object aValue) { 32 if (aValue instanceof Boolean ) { 33 if (((Boolean ) aValue).booleanValue()) { 34 return new TrueExp(); 35 } 36 else { 37 return new FalseExp(); 38 } 39 } 40 return new ConstantExp(aValue); 41 } 42 43 48 public Expression newAnd(Expression expression) { 49 return basicAnd(expression); 50 } 51 52 57 public Expression newOr(Expression expression) { 58 return basicOr(expression); 59 } 60 61 65 protected String basicAsString() { 66 return value.toString(); 67 } 68 69 73 public boolean isConstant() { 74 return true; 75 } 76 77 81 public Object getValue() { 82 return value; 83 } 84 85 89 protected Set variables() { 90 return new HashSet (); 91 } 92 93 94 99 public Object visitedBy(ExpressionVisitor visitor) { 100 return visitor.processConstant(this); 101 } 102 } 103 | Popular Tags |