KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > web > multipart > support > AbstractMultipartHttpServletRequest


1 /*
2  * Copyright 2002-2005 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.web.multipart.support;
18
19 import java.util.Collections JavaDoc;
20 import java.util.Iterator JavaDoc;
21 import java.util.Map JavaDoc;
22
23 import javax.servlet.http.HttpServletRequest JavaDoc;
24 import javax.servlet.http.HttpServletRequestWrapper JavaDoc;
25
26 import org.springframework.web.multipart.MultipartFile;
27 import org.springframework.web.multipart.MultipartHttpServletRequest;
28
29 /**
30  * Abstract base implementation of the MultipartHttpServletRequest interface.
31  * Provides management of pre-generated MultipartFile instances.
32  *
33  * @author Juergen Hoeller
34  * @since 06.10.2003
35  */

36 public abstract class AbstractMultipartHttpServletRequest extends HttpServletRequestWrapper JavaDoc
37     implements MultipartHttpServletRequest {
38
39     private Map JavaDoc multipartFiles;
40
41
42     /**
43      * Wrap the given HttpServletRequest in a MultipartHttpServletRequest.
44      * @param request the request to wrap
45      */

46     protected AbstractMultipartHttpServletRequest(HttpServletRequest JavaDoc request) {
47         super(request);
48     }
49
50     /**
51      * Set a Map with parameter names as keys and MultipartFile objects as values.
52      * To be invoked by subclasses on initialization.
53      */

54     protected void setMultipartFiles(Map JavaDoc multipartFiles) {
55         this.multipartFiles = Collections.unmodifiableMap(multipartFiles);
56     }
57
58
59     public Iterator JavaDoc getFileNames() {
60         return this.multipartFiles.keySet().iterator();
61     }
62
63     public MultipartFile getFile(String JavaDoc name) {
64         return (MultipartFile) this.multipartFiles.get(name);
65     }
66
67     public Map JavaDoc getFileMap() {
68         return this.multipartFiles;
69     }
70
71 }
72
Popular Tags