001// Copyright 2004, 2005 The Apache Software Foundation
002//
003// Licensed under the Apache License, Version 2.0 (the "License");
004// you may not use this file except in compliance with the License.
005// You may obtain a copy of the License at
006//
007//     http://www.apache.org/licenses/LICENSE-2.0
008//
009// Unless required by applicable law or agreed to in writing, software
010// distributed under the License is distributed on an "AS IS" BASIS,
011// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012// See the License for the specific language governing permissions and
013// limitations under the License.
014
015package org.apache.tapestry.multipart;
016
017import javax.servlet.http.HttpServletRequest;
018
019import org.apache.tapestry.request.IUploadFile;
020
021/**
022 * Defines how a multipart HTTP request can be broken into individual elements (including file
023 * uploads).
024 * <p>
025 * Multipart decoder implementations must be threadsafe.
026 * 
027 * @author Howard Lewis Ship
028 * @since 2.3
029 */
030
031public interface IMultipartDecoder
032{
033    /**
034     * Decodes the incoming request, identifying all the parts (values and uploaded files) contained
035     * within.
036     */
037
038    public void decode(HttpServletRequest request);
039
040    /**
041     * Invoked to release any resources needed by tghe decoder. In some cases, large incoming parts
042     * are written to temporary files; this method ensures those temporary files are deleted.
043     */
044
045    public void cleanup(HttpServletRequest request);
046
047    /**
048     * Returns the single value (or first value) for the parameter with the specified name. Returns
049     * null if no such parameter was in the request.
050     */
051
052    public String getString(HttpServletRequest request, String name);
053
054    /**
055     * Returns an array of values (possibly a single element array). Returns null if no such
056     * parameter was in the request.
057     */
058
059    public String[] getStrings(HttpServletRequest request, String name);
060
061    /**
062     * Returns the uploaded file with the specified parameter name, or null if no such parameter was
063     * in the request.
064     */
065
066    public IUploadFile getUploadFile(HttpServletRequest request, String name);
067
068    /**
069     * Returns the names of all parameters whose type is string (not file upload).
070     * 
071     * @since 4.0
072     */
073    public String[] getStringParameterNames(HttpServletRequest request);
074}