KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > jsp > JSPEngineServletResponse


1 /*
2  * Copyright 1999-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 package org.apache.cocoon.components.jsp;
17
18 import java.io.IOException JavaDoc;
19 import java.io.PrintWriter JavaDoc;
20 import java.util.Locale JavaDoc;
21
22 import javax.servlet.ServletOutputStream JavaDoc;
23 import javax.servlet.http.Cookie JavaDoc;
24 import javax.servlet.http.HttpServletResponse JavaDoc;
25
26
27 /**
28  * Stub implementation of HttpServletResponse.
29  */

30 public class JSPEngineServletResponse implements HttpServletResponse JavaDoc {
31
32     private final HttpServletResponse JavaDoc servletResponse;
33     private final JSPEngineServletOutputStream output;
34     
35     private boolean hasWriter = false;
36     private boolean hasOutputStream = false;
37
38     public JSPEngineServletResponse(HttpServletResponse JavaDoc servletResponse, JSPEngineServletOutputStream output) {
39         this.servletResponse = servletResponse;
40         this.output = output;
41     }
42     public String JavaDoc getCharacterEncoding() {
43         return this.servletResponse.getCharacterEncoding();
44     }
45     public Locale JavaDoc getLocale(){
46         return this.servletResponse.getLocale();
47     }
48     public PrintWriter JavaDoc getWriter() {
49         if (this.hasOutputStream) {
50             throw new IllegalStateException JavaDoc("getOutputStream was already called.");
51         }
52         this.hasWriter = true;
53         return this.output.getWriter();
54     }
55     public void setContentLength(int len) {
56         // this value can be overriden by cocoon
57
servletResponse.setContentLength(len);
58     }
59     public void setContentType(java.lang.String JavaDoc type) {
60         servletResponse.setContentType(type);
61     }
62     public void setLocale(java.util.Locale JavaDoc loc) {
63         servletResponse.setLocale(loc);
64     }
65     public ServletOutputStream JavaDoc getOutputStream() {
66         if (this.hasWriter) {
67             throw new IllegalStateException JavaDoc("getWriter was already called.");
68         }
69         this.hasOutputStream = true;
70         return this.output;
71     }
72     public void addCookie(Cookie JavaDoc cookie){
73         servletResponse.addCookie(cookie);
74     }
75     public boolean containsHeader(String JavaDoc s){
76         return servletResponse.containsHeader(s);
77     }
78     /** @deprecated use encodeURL(String url) instead. */
79     public String JavaDoc encodeUrl(String JavaDoc s){
80         return servletResponse.encodeUrl(s);
81     }
82     public String JavaDoc encodeURL(String JavaDoc s){
83         return servletResponse.encodeURL(s);
84     }
85     /** @deprecated use encodeRedirectURL(String url) instead. */
86     public String JavaDoc encodeRedirectUrl(String JavaDoc s){
87         return servletResponse.encodeRedirectUrl(s);
88     }
89     public String JavaDoc encodeRedirectURL(String JavaDoc s){
90         return servletResponse.encodeRedirectURL(s);
91     }
92     public void sendError(int i, String JavaDoc s) throws IOException JavaDoc{
93         servletResponse.sendError(i,s);
94     }
95     public void sendError(int i) throws IOException JavaDoc{
96         servletResponse.sendError(i);
97     }
98     public void sendRedirect(String JavaDoc s) throws IOException JavaDoc{
99         servletResponse.sendRedirect(s);
100     }
101     public void setDateHeader(String JavaDoc s, long l) {
102         servletResponse.setDateHeader(s, l);
103     }
104     public void addDateHeader(String JavaDoc s, long l) {
105         servletResponse.addDateHeader(s, l);
106     }
107     public void setHeader(String JavaDoc s, String JavaDoc s1) {
108         servletResponse.setHeader(s, s1);
109     }
110     public void addHeader(String JavaDoc s, String JavaDoc s1) {
111         servletResponse.addHeader(s, s1);
112     }
113     public void setIntHeader(String JavaDoc s, int i) {
114         servletResponse.setIntHeader(s, i);
115     }
116     public void addIntHeader(String JavaDoc s, int i) {
117         servletResponse.addIntHeader(s, i);
118     }
119     public void setStatus(int i){
120         servletResponse.setStatus(i);
121     }
122     /** @deprecated use sendError(int, String) instead */
123     public void setStatus(int i, String JavaDoc s){
124         servletResponse.setStatus(i, s);
125     }
126     public void resetBuffer() {}
127     public void reset() {}
128     public int getBufferSize() { return 1024; }
129     public void setBufferSize(int size) {}
130     public void flushBuffer() throws IOException JavaDoc {}
131     public boolean isCommitted() { return false; }
132
133 }
134
Popular Tags