01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
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;
20: import java.util.Iterator;
21: import java.util.Map;
22:
23: import javax.servlet.http.HttpServletRequest;
24: import javax.servlet.http.HttpServletRequestWrapper;
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
37: HttpServletRequestWrapper implements
38: MultipartHttpServletRequest {
39:
40: private Map multipartFiles;
41:
42: /**
43: * Wrap the given HttpServletRequest in a MultipartHttpServletRequest.
44: * @param request the request to wrap
45: */
46: protected AbstractMultipartHttpServletRequest(
47: HttpServletRequest request) {
48: super (request);
49: }
50:
51: /**
52: * Set a Map with parameter names as keys and MultipartFile objects as values.
53: * To be invoked by subclasses on initialization.
54: */
55: protected void setMultipartFiles(Map multipartFiles) {
56: this .multipartFiles = Collections
57: .unmodifiableMap(multipartFiles);
58: }
59:
60: public Iterator getFileNames() {
61: return this .multipartFiles.keySet().iterator();
62: }
63:
64: public MultipartFile getFile(String name) {
65: return (MultipartFile) this .multipartFiles.get(name);
66: }
67:
68: public Map getFileMap() {
69: return this.multipartFiles;
70: }
71:
72: }
|