All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.fulcrum.parser.ParameterParser Maven / Gradle / Ivy

The newest version!
package org.apache.fulcrum.parser;

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

import java.util.Collection;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.Part;

/**
 * ParameterParser is an interface to a utility to handle parsing and
 * retrieving the data passed via the GET/POST/PATH_INFO arguments.
 *
 * 

NOTE: The name= portion of a name=value pair may be converted * to lowercase or uppercase when the object is initialized and when * new data is added. This behaviour is determined by the url.case.folding * property in TurbineResources.properties. Adding a name/value pair may * overwrite existing name=value pairs if the names match: * *

 * ParameterParser pp = data.getParameters();
 * pp.add("ERROR",1);
 * pp.add("eRrOr",2);
 * int result = pp.getInt("ERROR");
 * 
* * In the above example, result is 2. * * @author Ilkka Priha * @author Jon S. Stevens * @author Sean Legassick * @author Jürgen Hoffmann * @author Thomas Vandahl * @version $Id$ */ public interface ParameterParser extends ValueParser { /** * Gets the parsed servlet request. * * @return the parsed servlet request or null. */ HttpServletRequest getRequest(); /** * Sets the servlet request to be parser. This requires a * valid HttpServletRequest object. It will attempt to parse out * the GET/POST/PATH_INFO data and store the data into a Hashtable. * There are convenience methods for retrieving the data as a * number of different datatypes. The PATH_INFO data must be a * URLEncoded() string. * *

To add name/value pairs to this set of parameters, use the * add() methods. * * @param req An HttpServletRequest. */ void setRequest(HttpServletRequest req); /** * Sets the uploadData byte[] * * @param uploadData A byte[] with data. */ void setUploadData ( byte[] uploadData ); /** * Gets the uploadData byte[] * * @return uploadData A byte[] with data. */ byte[] getUploadData(); /** * Add a Part object as a parameters. If there are any * Parts already associated with the name, append to the * array. The reason for this is that RFC 1867 allows multiple * files to be associated with single HTML input element. * * @param name A String with the name. * @param value A Part with the value. */ void add( String name, Part value ); /** * Return a Part object for the given name. If the name does * not exist or the object stored is not a Part, return null. * * @param name A String with the name. * @return A Part. */ Part getPart(String name); /** * Return an array of Part objects for the given name. If the * name does not exist or the object stored is not a Part * array, return null. * * @param name A String with the name. * @return A Part[]. */ Part[] getParts(String name); /** * Return an array of all Part objects. If no parts * exist or the object stored is not a Part * array, return an empty list. * @return Collection Collection of parts */ Collection getParts(); /** * Convenience fileName utility, which extracts the filename from header * * @param part The part which represents the uploaded file * @return the fileName String object. */ String getFileName(Part part); }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy