KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > services > portletcontainer > impl > portletAPIImp > RenderRequestImp


1 /**
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved.
3  * Please look at license.txt in info directory for more license detail.
4  **/

5
6 /**
7  * Created by The eXo Platform SARL
8  * Author : Mestrallet Benjamin
9  * benjmestrallet@users.sourceforge.net
10  * Date: Jul 29, 2003
11  * Time: 5:50:44 PM
12  */

13 package org.exoplatform.services.portletcontainer.impl.portletAPIImp;
14
15
16 import javax.portlet.RenderRequest;
17 import javax.servlet.http.HttpServletRequest JavaDoc;
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 JavaDoc 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 JavaDoc getParameter(String JavaDoc param) {
47         if(param == null || param.startsWith(Constants.PARAMETER_ENCODER))
48       throw new IllegalArgumentException JavaDoc("parameter must not be null");
49     Object JavaDoc obj = renderParameters.get(param);
50     if (obj instanceof String JavaDoc[]) {
51       String JavaDoc[] tmp = (String JavaDoc[]) obj ;
52       return tmp[0] ;
53     }
54     return (String JavaDoc) 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 JavaDoc key = (String JavaDoc) iterator.next();
63         if(!key.startsWith(Constants.PARAMETER_ENCODER))
64                     paramNames.add(key);
65             }
66         }
67     return paramNames.elements();
68   }
69
70   public String JavaDoc[] getParameterValues(String JavaDoc s) {
71         if(s == null || s.startsWith(Constants.PARAMETER_ENCODER))
72             throw new IllegalArgumentException JavaDoc("parameter must not be null");
73     return (String JavaDoc[]) 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 JavaDoc key = (String JavaDoc) iterator.next();
82                 String JavaDoc[] values = (String JavaDoc[]) 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