1 5 6 13 package org.exoplatform.services.portletcontainer.impl.portletAPIImp; 14 15 16 import javax.portlet.RenderRequest; 17 import javax.servlet.http.HttpServletRequest ; 18 import org.exoplatform.Constants; 19 import java.util.*; 20 21 public class RenderRequestImp extends PortletRequestImp 22 implements RenderRequest { 23 24 private boolean isRenderRequest; 25 private Map renderParameters; 26 private Vector paramNames; 27 private Map filteredMap; 28 29 public RenderRequestImp(HttpServletRequest httpServletRequest) { 30 super(httpServletRequest); 31 } 32 33 public void fillRenderRequest(Map renderParameters, boolean isRenderRequest) { 34 if(renderParameters == null) 35 this.renderParameters = new HashMap(); 36 else 37 this.renderParameters = renderParameters; 38 this.isRenderRequest = isRenderRequest; 39 } 40 41 public void emptyRenderRequest() { 42 this.paramNames = null; 43 this.filteredMap = null; 44 } 45 46 public String getParameter(String param) { 47 if(param == null || param.startsWith(Constants.PARAMETER_ENCODER)) 48 throw new IllegalArgumentException ("parameter must not be null"); 49 Object obj = renderParameters.get(param); 50 if (obj instanceof String []) { 51 String [] tmp = (String []) obj ; 52 return tmp[0] ; 53 } 54 return (String ) obj ; 55 } 56 57 public Enumeration getParameterNames() { 58 if(paramNames == null){ 59 Set set = renderParameters.keySet(); 60 paramNames = new Vector(); 61 for (Iterator iterator = set.iterator(); iterator.hasNext();) { 62 String key = (String ) iterator.next(); 63 if(!key.startsWith(Constants.PARAMETER_ENCODER)) 64 paramNames.add(key); 65 } 66 } 67 return paramNames.elements(); 68 } 69 70 public String [] getParameterValues(String s) { 71 if(s == null || s.startsWith(Constants.PARAMETER_ENCODER)) 72 throw new IllegalArgumentException ("parameter must not be null"); 73 return (String []) renderParameters.get(s); 74 } 75 76 public Map getParameterMap() { 77 if(filteredMap == null){ 78 Set set = renderParameters.keySet(); 79 filteredMap = new HashMap(); 80 for (Iterator iterator = set.iterator(); iterator.hasNext();) { 81 String key = (String ) iterator.next(); 82 String [] values = (String []) renderParameters.get(key); 83 if(!key.startsWith(Constants.PARAMETER_ENCODER)) 84 filteredMap.put(key, values); 85 } 86 } 87 return Collections.unmodifiableMap(filteredMap); 88 } 89 90 public boolean isRenderRequest() { 91 return isRenderRequest; 92 } 93 94 } 95 | Popular Tags |