KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > oreilly > servlet > MultipartWrapper


1 // Copyright (C) 1998-2001 by Jason Hunter <jhunter_AT_acm_DOT_org>.
2
// All rights reserved. Use of this class is limited.
3
// Please see the LICENSE for more information.
4

5 package com.oreilly.servlet;
6
7 import java.io.*;
8 import java.util.*;
9 import javax.servlet.*;
10 import javax.servlet.http.*;
11
12 /**
13  * A request wrapper to support MultipartFilter.
14  * The filter capability requires Servlet API 2.3.
15  * <p>
16  * See Jason Hunter's June 2001 article in JavaWorld for a full explanation of
17  * the class usage.
18  *
19  * @author <b>Jason Hunter</b>, Copyright &#169; 2001
20  * @version 1.0, 2001/06/19
21  */

22 public class MultipartWrapper extends HttpServletRequestWrapper {
23
24   MultipartRequest mreq = null;
25
26   public MultipartWrapper(HttpServletRequest req, String JavaDoc dir)
27                                      throws IOException {
28     super(req);
29     mreq = new MultipartRequest(req, dir);
30   }
31
32   // Methods to replace HSR methods
33
public Enumeration getParameterNames() {
34     return mreq.getParameterNames();
35   }
36   public String JavaDoc getParameter(String JavaDoc name) {
37     return mreq.getParameter(name);
38   }
39   public String JavaDoc[] getParameterValues(String JavaDoc name) {
40     return mreq.getParameterValues(name);
41   }
42   public Map getParameterMap() {
43     Map map = new HashMap();
44     Enumeration paramenum = getParameterNames();
45     while (paramenum.hasMoreElements()) {
46       String JavaDoc name = (String JavaDoc) paramenum.nextElement();
47       map.put(name, mreq.getParameterValues(name));
48     }
49     return map;
50   }
51
52   // Methods only in MultipartRequest
53
public Enumeration getFileNames() {
54     return mreq.getFileNames();
55   }
56   public String JavaDoc getFilesystemName(String JavaDoc name) {
57     return mreq.getFilesystemName(name);
58   }
59   public String JavaDoc getContentType(String JavaDoc name) {
60     return mreq.getContentType(name);
61   }
62   public File getFile(String JavaDoc name) {
63     return mreq.getFile(name);
64   }
65 }
66
Popular Tags