KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > pluto > portlet > PortletResponseWrapper


1 /*
2  * Copyright 2003,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 /*
17
18  */

19
20 package org.apache.pluto.portlet;
21
22 import javax.portlet.PortletResponse;
23
24 public class PortletResponseWrapper extends javax.servlet.http.HttpServletResponseWrapper JavaDoc
25 implements PortletResponse
26 {
27
28     /**
29     * Creates a ServletResponse adaptor wrapping the given response object.
30     * @throws java.lang.IllegalArgumentException if the response is null.
31     */

32     public PortletResponseWrapper(PortletResponse portletResponse)
33     {
34         super((javax.servlet.http.HttpServletResponse JavaDoc)portletResponse);
35
36         if (portletResponse == null)
37         {
38             throw new IllegalArgumentException JavaDoc("Response cannot be null");
39         }
40     }
41
42     // javax.portlet.PortletResponse implementation ------------------------------------------------
43
public void addProperty(String JavaDoc key, String JavaDoc value)
44     {
45         this.getPortletResponse().addProperty(key, value);
46     }
47     
48     public void setProperty(String JavaDoc key, String JavaDoc value)
49     {
50         this.getPortletResponse().setProperty(key, value);
51     }
52
53     public String JavaDoc encodeURL(String JavaDoc path)
54     {
55         return this.getPortletResponse().encodeURL(path);
56     }
57     // --------------------------------------------------------------------------------------------
58

59     // additional methods -------------------------------------------------------------------------
60
/**
61      * Return the wrapped ServletResponse object.
62      */

63     public PortletResponse getPortletResponse()
64     {
65         return (PortletResponse) super.getResponse();
66     }
67
68     /**
69      * Sets the response being wrapped.
70      * @throws java.lang.IllegalArgumentException if the response is null.
71      */

72     public void setResponse(PortletResponse response)
73     {
74         if (response == null)
75         {
76             throw new IllegalArgumentException JavaDoc("Response cannot be null");
77         }
78         setResponse((javax.servlet.http.HttpServletResponse JavaDoc)response);
79     }
80     // --------------------------------------------------------------------------------------------
81
}
82
83
Popular Tags