/* Generated by Together */

package cobalt.deployment.descriptor.dist;

import java.util.Hashtable;
import java.util.Enumeration;
import java.util.Vector;

import cobalt.deployment.descriptor.MethodDescriptor;

/**
 * Title:        J2EE container managed descriptor
 * Description:  Represents J2EE-specific container managed description for standard container managed description
 * Copyright:    Copyright (c) 2001
 * Company:      ETRI
 * @author Yeon Jun Choi
 * @version 1.0
 */

public class J2eeContainerManaged {
    public J2eeContainerManaged() {
        values = new Hashtable();
    }

    public String getJndiName(){ return jndiName; }

    public void setJndiName(String jndiName){ this.jndiName = jndiName; }

    public Hashtable getValues(){ return values; }

    public void setValues(Hashtable values){ this.values = values; }

    public String getName() {
        return (String)values.get("name");
    }

    public void setName(String name) {
        values.put("name", name);
    }

    public String getPassword() {
        return (String)values.get("password");
    }

    public void setPassword(String password) {
        values.put("password", password);
    }

    public String getTableCreateSql() {
        return (String)values.get("table-create-sql");
    }

    public void setTableCreateSql(String sql) {
        values.put("table-create-sql", sql);
    }

    public String getTableRemoveSql() {
        return (String)values.get("table-remove-sql");
    }

    public void setTableRemoveSql(String sql) {
        values.put("table-remove-sql", sql);
    }

    public Vector getMethods() {
        Vector ret = new Vector();
        Object[] keys = values.keySet().toArray();
        for ( int i=0 ; i<keys.length; i++)
            if (keys[i] instanceof MethodDescriptor)
            	ret.addElement(keys[i]);
        return ret;
    }

/*
    public String getSql(MethodDescriptor method) {
        return (String)values.get(method);
    }

    public void setSql(MethodDescriptor method, String sql) {
        values.put(method, sql);
    }

    public String getSql(String method) {
        return (String)values.get(method);
    }

    public void setSql(String method, String sql) {
        values.put(method, sql);
    }
*/
    public String getSql(Object method) {
        //if ( values.containsKey(method) )
System.out.println("get sql - " + method + " : " + values.get(method));
            return (String)values.get(method);
        //return "";
    }

    public void setSql(Object method, String sql) {
System.out.println("set sql - " + method + " : " + sql);
        values.put(method, sql);
    }

    public void removeMethod(Object method) {
System.out.println("remove sql - " + method);
        values.remove(method);
    }

    public boolean isTableCreateOnDeploy(){
            return tableCreateOnDeploy;
        }

    public String getTableCreateOnDeploy(){
        return ( tableCreateOnDeploy? "True" : "False" );
    }

    public void setTableCreateOnDeploy(boolean tableCreateOnDeploy){
            this.tableCreateOnDeploy = tableCreateOnDeploy;
        }

    public boolean isTableDeleteOnUndeploy(){
            return tableDeleteOnUndeploy;
        }

    public void setTableDeleteOnUndeploy(boolean tableDeleteOnUndeploy){
            this.tableDeleteOnUndeploy = tableDeleteOnUndeploy;
        }

    public String getTableDeleteOnUndeploy(){
        return ( tableDeleteOnUndeploy? "True" : "False" );
    }

    public boolean verify() {
        Enumeration enum = values.keys();
        while ( enum.hasMoreElements() ) {
            Object key = enum.nextElement();
            String value = (String)values.get(key);
            if ( value == null || value.equals("") )
                return false;
        }
        return true;
    }

    private String jndiName;
    private Hashtable values;
    private boolean tableCreateOnDeploy;
    private boolean tableDeleteOnUndeploy;
}
