InExp.java :  » Report » jmagallanes-1.0 » com » calipso » reportgenerator » reportcalculator » expression » Java Open Source

Java Open Source » Report » jmagallanes 1.0 
jmagallanes 1.0 » com » calipso » reportgenerator » reportcalculator » expression » InExp.java
package com.calipso.reportgenerator.reportcalculator.expression;

import java.util.Collection;
import java.util.Iterator;
import java.sql.Date;

/**
 *
 * User: jbassino
 * Date: 06/07/2004
 * Time: 16:29:50
 *
 */
public class InExp extends BinaryExp{
  private Collection values;

  public InExp(VariableExp expression, Collection values) {
    initialize();
    setVariable(expression);
    this.values = values;
  }

  private void setVariable(VariableExp expression) {
    this.arguments[0] = expression;
  }

  protected void initialize(){
    arguments = new Expression[1];
  }

  public String basicAsString(){
    String result = "";
    if(!values.isEmpty()){
      result += arguments[0].basicAsString() + " IN (";
      Iterator iterator = values.iterator();
      result += iterator.next().toString();
      while(iterator.hasNext()){
        result += ", " + iterator.next().toString();
      }
      result += ")";
    }
    return result;
  }

  public Object visitedBy(ExpressionVisitor visitor){
    return visitor.processIn(this);
  }

  public Expression getArgument(){
    return arguments[0];
  }

  public Collection getValues() {
    return values;
  }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.