/* Generated by Together */

package cobalt.deployment.descriptor.dist;

import java.util.ArrayList;

/**
 * Title:        WebLogic 5.1 finder descriptor
 * Description:  Represents WebLogic 5.1-specific finder of dbms configuration
 * Copyright:    Copyright (c) 2001
 * Company:      ETRI
 * @author Yeon Jun Choi
 * @version 1.0
 */

public class Weblogic51Finder {
    public Weblogic51Finder() {
        params = new ArrayList();
        exps = new ArrayList();
    }
    public String getName(){
            return name;
        }

    public void setName(String name){
            this.name = name;
        }

    public ArrayList getParams(){
            return params;
        }

    public void setParams(ArrayList params){
            this.params = params;
        }

    public void setParams(String[] params){
            for ( int i=0 ; i<params.length; i++)
                this.params.add(params[i]);
        }

    public String getQuery(){
            return query;
        }

    public void setQuery(String query){
            this.query = query;
        }

    public String isUpdateString(){
            return update;
        }

    public boolean isUpdate(){
            return Boolean.getBoolean(update);
        }

    public void setUpdate(String update){
            this.update = update;
        }

    public String getFinderString() {
        return name + '(' + getParamsString() + ')';
    }
    public String getParamsString() {
        String ret = "";
        for ( int i=0 ; i<params.size(); i++) {
            ret += params.get(i);
            if ( i < params.size() - 1)
                ret += ',';
        }
        return ret;
    }

    public ArrayList getExps(){ return exps; }

    public void setExps(ArrayList exps){ this.exps = exps; }

    public int getExpSize() {
        return exps.size();
    }

    public Weblogic51Expression getExpression(int index) {
        return (Weblogic51Expression)exps.get(index);
    }

    public void addExpression(Weblogic51Expression exp) {
        exps.add(exp);
    }

    public Weblogic51Expression getExpressionOnNo(int no) {
        Weblogic51Expression exp = null;
        for ( int i=0 ; i<exps.size() ; i++) {
            exp = (Weblogic51Expression)exps.get(i);
            if (exp.getNo() == no)
                return exp;
        }
        return null;
    }

    public void removeExpression(int index) {
        exps.remove(index);
    }

    public Weblogic51Expression getNewExpressionOnNo() {
        int nextValue = 0;
        int i=0, j=0;
        Weblogic51Expression exp = null;
        for ( i=0 ; i<exps.size() ; i++) {
            exp = getExpressionOnNo(nextValue);
            if ( exp == null )
                break;
            nextValue++;
        }
        exp = new Weblogic51Expression();
        exp.setNo(nextValue);

        return exp;
    }

    private String name;
    private String query;
    private String update;
    private ArrayList params;
    private ArrayList exps;
}
