1 package com.calipso.reportgenerator.reportcalculator.expression; 2 3 import java.util.Collection ; 4 import java.util.Iterator ; 5 import java.sql.Date ; 6 7 14 public class InExp extends BinaryExp{ 15 private Collection values; 16 17 public InExp(VariableExp expression, Collection values) { 18 initialize(); 19 setVariable(expression); 20 this.values = values; 21 } 22 23 private void setVariable(VariableExp expression) { 24 this.arguments[0] = expression; 25 } 26 27 protected void initialize(){ 28 arguments = new Expression[1]; 29 } 30 31 public String basicAsString(){ 32 String result = ""; 33 if(!values.isEmpty()){ 34 result += arguments[0].basicAsString() + " IN ("; 35 Iterator iterator = values.iterator(); 36 result += iterator.next().toString(); 37 while(iterator.hasNext()){ 38 result += ", " + iterator.next().toString(); 39 } 40 result += ")"; 41 } 42 return result; 43 } 44 45 public Object visitedBy(ExpressionVisitor visitor){ 46 return visitor.processIn(this); 47 } 48 49 public Expression getArgument(){ 50 return arguments[0]; 51 } 52 53 public Collection getValues() { 54 return values; 55 } 56 } 57 | Popular Tags |