Clover coverage report - Code Coverage for tapestry release 4.0-beta-9
Coverage timestamp: Sat Oct 1 2005 08:36:20 EDT
file stats: LOC: 79   Methods: 6
NCLOC: 37   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
UploadFormParametersWrapper.java 50% 88.9% 83.3% 82.4%
coverage coverage
 1    // Copyright 2005 The Apache Software Foundation
 2    //
 3    // Licensed under the Apache License, Version 2.0 (the "License");
 4    // you may not use this file except in compliance with the License.
 5    // You may obtain a copy of the License at
 6    //
 7    // http://www.apache.org/licenses/LICENSE-2.0
 8    //
 9    // Unless required by applicable law or agreed to in writing, software
 10    // distributed under the License is distributed on an "AS IS" BASIS,
 11    // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12    // See the License for the specific language governing permissions and
 13    // limitations under the License.
 14   
 15    package org.apache.tapestry.multipart;
 16   
 17    import java.util.Collections;
 18    import java.util.Enumeration;
 19    import java.util.Map;
 20   
 21    import javax.servlet.http.HttpServletRequest;
 22    import javax.servlet.http.HttpServletRequestWrapper;
 23   
 24    import org.apache.hivemind.util.Defense;
 25   
 26    /**
 27    * {@link javax.servlet.http.HttpServletRequest}  wrapper that provides access to the form
 28    * field values uploaded in a multipart request.
 29    *
 30    * @author Howard M. Lewis Ship
 31    * @since 4.0
 32    */
 33    public class UploadFormParametersWrapper extends HttpServletRequestWrapper
 34    {
 35    /**
 36    * Map of {@link ValuePart} keyed on parameter name.
 37    */
 38    private Map _parameterMap;
 39   
 40    /**
 41    * @param parameterMap
 42    * a map whose keys are parameter names and whose values are arrays of Strings.
 43    */
 44  10 public UploadFormParametersWrapper(HttpServletRequest request, Map parameterMap)
 45    {
 46  10 super(request);
 47   
 48  10 Defense.notNull(parameterMap, "parameterMap");
 49   
 50  10 _parameterMap = Collections.unmodifiableMap(parameterMap);
 51    }
 52   
 53  2 public String getParameter(String name)
 54    {
 55  2 String[] values = getParameterValues(name);
 56   
 57  2 return (values == null || values.length == 0) ? null : values[0];
 58    }
 59   
 60  1 public Map getParameterMap()
 61    {
 62  1 return _parameterMap;
 63    }
 64   
 65  16 public Enumeration getParameterNames()
 66    {
 67  16 return Collections.enumeration(_parameterMap.keySet());
 68    }
 69   
 70  25 public String[] getParameterValues(String name)
 71    {
 72  25 return (String[]) _parameterMap.get(name);
 73    }
 74   
 75  0 public String toString()
 76    {
 77  0 return "<UploadFormPartWrapper for " + getRequest() + ">";
 78    }
 79    }