001: /*
002: * Enhydra Java Application Server Project
003: *
004: * The contents of this file are subject to the Enhydra Public License
005: * Version 1.1 (the "License"); you may not use this file except in
006: * compliance with the License. You may obtain a copy of the License on
007: * the Enhydra web site ( http://www.enhydra.org/ ).
008: *
009: * Software distributed under the License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011: * the License for the specific terms governing rights and limitations
012: * under the License.
013: *
014: * The Initial Developer of the Enhydra Application Server is Lutris
015: * Technologies, Inc. The Enhydra Application Server and portions created
016: * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017: * All Rights Reserved.
018: *
019: * Contributor(s):
020: *
021: * $Id: ServletHttpPresentationOutputStream.java,v 1.3 2007-10-19 10:05:39 sinisa Exp $
022: */
023:
024: package com.lutris.appserver.server.httpPresentation.servlet;
025:
026: import java.io.IOException;
027:
028: import javax.servlet.ServletOutputStream;
029:
030: import com.lutris.appserver.server.httpPresentation.HttpPresentationIOException;
031: import com.lutris.appserver.server.httpPresentation.HttpPresentationOutputStream;
032:
033: /**
034: * HTTP request output stream writter for servlets.
035: * This implements all methods that are defined in OutputStream as calles
036: * to the servlet object, since we don't know which ones are implemented by
037: * ServletOutputStream.
038: *
039: * @see javax.servlet.ServletOutputStream
040: */
041: public class ServletHttpPresentationOutputStream extends
042: HttpPresentationOutputStream {
043:
044: // private ServletHttpPresentationResponse response;
045: private ServletOutputStream outputStream;
046:
047: /**
048: * Construct an object for accessing a servlet output stream.
049: */
050: protected ServletHttpPresentationOutputStream(
051: ServletHttpPresentationResponse response,
052: ServletOutputStream outputStream) {
053: // this.response = response;
054: this .outputStream = outputStream;
055: }
056:
057: /**
058: * Prints the string provided.
059: * @exception IOException if an I/O error has occurred
060: */
061: public void print(String s) throws IOException {
062: try {
063: outputStream.print(s);
064: } catch (IOException except) {
065: throw new HttpPresentationIOException(except);
066: }
067: }
068:
069: /**
070: * Prints the boolean provided.
071: * @exception IOException if an I/O error has occurred.
072: */
073: public void print(boolean b) throws IOException {
074: try {
075: outputStream.print(b);
076: } catch (IOException except) {
077: throw new HttpPresentationIOException(except);
078: }
079: }
080:
081: /*
082: * Prints the character provided.
083: * @exception IOException if an I/O error has occurred
084: */
085: public void print(char c) throws IOException {
086: try {
087: outputStream.print(c);
088: } catch (IOException except) {
089: throw new HttpPresentationIOException(except);
090: }
091: }
092:
093: /**
094: * Prints the integer provided.
095: * @exception IOException if an I/O error has occurred
096: */
097: public void print(int i) throws IOException {
098: try {
099: outputStream.print(i);
100: } catch (IOException except) {
101: throw new HttpPresentationIOException(except);
102: }
103: }
104:
105: /**
106: * Prints the long provided.
107: * @exception IOException if an I/O error has occurred
108: */
109: public void print(long l) throws IOException {
110: try {
111: outputStream.print(l);
112: } catch (IOException except) {
113: throw new HttpPresentationIOException(except);
114: }
115: }
116:
117: /**
118: * Prints the float provided.
119: * @exception IOException if an I/O error has occurred
120: */
121: public void print(float f) throws IOException {
122: try {
123: outputStream.print(f);
124: } catch (IOException except) {
125: throw new HttpPresentationIOException(except);
126: }
127: }
128:
129: /**
130: * Prints the double provided.
131: * @exception IOException if an I/O error has occurred
132: */
133: public void print(double d) throws IOException {
134: try {
135: outputStream.print(d);
136: } catch (IOException except) {
137: throw new HttpPresentationIOException(except);
138: }
139: }
140:
141: /**
142: * Prints a CRLF.
143: * @exception IOException if an I/O error has occurred
144: */
145: public void println() throws IOException {
146: try {
147: outputStream.println();
148: } catch (IOException except) {
149: throw new HttpPresentationIOException(except);
150: }
151: }
152:
153: /**
154: * Prints the string provided, followed by a CRLF.
155: * @exception IOException if an I/O error has occurred
156: */
157: public void println(String s) throws IOException {
158: try {
159: outputStream.println(s);
160: } catch (IOException except) {
161: throw new HttpPresentationIOException(except);
162: }
163: }
164:
165: /**
166: * Prints the boolean provided, followed by a CRLF.
167: * @exception IOException if an I/O error has occurred.
168: */
169: public void println(boolean b) throws IOException {
170: try {
171: outputStream.println(b);
172: } catch (IOException except) {
173: throw new HttpPresentationIOException(except);
174: }
175: }
176:
177: /*
178: * Prints the character provided, followed by a CRLF.
179: * @exception IOException if an I/O error has occurred
180: */
181: public void println(char c) throws IOException {
182: try {
183: outputStream.println(c);
184: } catch (IOException except) {
185: throw new HttpPresentationIOException(except);
186: }
187: }
188:
189: /**
190: * Prints the integer provided, followed by a CRLF.
191: * @exception IOException if an I/O error has occurred
192: */
193: public void println(int i) throws IOException {
194: try {
195: outputStream.println(i);
196: } catch (IOException except) {
197: throw new HttpPresentationIOException(except);
198: }
199: }
200:
201: /**
202: * Prints the long provided, followed by a CRLF.
203: * @exception IOException if an I/O error has occurred
204: */
205: public void println(long l) throws IOException {
206: try {
207: outputStream.println(l);
208: } catch (IOException except) {
209: throw new HttpPresentationIOException(except);
210: }
211: }
212:
213: /**
214: * Prints the float provided, followed by a CRLF.
215: * @exception IOException if an I/O error has occurred
216: */
217: public void println(float f) throws IOException {
218: try {
219: outputStream.println(f);
220: } catch (IOException except) {
221: throw new HttpPresentationIOException(except);
222: }
223: }
224:
225: /**
226: * Prints the double provided, followed by a CRLF.
227: * @exception IOException if an I/O error has occurred
228: */
229: public void println(double d) throws IOException {
230: try {
231: outputStream.println(d);
232: } catch (IOException except) {
233: throw new HttpPresentationIOException(except);
234: }
235: }
236:
237: /*
238: * OutputStream methods vectored off to the ServletOutputStream.
239: */
240: public void write(int b) throws IOException {
241: try {
242: outputStream.write(b);
243: } catch (IOException except) {
244: throw new HttpPresentationIOException(except);
245: }
246: }
247:
248: public void write(byte b[]) throws IOException {
249: try {
250: outputStream.write(b);
251: } catch (IOException except) {
252: throw new HttpPresentationIOException(except);
253: }
254: }
255:
256: public void write(byte b[], int off, int len) throws IOException {
257: try {
258: outputStream.write(b, off, len);
259: } catch (IOException except) {
260: throw new HttpPresentationIOException(except);
261: }
262: }
263:
264: public void flush() throws IOException {
265: try {
266: outputStream.flush();
267: } catch (IOException except) {
268: throw new HttpPresentationIOException(except);
269: }
270: }
271:
272: //FIX: Need MIME-write functions.
273: }
|