View Javadoc

1   /*
2    * $Id: MultiPartRequest.java 651946 2008-04-27 13:41:38Z apetrelli $
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  package org.apache.struts2.dispatcher.multipart;
23  
24  import java.io.File;
25  import java.io.IOException;
26  import java.util.Enumeration;
27  import java.util.List;
28  
29  import javax.servlet.http.HttpServletRequest;
30  
31  
32  /***
33   * Abstract wrapper class HTTP requests to handle multi-part data. <p>
34   *
35   */
36  public interface MultiPartRequest {
37  
38      public void parse(HttpServletRequest request, String saveDir) throws IOException;
39      
40      /***
41       * Returns an enumeration of the parameter names for uploaded files
42       *
43       * @return an enumeration of the parameter names for uploaded files
44       */
45      public Enumeration<String> getFileParameterNames();
46  
47      /***
48       * Returns the content type(s) of the file(s) associated with the specified field name
49       * (as supplied by the client browser), or <tt>null</tt> if no files are associated with the
50       * given field name.
51       *
52       * @param fieldName input field name
53       * @return an array of content encoding for the specified input field name or <tt>null</tt> if
54       *         no content type was specified.
55       */
56      public String[] getContentType(String fieldName);
57  
58      /***
59       * Returns a {@link java.io.File} object for the filename specified or <tt>null</tt> if no files
60       * are associated with the given field name.
61       *
62       * @param fieldName input field name
63       * @return a File[] object for files associated with the specified input field name
64       */
65      public File[] getFile(String fieldName);
66  
67      /***
68       * Returns a String[] of file names for files associated with the specified input field name
69       *
70       * @param fieldName input field name
71       * @return a String[] of file names for files associated with the specified input field name
72       */
73      public String[] getFileNames(String fieldName);
74  
75      /***
76       * Returns the file system name(s) of files associated with the given field name or
77       * <tt>null</tt> if no files are associated with the given field name.
78       *
79       * @param fieldName input field name
80       * @return the file system name(s) of files associated with the given field name
81       */
82      public String[] getFilesystemName(String fieldName);
83  
84      /***
85       * Returns the specified request parameter.
86       *
87       * @param name the name of the parameter to get
88       * @return the parameter or <tt>null</tt> if it was not found.
89       */
90      public String getParameter(String name);
91  
92      /***
93       * Returns an enumeration of String parameter names.
94       *
95       * @return an enumeration of String parameter names.
96       */
97      public Enumeration<String> getParameterNames();
98  
99      /***
100      * Returns a list of all parameter values associated with a parameter name. If there is only
101      * one parameter value per name the resulting array will be of length 1.
102      *
103      * @param name the name of the parameter.
104      * @return an array of all values associated with the parameter name.
105      */
106     public String[] getParameterValues(String name);
107 
108     /***
109      * Returns a list of error messages that may have occurred while processing the request.
110      * If there are no errors, an empty list is returned. If the underlying implementation
111      * (ie: pell, cos, jakarta, etc) cannot support providing these errors, an empty list is
112      * also returned. This list of errors is repoted back to the
113      * {@link MultiPartRequestWrapper}'s errors field.
114      *
115      * @return a list of Strings that represent various errors during parsing
116      */
117     public List getErrors();
118 }