KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > icesoft > faces > env > ServletEnvironmentResponse


1 /*
2  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3  *
4  * "The contents of this file are subject to the Mozilla Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
11  * License for the specific language governing rights and limitations under
12  * the License.
13  *
14  * The Original Code is ICEfaces 1.5 open source software code, released
15  * November 5, 2006. The Initial Developer of the Original Code is ICEsoft
16  * Technologies Canada, Corp. Portions created by ICEsoft are Copyright (C)
17  * 2004-2006 ICEsoft Technologies Canada, Corp. All Rights Reserved.
18  *
19  * Contributor(s): _____________________.
20  *
21  * Alternatively, the contents of this file may be used under the terms of
22  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"
23  * License), in which case the provisions of the LGPL License are
24  * applicable instead of those above. If you wish to allow use of your
25  * version of this file only under the terms of the LGPL License and not to
26  * allow others to use your version of this file under the MPL, indicate
27  * your decision by deleting the provisions above and replace them with
28  * the notice and other provisions required by the LGPL License. If you do
29  * not delete the provisions above, a recipient may use your version of
30  * this file under either the MPL or the LGPL License."
31  *
32  */

33
34 package com.icesoft.faces.env;
35
36 import javax.servlet.ServletOutputStream JavaDoc;
37 import javax.servlet.http.Cookie JavaDoc;
38 import javax.servlet.http.HttpServletResponse JavaDoc;
39 import java.io.IOException JavaDoc;
40 import java.io.OutputStream JavaDoc;
41 import java.io.PrintWriter JavaDoc;
42 import java.util.Locale JavaDoc;
43
44 /**
45  * A pretty straight-forward wrapper for HttpServletResponse.
46  * <p/>
47  * It is up to the user to ensure that casts to this specific type and use the
48  * specific methods if you are running in the appropriate environment. Also,
49  * since we wrap real responses, the state of those responses can get changed by
50  * the application server, so it's possible that certain calls may result in
51  * exceptions being thrown.
52  * <p/>
53  * Note: This class may not be completely finished. We have only included what
54  * we've needed to this point.
55  */

56 public class ServletEnvironmentResponse
57         extends CommonEnvironmentResponse
58         implements HttpServletResponse JavaDoc {
59
60
61     //Servlet members
62
private HttpServletResponse JavaDoc response;
63
64
65     public ServletEnvironmentResponse(HttpServletResponse JavaDoc response) {
66         this.response = response;
67     }
68
69     //Common methods
70

71     public String JavaDoc getContentType() {
72         return response.getContentType();
73     }
74
75     public void setContentType(String JavaDoc type) {
76         response.setContentType(type);
77     }
78
79     public String JavaDoc getCharacterEncoding() {
80         return response.getCharacterEncoding();
81     }
82
83     public PrintWriter JavaDoc getWriter() throws IOException JavaDoc {
84         return response.getWriter();
85     }
86
87     public OutputStream JavaDoc getStream() throws IOException JavaDoc {
88         return response.getOutputStream();
89     }
90
91     public Locale JavaDoc getLocale() {
92         return response.getLocale();
93     }
94
95     public void setBufferSize(int size) {
96         response.setBufferSize(size);
97     }
98
99     public int getBufferSize() {
100         return response.getBufferSize();
101     }
102
103     public void flushBuffer() throws IOException JavaDoc {
104         response.flushBuffer();
105     }
106
107     public void resetBuffer() {
108         response.resetBuffer();
109     }
110
111     public boolean isCommitted() {
112         return response.isCommitted();
113     }
114
115     public void reset() {
116         response.reset();
117     }
118
119     public String JavaDoc encodeURL(String JavaDoc path) {
120         return response.encodeURL(path);
121     }
122
123     //Servlet specific methods
124

125     public ServletOutputStream JavaDoc getOutputStream() throws IOException JavaDoc {
126         return response.getOutputStream();
127     }
128
129     public void setCharacterEncoding(String JavaDoc encoding) {
130         response.setContentType(encoding);
131     }
132
133     public void setContentLength(int length) {
134         response.setContentLength(length);
135     }
136
137     public void setLocale(Locale JavaDoc locale) {
138         response.setLocale(locale);
139     }
140
141     public void addCookie(Cookie JavaDoc cookie) {
142         response.addCookie(cookie);
143     }
144
145     public boolean containsHeader(String JavaDoc name) {
146         return response.containsHeader(name);
147     }
148
149     public String JavaDoc encodeRedirectURL(String JavaDoc url) {
150         return response.encodeRedirectURL(url);
151     }
152
153     public String JavaDoc encodeUrl(String JavaDoc url) {
154         return encodeURL(url);
155     }
156
157     public String JavaDoc encodeRedirectUrl(String JavaDoc url) {
158         return encodeRedirectURL(url);
159     }
160
161     public void sendError(int code, String JavaDoc message) throws IOException JavaDoc {
162         response.sendError(code, message);
163     }
164
165     public void sendError(int code) throws IOException JavaDoc {
166         response.sendError(code);
167     }
168
169     public void sendRedirect(String JavaDoc dest) throws IOException JavaDoc {
170         response.sendRedirect(dest);
171     }
172
173     public void setDateHeader(String JavaDoc name, long date) {
174         response.setDateHeader(name, date);
175     }
176
177     public void addDateHeader(String JavaDoc name, long date) {
178         response.addDateHeader(name, date);
179     }
180
181     public void setHeader(String JavaDoc name, String JavaDoc val) {
182         response.setHeader(name, val);
183     }
184
185     public void addHeader(String JavaDoc name, String JavaDoc val) {
186         response.addHeader(name, val);
187     }
188
189     public void setIntHeader(String JavaDoc name, int val) {
190         response.setIntHeader(name, val);
191     }
192
193     public void addIntHeader(String JavaDoc name, int val) {
194         response.addIntHeader(name, val);
195     }
196
197     public void setStatus(int code) {
198         response.setStatus(code);
199     }
200
201     /**
202      * @deprecated
203      */

204     public void setStatus(int code, String JavaDoc message) {
205         response.setStatus(code, message);
206     }
207 }
208
Popular Tags