KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > calipso > reportgenerator > reportcalculator > expression > InExp


1 package com.calipso.reportgenerator.reportcalculator.expression;
2
3 import java.util.Collection JavaDoc;
4 import java.util.Iterator JavaDoc;
5 import java.sql.Date JavaDoc;
6
7 /**
8  *
9  * User: jbassino
10  * Date: 06/07/2004
11  * Time: 16:29:50
12  *
13  */

14 public class InExp extends BinaryExp{
15   private Collection JavaDoc values;
16
17   public InExp(VariableExp expression, Collection JavaDoc 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 JavaDoc basicAsString(){
32     String JavaDoc result = "";
33     if(!values.isEmpty()){
34       result += arguments[0].basicAsString() + " IN (";
35       Iterator JavaDoc 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 JavaDoc visitedBy(ExpressionVisitor visitor){
46     return visitor.processIn(this);
47   }
48
49   public Expression getArgument(){
50     return arguments[0];
51   }
52
53   public Collection JavaDoc getValues() {
54     return values;
55   }
56 }
57
Popular Tags