1 17 18 package org.objectweb.jac.aspects.gui.web; 19 20 import java.util.Iterator ; 21 import java.util.Map ; 22 import javax.servlet.http.HttpServletRequest ; 23 import org.mortbay.util.MultiMap; 24 25 28 public class MultiMapJacRequest extends AbstractJacRequest implements JacRequest { 29 MultiMap parameters; 30 31 34 public MultiMapJacRequest(MultiMap map, HttpServletRequest servletRequest) { 35 super(servletRequest); 36 this.parameters = map; 37 readParamsFromRequest(servletRequest); 38 } 39 40 public MultiMapJacRequest(MultiMap map, HttpServletRequest servletRequest, 41 JacRequest parent) { 42 this(map,servletRequest); 43 this.parent = parent; 44 } 45 46 49 public MultiMapJacRequest(HttpServletRequest servletRequest) { 50 super(servletRequest); 51 parameters = new MultiMap(); 52 readParamsFromRequest(servletRequest); 53 } 54 55 protected void readParamsFromRequest(HttpServletRequest servletRequest) { 56 Map servletParameters = servletRequest.getParameterMap(); 59 Iterator it = servletParameters.keySet().iterator(); 60 while(it.hasNext()) { 61 String name = (String )it.next(); 62 String [] values = (String [])servletParameters.get(name); 63 parameters.putValues(name,values); 64 } 65 } 66 67 public boolean contains(String name) { 68 if (parameters.containsKey(name)) 69 return true; 70 else if (parent!=null) 71 return parent.contains(name); 72 else 73 return false; 74 } 75 76 public Object getParameter(String name) { 77 if (parameters.containsKey(name)) 78 return parameters.getString(name); 79 else if (parent!=null) 80 return parent.getParameter(name); 81 else 82 return null; 83 } 84 85 public Object [] getParameters(String name) { 86 if (parameters.containsKey(name)) 87 return parameters.getValues(name).toArray(new String [0]); 88 else if (parent!=null) 89 return parent.getParameters(name); 90 else 91 return null; 92 } 93 94 public String toString() { 95 return parameters.toString(); 96 } 97 98 } 99 | Popular Tags |