1 /**
2 * Licensed under the Artistic License; you may not use this file
3 * except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://displaytag.sourceforge.net/license.html
7 *
8 * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
9 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
10 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11 */
12 package org.displaytag.filter;
13
14 import java.io.ByteArrayOutputStream;
15
16 import javax.servlet.ServletOutputStream;
17
18
19 /**
20 * A simple implementation of ServletOutputStream which wraps a ByteArrayOutputStream.
21 * @author Fabrizio Giustina
22 * @version $Revision: 1081 $ ($Author: fgiust $)
23 */
24 public class SimpleServletOutputStream extends ServletOutputStream
25 {
26
27 /**
28 * My outputWriter stream, a buffer.
29 */
30 ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
31
32 /**
33 * {@inheritDoc}
34 */
35 public void write(int b)
36 {
37 this.outputStream.write(b);
38 }
39
40 /**
41 * Get the contents of the outputStream.
42 * @return contents of the outputStream
43 */
44 public String toString()
45 {
46 return this.outputStream.toString();
47 }
48
49 /**
50 * Reset the wrapped ByteArrayOutputStream.
51 */
52 public void reset()
53 {
54 outputStream.reset();
55 }
56 }