KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > lutris > appserver > server > httpPresentation > servlet > ServletHttpPresentationOutputStream


1
2 /*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  *
22  * $Id: ServletHttpPresentationOutputStream.java,v 1.2 2005/03/24 10:51:16 slobodan Exp $
23  */

24
25
26
27
28
29 package com.lutris.appserver.server.httpPresentation.servlet;
30
31 import java.io.IOException JavaDoc;
32
33 import javax.servlet.ServletOutputStream JavaDoc;
34
35 import com.lutris.appserver.server.httpPresentation.HttpPresentationIOException;
36 import com.lutris.appserver.server.httpPresentation.HttpPresentationOutputStream;
37
38 /**
39  * HTTP request output stream writter for servlets.
40  * This implements all methods that are defined in OutputStream as calles
41  * to the servlet object, since we don't know which ones are implemented by
42  * ServletOutputStream.
43  *
44  * @see javax.servlet.ServletOutputStream
45  */

46 public class ServletHttpPresentationOutputStream
47     extends HttpPresentationOutputStream {
48
49     private ServletHttpPresentationResponse response;
50     private ServletOutputStream JavaDoc outputStream;
51
52     /**
53      * Construct an object for accessing a servlet output stream.
54      */

55     protected ServletHttpPresentationOutputStream(ServletHttpPresentationResponse response,
56                                                   ServletOutputStream JavaDoc outputStream) {
57         this.response = response;
58         this.outputStream = outputStream;
59     }
60
61     /**
62      * Prints the string provided.
63      * @exception IOException if an I/O error has occurred
64      */

65     public void print(String JavaDoc s) throws IOException JavaDoc {
66         try {
67             outputStream.print(s);
68         } catch (IOException JavaDoc except) {
69             throw new HttpPresentationIOException(except);
70         }
71     }
72
73     /**
74      * Prints the boolean provided.
75      * @exception IOException if an I/O error has occurred.
76      */

77     public void print(boolean b) throws IOException JavaDoc {
78         try {
79             outputStream.print(b);
80         } catch (IOException JavaDoc except) {
81             throw new HttpPresentationIOException(except);
82         }
83     }
84
85     /*
86      * Prints the character provided.
87      * @exception IOException if an I/O error has occurred
88      */

89     public void print(char c) throws IOException JavaDoc {
90         try {
91             outputStream.print(c);
92         } catch (IOException JavaDoc except) {
93             throw new HttpPresentationIOException(except);
94         }
95     }
96
97     /**
98      * Prints the integer provided.
99      * @exception IOException if an I/O error has occurred
100      */

101     public void print(int i) throws IOException JavaDoc {
102         try {
103             outputStream.print(i);
104         } catch (IOException JavaDoc except) {
105             throw new HttpPresentationIOException(except);
106         }
107     }
108  
109     /**
110      * Prints the long provided.
111      * @exception IOException if an I/O error has occurred
112      */

113     public void print(long l) throws IOException JavaDoc {
114         try {
115             outputStream.print(l);
116         } catch (IOException JavaDoc except) {
117             throw new HttpPresentationIOException(except);
118         }
119     }
120
121     /**
122      * Prints the float provided.
123      * @exception IOException if an I/O error has occurred
124      */

125     public void print(float f) throws IOException JavaDoc {
126         try {
127             outputStream.print(f);
128         } catch (IOException JavaDoc except) {
129             throw new HttpPresentationIOException(except);
130         }
131     }
132
133     /**
134      * Prints the double provided.
135      * @exception IOException if an I/O error has occurred
136      */

137     public void print(double d) throws IOException JavaDoc {
138         try {
139             outputStream.print(d);
140         } catch (IOException JavaDoc except) {
141             throw new HttpPresentationIOException(except);
142         }
143     }
144
145     /**
146      * Prints a CRLF.
147      * @exception IOException if an I/O error has occurred
148      */

149     public void println() throws IOException JavaDoc {
150         try {
151             outputStream.println();
152         } catch (IOException JavaDoc except) {
153             throw new HttpPresentationIOException(except);
154         }
155     }
156
157     /**
158      * Prints the string provided, followed by a CRLF.
159      * @exception IOException if an I/O error has occurred
160      */

161     public void println(String JavaDoc s) throws IOException JavaDoc {
162         try {
163             outputStream.println(s);
164         } catch (IOException JavaDoc except) {
165             throw new HttpPresentationIOException(except);
166         }
167     }
168
169     /**
170      * Prints the boolean provided, followed by a CRLF.
171      * @exception IOException if an I/O error has occurred.
172      */

173     public void println(boolean b) throws IOException JavaDoc {
174         try {
175             outputStream.println(b);
176         } catch (IOException JavaDoc except) {
177             throw new HttpPresentationIOException(except);
178         }
179     }
180
181     /*
182      * Prints the character provided, followed by a CRLF.
183      * @exception IOException if an I/O error has occurred
184      */

185     public void println(char c) throws IOException JavaDoc {
186         try {
187             outputStream.println(c);
188         } catch (IOException JavaDoc except) {
189             throw new HttpPresentationIOException(except);
190         }
191     }
192
193     /**
194      * Prints the integer provided, followed by a CRLF.
195      * @exception IOException if an I/O error has occurred
196      */

197     public void println(int i) throws IOException JavaDoc {
198         try {
199             outputStream.println(i);
200         } catch (IOException JavaDoc except) {
201             throw new HttpPresentationIOException(except);
202         }
203     }
204
205     /**
206      * Prints the long provided, followed by a CRLF.
207      * @exception IOException if an I/O error has occurred
208      */

209     public void println(long l) throws IOException JavaDoc {
210         try {
211             outputStream.println(l);
212         } catch (IOException JavaDoc except) {
213             throw new HttpPresentationIOException(except);
214         }
215     }
216
217     /**
218      * Prints the float provided, followed by a CRLF.
219      * @exception IOException if an I/O error has occurred
220      */

221     public void println(float f) throws IOException JavaDoc {
222         try {
223             outputStream.println(f);
224         } catch (IOException JavaDoc except) {
225             throw new HttpPresentationIOException(except);
226         }
227     }
228
229     /**
230      * Prints the double provided, followed by a CRLF.
231      * @exception IOException if an I/O error has occurred
232      */

233     public void println(double d) throws IOException JavaDoc {
234         try {
235             outputStream.println(d);
236         } catch (IOException JavaDoc except) {
237             throw new HttpPresentationIOException(except);
238         }
239     }
240
241     /*
242      * OutputStream methods vectored off to the ServletOutputStream.
243      */

244     public void write(int b) throws IOException JavaDoc {
245         try {
246             outputStream.write(b);
247         } catch (IOException JavaDoc except) {
248             throw new HttpPresentationIOException(except);
249         }
250     }
251
252     public void write(byte b[]) throws IOException JavaDoc {
253         try {
254             outputStream.write(b);
255         } catch (IOException JavaDoc except) {
256             throw new HttpPresentationIOException(except);
257         }
258     }
259
260     public void write(byte b[], int off, int len) throws IOException JavaDoc {
261         try {
262             outputStream.write(b, off, len);
263         } catch (IOException JavaDoc except) {
264             throw new HttpPresentationIOException(except);
265         }
266     }
267
268     public void flush() throws IOException JavaDoc {
269         try {
270             outputStream.flush();
271         } catch (IOException JavaDoc except) {
272             throw new HttpPresentationIOException(except);
273         }
274     }
275
276     //FIX: Need MIME-write functions.
277
}
278
Popular Tags