KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.io.IOException JavaDoc;
12 import java.io.OutputStream JavaDoc;
13 import java.io.PrintWriter JavaDoc;
14 import java.util.Locale JavaDoc;
15
16 import javax.portlet.RenderResponse;
17 import javax.servlet.ServletOutputStream JavaDoc;
18 import javax.servlet.http.Cookie JavaDoc;
19 import javax.servlet.http.HttpServletResponse JavaDoc;
20
21 import org.jboss.portal.server.PortalResponse;
22
23 /**
24  * @author <a HREF="mailto:julien@jboss.org">Julien Viet</a>
25  * @version $Revision: 1.3 $
26  */

27 public class DispatchedHttpServletResponse implements HttpServletResponse JavaDoc
28 {
29
30    private PortalResponse presp;
31    private RenderResponse rresp;
32    private HttpServletResponse JavaDoc hresp;
33    private ServletOutputStream JavaDoc sos;
34
35    public DispatchedHttpServletResponse(PortalResponse presp, RenderResponse rresp, HttpServletResponse JavaDoc hresp)
36    {
37       this.presp = presp;
38       this.rresp = rresp;
39       this.hresp = hresp;
40       this.sos = null;
41    }
42
43    // Must return null
44

45    public String JavaDoc encodeRedirectURL(String JavaDoc s)
46    {
47       return null;
48    }
49
50    public String JavaDoc encodeRedirectUrl(String JavaDoc s)
51    {
52       return null;
53    }
54
55    // Must be equivalent to the methods of the RenderResponse
56

57    public String JavaDoc getCharacterEncoding()
58    {
59       return rresp.getCharacterEncoding();
60    }
61
62    public void setBufferSize(int i)
63    {
64       rresp.setBufferSize(i);
65    }
66
67    public void flushBuffer() throws IOException JavaDoc
68    {
69       rresp.flushBuffer();
70    }
71
72    public void resetBuffer()
73    {
74       rresp.resetBuffer();
75    }
76
77    public void reset()
78    {
79       rresp.reset();
80    }
81
82    public int getBufferSize()
83    {
84       return rresp.getBufferSize();
85    }
86
87    public boolean isCommitted()
88    {
89       return rresp.isCommitted();
90    }
91
92    public ServletOutputStream JavaDoc getOutputStream() throws IOException JavaDoc
93    {
94       if (sos == null)
95       {
96          sos = new ServletOutputStream JavaDoc()
97          {
98             private OutputStream JavaDoc out = rresp.getPortletOutputStream();
99             public void write(byte b[], int off, int len) throws IOException JavaDoc
100             {
101                out.write(b, off, len);
102             }
103             public void write(byte b[]) throws IOException JavaDoc
104             {
105                out.write(b);
106             }
107             public void write(int b) throws IOException JavaDoc
108             {
109                out.write(b);
110             }
111          };
112       }
113       return sos;
114    }
115
116    public PrintWriter JavaDoc getWriter() throws IOException JavaDoc
117    {
118       return rresp.getWriter();
119    }
120
121    public String JavaDoc encodeURL(String JavaDoc s)
122    {
123       return rresp.encodeURL(s);
124    }
125
126    public String JavaDoc encodeUrl(String JavaDoc s)
127    {
128       return rresp.encodeURL(s);
129    }
130
131    // Must perform no operations
132

133    public void setContentType(String JavaDoc s)
134    {
135    }
136
137    public void setContentLength(int i)
138    {
139    }
140
141    public void setLocale(Locale JavaDoc locale)
142    {
143    }
144
145    public void addCookie(Cookie JavaDoc cookie)
146    {
147    }
148
149    public void sendError(int i) throws IOException JavaDoc
150    {
151    }
152
153    public void sendError(int i, String JavaDoc s) throws IOException JavaDoc
154    {
155    }
156
157    public void sendRedirect(String JavaDoc s) throws IOException JavaDoc
158    {
159    }
160
161    public void setDateHeader(String JavaDoc s, long l)
162    {
163    }
164
165    public void addDateHeader(String JavaDoc s, long l)
166    {
167    }
168
169    public void setHeader(String JavaDoc s, String JavaDoc s1)
170    {
171    }
172
173    public void addHeader(String JavaDoc s, String JavaDoc s1)
174    {
175    }
176
177    public void setIntHeader(String JavaDoc s, int i)
178    {
179    }
180
181    public void addIntHeader(String JavaDoc s, int i)
182    {
183    }
184
185    public void setStatus(int i)
186    {
187    }
188
189    public void setStatus(int i, String JavaDoc s)
190    {
191    }
192
193    public boolean containsHeader(String JavaDoc s)
194    {
195       // Must return false
196
return false;
197    }
198
199    // Must be based on the getLocale method of the RenderResponse
200

201    public Locale JavaDoc getLocale()
202    {
203       return rresp.getLocale();
204    }
205
206    // Belongs to servlet 2.4 - not specified how it should behave yet
207

208    public String JavaDoc getContentType()
209    {
210       throw new UnsupportedOperationException JavaDoc("Not specified by spec");
211    }
212
213    public void setCharacterEncoding(String JavaDoc s)
214    {
215       throw new UnsupportedOperationException JavaDoc("Not specified by spec");
216    }
217 }
218
219
Popular Tags