01: // Copyright (C) 1998-2001 by Jason Hunter <jhunter_AT_acm_DOT_org>.
02: // All rights reserved. Use of this class is limited.
03: // Please see the LICENSE for more information.
04:
05: package com.oreilly.servlet;
06:
07: import java.io.*;
08: import java.util.*;
09: 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 © 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 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:
37: public String getParameter(String name) {
38: return mreq.getParameter(name);
39: }
40:
41: public String[] getParameterValues(String name) {
42: return mreq.getParameterValues(name);
43: }
44:
45: public Map getParameterMap() {
46: Map map = new HashMap();
47: Enumeration paramenum = getParameterNames();
48: while (paramenum.hasMoreElements()) {
49: String name = (String) paramenum.nextElement();
50: map.put(name, mreq.getParameterValues(name));
51: }
52: return map;
53: }
54:
55: // Methods only in MultipartRequest
56: public Enumeration getFileNames() {
57: return mreq.getFileNames();
58: }
59:
60: public String getFilesystemName(String name) {
61: return mreq.getFilesystemName(name);
62: }
63:
64: public String getContentType(String name) {
65: return mreq.getContentType(name);
66: }
67:
68: public File getFile(String name) {
69: return mreq.getFile(name);
70: }
71: }
|