Coverage Report - org.apache.fulcrum.parser.ParameterParser
 
Classes in this File Line Coverage Branch Coverage Complexity
ParameterParser
N/A
N/A
1
 
 1  
 package org.apache.fulcrum.parser;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 import java.util.Collection;
 23  
 
 24  
 import javax.servlet.http.HttpServletRequest;
 25  
 import javax.servlet.http.Part;
 26  
 
 27  
 /**
 28  
  * ParameterParser is an interface to a utility to handle parsing and
 29  
  * retrieving the data passed via the GET/POST/PATH_INFO arguments.
 30  
  *
 31  
  * <p>NOTE: The name= portion of a name=value pair may be converted
 32  
  * to lowercase or uppercase when the object is initialized and when
 33  
  * new data is added.  This behaviour is determined by the url.case.folding
 34  
  * property in TurbineResources.properties.  Adding a name/value pair may
 35  
  * overwrite existing name=value pairs if the names match:
 36  
  *
 37  
  * <pre>
 38  
  * ParameterParser pp = data.getParameters();
 39  
  * pp.add("ERROR",1);
 40  
  * pp.add("eRrOr",2);
 41  
  * int result = pp.getInt("ERROR");
 42  
  * </pre>
 43  
  *
 44  
  * In the above example, result is 2.
 45  
  *
 46  
  * @author <a href="mailto:ilkka.priha@simsoft.fi">Ilkka Priha</a>
 47  
  * @author <a href="mailto:jon@clearink.com">Jon S. Stevens</a>
 48  
  * @author <a href="mailto:sean@informage.net">Sean Legassick</a>
 49  
  * @author <a href="mailto:jh@byteaction.de">J&#252;rgen Hoffmann</a>
 50  
  * @author <a href="mailto:tv@apache.org">Thomas Vandahl</a>
 51  
  * @version $Id: ParameterParser.java 1844836 2018-10-25 14:59:49Z painter $
 52  
  */
 53  
 public interface ParameterParser
 54  
     extends ValueParser
 55  
 {
 56  
     /**
 57  
      * Gets the parsed servlet request.
 58  
      *
 59  
      * @return the parsed servlet request or null.
 60  
      */
 61  
     HttpServletRequest getRequest();
 62  
 
 63  
     /**
 64  
      * Sets the servlet request to be parser.  This requires a
 65  
      * valid HttpServletRequest object.  It will attempt to parse out
 66  
      * the GET/POST/PATH_INFO data and store the data into a Hashtable.
 67  
      * There are convenience methods for retrieving the data as a
 68  
      * number of different datatypes.  The PATH_INFO data must be a
 69  
      * URLEncoded() string.
 70  
      *
 71  
      * <p>To add name/value pairs to this set of parameters, use the
 72  
      * <code>add()</code> methods.
 73  
      *
 74  
      * @param req An HttpServletRequest.
 75  
      */
 76  
     void setRequest(HttpServletRequest req);
 77  
 
 78  
     /**
 79  
      * Sets the uploadData byte[]
 80  
      *
 81  
      * @param uploadData A byte[] with data.
 82  
      */
 83  
     void setUploadData ( byte[] uploadData );
 84  
 
 85  
     /**
 86  
      * Gets the uploadData byte[]
 87  
      *
 88  
      * @return uploadData A byte[] with data.
 89  
      */
 90  
     byte[] getUploadData();
 91  
 
 92  
 
 93  
     /**
 94  
      * Add a Part object as a parameters.  If there are any
 95  
      * Parts already associated with the name, append to the
 96  
      * array.  The reason for this is that RFC 1867 allows multiple
 97  
      * files to be associated with single HTML input element.
 98  
      *
 99  
      * @param name A String with the name.
 100  
      * @param value A Part with the value.
 101  
      */
 102  
     void add( String name, Part value );
 103  
 
 104  
     /**
 105  
      * Return a Part object for the given name.  If the name does
 106  
      * not exist or the object stored is not a Part, return null.
 107  
      *
 108  
      * @param name A String with the name.
 109  
      * @return A Part.
 110  
      */
 111  
     Part getPart(String name);
 112  
 
 113  
     /**
 114  
      * Return an array of Part objects for the given name.  If the
 115  
      * name does not exist or the object stored is not a Part
 116  
      * array, return null.
 117  
      *
 118  
      * @param name A String with the name.
 119  
      * @return A Part[].
 120  
      */
 121  
     Part[] getParts(String name);
 122  
     
 123  
     /**
 124  
      * Return an array of all Part objects.  If no parts
 125  
      * exist or the object stored is not a Part
 126  
      * array, return an empty list.
 127  
 
 128  
      * @return Collection Collection of parts
 129  
      */
 130  
     Collection<Part> getParts();
 131  
     
 132  
     /**
 133  
      * Convenience fileName utility, which extracts the filename from header
 134  
      *  
 135  
      * @param part The part which represents the uploaded file
 136  
      * @return the fileName String object.
 137  
      */
 138  
     String getFileName(Part part);
 139  
 }