/* Copyright (c) 2001 Oracle Corporation. All Rights Reserved. */
package oracle.portal.utils.v2;

import java.util.*;

/**
 * A <code>ParameterMap</code> contains a set of parameters whose values
 * are <code>Object</code>s mapped to <code>String</code> names.
 *
 * @deprecated use Java 2 collection class such as HashMap
 */
public class SimpleParameterMap implements ParameterMap
{

    /**
     * Gets the value of the parameter with the given name. If either the name
     * or parameter does not exist, null is returned.
     *
     * @param parameterName the parameter name.
     * @return the parameter with given name.
     */
    public Object getParameterValue(String parameterName)
    {
        return mParams.get(parameterName);
    }

    /**
     * Adds the specified parameter.
     *
     * @param paramName the parameter name.
     * @param paramValue the parameter value.
     */
    public void putParameterValue(String paramName, Object paramValue)
    {
        mParams.put(paramName, paramValue);
    }

    /**
     * Returns an <code>Enumeration</code> of the parameter names belonging to
     * this <code>ParameterMap</code> object, this may then be used to fetch
     * the parameters sequentially.
     *
     * @return an <code>Enumeration</code> of the parameter names.
     */
    public Enumeration getParameterNames()
    {
        return mParams.keys();
    }

    /**
     * Returns true if this <code>ParameterMap</code> object contains the
     * specified String as a parameter name.
     *
     * @param parameterName parameter name to search for.
     * @return true if the give name is found, false otherwise.
     */
    public boolean containsParameter(String parameterName)
    {
        return mParams.containsKey(parameterName);
    }


    /**
     * Returns a Map containing the contents of this SimpleParameterMap. 
     *
     * This method is included to provide a quick & dirty way to get a Map from
     * a SimpleParameterMap. Added to allow rapid conversion of objects
     * so calls to deprecated methods in PortletContainerRenderer can
     * be converted to calls to equivalent supported methods with minimum
     * amount of work
     *
     * @return internal Map containing parameter values
     */ 
    public Map getMap()
    {
        return new HashMap(mParams);
    }
    
    private Hashtable mParams = new Hashtable(10);
}
