KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > catalina > connector > HttpResponseFacade


1
2
3 /*
4  * The contents of this file are subject to the terms
5  * of the Common Development and Distribution License
6  * (the "License"). You may not use this file except
7  * in compliance with the License.
8  *
9  * You can obtain a copy of the license at
10  * glassfish/bootstrap/legal/CDDLv1.0.txt or
11  * https://glassfish.dev.java.net/public/CDDLv1.0.html.
12  * See the License for the specific language governing
13  * permissions and limitations under the License.
14  *
15  * When distributing Covered Code, include this CDDL
16  * HEADER in each file and include the License file at
17  * glassfish/bootstrap/legal/CDDLv1.0.txt. If applicable,
18  * add the following below this CDDL HEADER, with the
19  * fields enclosed by brackets "[]" replaced with your
20  * own identifying information: Portions Copyright [yyyy]
21  * [name of copyright owner]
22  *
23  * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24  *
25  * Portions Copyright Apache Software Foundation.
26  */

27
28
29 package org.apache.catalina.connector;
30
31
32 import java.io.IOException JavaDoc;
33 import javax.servlet.ServletException JavaDoc;
34 import javax.servlet.ServletOutputStream JavaDoc;
35 import javax.servlet.http.HttpServletResponse JavaDoc;
36 import javax.servlet.http.Cookie JavaDoc;
37 import org.apache.catalina.HttpResponse;
38
39
40 /**
41  * Facade class that wraps a Catalina-internal <b>HttpResponse</b>
42  * object. All methods are delegated to the wrapped response.
43  *
44  * @author Remy Maucherat
45  * @author Craig R. McClanahan
46  * @version $Revision: 1.2 $ $Date: 2005/12/08 01:27:29 $
47  */

48
49 public final class HttpResponseFacade
50     extends ResponseFacade
51     implements HttpServletResponse JavaDoc {
52
53
54     // ----------------------------------------------------------- Constructors
55

56
57     /**
58      * Construct a wrapper for the specified response.
59      *
60      * @param response The response to be wrapped
61      */

62     public HttpResponseFacade(HttpResponse response) {
63         super(response);
64     }
65
66
67     // -------------------------------------------- HttpServletResponse Methods
68

69
70     public void addCookie(Cookie JavaDoc cookie) {
71
72         if (isCommitted())
73             return;
74
75         ((HttpServletResponse JavaDoc) response).addCookie(cookie);
76
77     }
78
79
80     public boolean containsHeader(String JavaDoc name) {
81         return ((HttpServletResponse JavaDoc) response).containsHeader(name);
82     }
83
84
85     public String JavaDoc encodeURL(String JavaDoc url) {
86         return ((HttpServletResponse JavaDoc) response).encodeURL(url);
87     }
88
89
90     public String JavaDoc encodeRedirectURL(String JavaDoc url) {
91         return ((HttpServletResponse JavaDoc) response).encodeRedirectURL(url);
92     }
93
94
95     public String JavaDoc encodeUrl(String JavaDoc url) {
96         return ((HttpServletResponse JavaDoc) response).encodeURL(url);
97     }
98
99
100     public String JavaDoc encodeRedirectUrl(String JavaDoc url) {
101         return ((HttpServletResponse JavaDoc) response).encodeRedirectURL(url);
102     }
103
104
105     public void sendError(int sc, String JavaDoc msg)
106         throws IOException JavaDoc {
107
108         if (isCommitted())
109             throw new IllegalStateException JavaDoc
110                 (/*sm.getString("responseBase.reset.ise")*/);
111
112         resp.setAppCommitted(true);
113
114         ((HttpServletResponse JavaDoc) response).sendError(sc, msg);
115
116     }
117
118
119     public void sendError(int sc)
120         throws IOException JavaDoc {
121
122         if (isCommitted())
123             throw new IllegalStateException JavaDoc
124                 (/*sm.getString("responseBase.reset.ise")*/);
125
126         resp.setAppCommitted(true);
127
128         ((HttpServletResponse JavaDoc) response).sendError(sc);
129
130     }
131
132
133     public void sendRedirect(String JavaDoc location)
134         throws IOException JavaDoc {
135
136         if (isCommitted())
137             throw new IllegalStateException JavaDoc
138                 (/*sm.getString("responseBase.reset.ise")*/);
139
140         resp.setAppCommitted(true);
141
142         ((HttpServletResponse JavaDoc) response).sendRedirect(location);
143
144     }
145
146
147     public void setDateHeader(String JavaDoc name, long date) {
148
149         if (isCommitted())
150             return;
151
152         ((HttpServletResponse JavaDoc) response).setDateHeader(name, date);
153
154     }
155
156
157     public void addDateHeader(String JavaDoc name, long date) {
158
159         if (isCommitted())
160             return;
161
162         ((HttpServletResponse JavaDoc) response).addDateHeader(name, date);
163
164     }
165
166
167     public void setHeader(String JavaDoc name, String JavaDoc value) {
168
169         if (isCommitted())
170             return;
171
172         ((HttpServletResponse JavaDoc) response).setHeader(name, value);
173
174     }
175
176
177     public void addHeader(String JavaDoc name, String JavaDoc value) {
178
179         if (isCommitted())
180             return;
181
182         ((HttpServletResponse JavaDoc) response).addHeader(name, value);
183
184     }
185
186
187     public void setIntHeader(String JavaDoc name, int value) {
188
189         if (isCommitted())
190             return;
191
192         ((HttpServletResponse JavaDoc) response).setIntHeader(name, value);
193
194     }
195
196
197     public void addIntHeader(String JavaDoc name, int value) {
198
199         if (isCommitted())
200             return;
201
202         ((HttpServletResponse JavaDoc) response).addIntHeader(name, value);
203
204     }
205
206
207     public void setStatus(int sc) {
208
209         if (isCommitted())
210             return;
211
212         ((HttpServletResponse JavaDoc) response).setStatus(sc);
213
214     }
215
216
217     public void setStatus(int sc, String JavaDoc sm) {
218
219         if (isCommitted())
220             return;
221
222         ((HttpServletResponse JavaDoc) response).setStatus(sc, sm);
223
224     }
225
226
227 }
228
Popular Tags