head	1.3;
access;
symbols;
locks; strict;
comment	@# @;


1.3
date	2001.08.30.16.57.42;	author dlr;	state Exp;
branches;
next	1.2;

1.2
date	2001.08.27.08.32.44;	author dlr;	state Exp;
branches;
next	1.1;

1.1
date	2001.05.23.02.39.15;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.3
log
@Updated for latest Turbine API changes.
@
text
@package org.tigris.helm.tool;

import java.util.*;
import java.io.*;

import javax.servlet.*;
import javax.servlet.http.*;

import org.apache.turbine.ParameterParser;
import org.apache.turbine.ParameterParser;

/**
 * Provides access to form variables.
 *
 * @@author <a href="mailto:jon@@collab.net">Jon S. Stevens</a>
 * @@author <a href="mailto:dlr@@collab.net">Daniel Rall</a>
 */
public final class FormCache
{
    private ParameterParser pp = null;

    /**
     * Read the form data from the supplied Request object
     */
    protected FormCache(HttpServletRequest r)
    {
        pp = new ParameterParser();
        pp.setRequest(r);
    }

    /**
     * Overrides all the values in the existing cach with another's.
     */
    public final void override(FormCache other)
    {
        this.pp = other.pp;
    }

    /**
     * Gets a form value.
     */
    public final Object get(String field)
    {
       try
       {
           return (Object) pp.getObject(field);
       }
       catch (NullPointerException e)
       {
          return null;
       }
    }

    /**
     * Adds the specified mapping to this cache.
     */
    public final void put(String key, Object value) 
    {
        pp.add(key, value.toString());
    }

    /**
     * Removes the specified field from the cache.
     */
    public final void remove(String key) 
    {
        try
        {
            pp.remove(key);
        }
        catch (Exception ignored)
        {
            // Assume removed.
        }
    }
}
@


1.2
log
@Turbine API change.
@
text
@d9 2
a10 2
import org.apache.fulcrum.util.parser.DefaultParameterParser;
import org.apache.fulcrum.util.parser.ParameterParser;
d27 1
a27 1
        pp = new DefaultParameterParser();
@


1.1
log
@Moved FormCache from Joist into Helm.
@
text
@d9 2
a10 2
import org.apache.turbine.util.*;
import org.apache.turbine.util.parser.DefaultParameterParser;
@

