KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > portal > portlet > impl > PortletResponseImpl


1 /*****************************************
2  * *
3  * JBoss Portal: The OpenSource Portal *
4  * *
5  * Distributable under LGPL license. *
6  * See terms of license at gnu.org. *
7  * *
8  *****************************************/

9 package org.jboss.portal.portlet.impl;
10
11 import javax.portlet.PortletResponse;
12
13 import org.jboss.portal.server.PortalRequest;
14 import org.jboss.portal.server.PortalResponse;
15 import org.jboss.portal.server.util.Properties;
16
17 /**
18  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
19  * @version $Revision: 1.4 $
20  */

21 public abstract class PortletResponseImpl implements PortletResponse
22 {
23
24    protected final PortalRequest req;
25    protected final PortalResponse resp;
26    protected final Properties properties;
27
28    protected PortletResponseImpl(
29          PortalRequest req,
30          PortalResponse resp,
31          Properties properties)
32    {
33       if (resp == null)
34       {
35          throw new IllegalArgumentException JavaDoc("Resp must not be null");
36       }
37       this.req = req;
38       this.resp = resp;
39       this.properties = properties;
40    }
41
42    public String JavaDoc encodeURL(String JavaDoc url)
43    {
44       if (url == null)
45       {
46          throw new IllegalArgumentException JavaDoc("URL must not be null");
47       }
48       if (!url.startsWith("http://") && !url.startsWith("/"))
49       {
50          throw new IllegalArgumentException JavaDoc("invalid URL " + url);
51       }
52       return resp.encodeURL(url);
53    }
54
55    public void addProperty(String JavaDoc name, String JavaDoc value)
56    {
57       properties.addProperty(name, value);
58    }
59
60    public void setProperty(String JavaDoc name, String JavaDoc value)
61    {
62       properties.setProperty(name, value);
63    }
64 }
65
Popular Tags