1 16 17 package org.springframework.web.multipart.support; 18 19 import java.util.Collections ; 20 import java.util.Enumeration ; 21 import java.util.HashMap ; 22 import java.util.HashSet ; 23 import java.util.Map ; 24 import java.util.Set ; 25 26 import javax.servlet.http.HttpServletRequest ; 27 28 37 public class DefaultMultipartHttpServletRequest extends AbstractMultipartHttpServletRequest { 38 39 private final Map multipartParameters; 40 41 42 49 public DefaultMultipartHttpServletRequest( 50 HttpServletRequest request, Map multipartFiles, Map multipartParameters) { 51 52 super(request); 53 setMultipartFiles(multipartFiles); 54 this.multipartParameters = multipartParameters; 55 } 56 57 58 public Enumeration getParameterNames() { 59 Set paramNames = new HashSet (); 60 Enumeration paramEnum = super.getParameterNames(); 61 while (paramEnum.hasMoreElements()) { 62 paramNames.add(paramEnum.nextElement()); 63 } 64 paramNames.addAll(this.multipartParameters.keySet()); 65 return Collections.enumeration(paramNames); 66 } 67 68 public String getParameter(String name) { 69 String [] values = (String []) this.multipartParameters.get(name); 70 if (values != null) { 71 return (values.length > 0 ? values[0] : null); 72 } 73 return super.getParameter(name); 74 } 75 76 public String [] getParameterValues(String name) { 77 String [] values = (String []) this.multipartParameters.get(name); 78 if (values != null) { 79 return values; 80 } 81 return super.getParameterValues(name); 82 } 83 84 public Map getParameterMap() { 85 Map paramMap = new HashMap (); 86 paramMap.putAll(super.getParameterMap()); 87 paramMap.putAll(this.multipartParameters); 88 return paramMap; 89 } 90 91 } 92 | Popular Tags |