/* Generated by Together */

package cobalt.deployment.descriptor.dist;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.Iterator;

import cobalt.deployment.descriptor.MethodDescriptor;

/**
 * Title:        WebLogic transaction isolation
 * Description:  Represents WebLogic-specific Isolation-level / MethodDescriptor Set pair
 *
 * Copyright:    Copyright (c) 2001
 * Company:      ETRI
 * @author Yeon Jun Choi
 * @version 1.0
 */

public class Weblogic60TransactionIsolation {
    Weblogic60TransactionIsolation() {
		elements = new HashMap();
        for ( int i=0 ; i<ISOLATION_LEVEL.length; i++) {
            elements.put(ISOLATION_LEVEL[i], new HashSet());
        }
    }
    public void setMethod(String level, MethodDescriptor method) {
        Set methods = (Set)elements.get(level);
        methods.add(method);
    }
    public void removeMethod(String level, MethodDescriptor method) {
        Set methods = (Set)elements.get(level);
        methods.remove(method);
    }
    public void changeMethod(String level, MethodDescriptor method) {
        for ( int i=0 ; i<ISOLATION_LEVEL.length; i++)
            removeMethod(ISOLATION_LEVEL[i], method);
        setMethod(level, method);
    }
    public Set getMethods(String level) {
        return (Set)elements.get(level);
    }
    public Iterator getMethodsIterator(String level) {
        return getMethods(level).iterator();
    }
    public boolean containsMethod(String level, MethodDescriptor md) {
        return ((Set)elements.get(level)).contains(md);
    }
    private HashMap elements;
    public static final String[] ISOLATION_LEVEL = {
        "TRANSACTION_SERIALIZABLE","TRANSACTION_READ_COMMITTED",
        "TRANSACTION_READ_UNCOMMITTED","TRANSACTION_REPEATABLE_READ"
    };
}
