View Javadoc

1   /**
2    *  Copyright 2003-2007 Greg Luck
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  
17  package net.sf.ehcache.constructs.web.filter;
18  
19  import javax.servlet.ServletOutputStream;
20  import java.io.IOException;
21  import java.io.OutputStream;
22  
23  /**
24   * A custom {@link javax.servlet.ServletOutputStream} for use by our filters
25   *
26   * @version $Id: FilterServletOutputStream.java 512 2007-07-10 09:18:45Z gregluck $
27   * @author <a href="mailto:gluck@thoughtworks.com">Greg Luck</a>
28   */
29  public class FilterServletOutputStream extends ServletOutputStream {
30  
31      private OutputStream stream;
32  
33      /**
34       * Creates a FilterServletOutputStream.
35       */
36      public FilterServletOutputStream(final OutputStream stream) {
37          this.stream = stream;
38      }
39  
40      /**
41       * Writes to the stream.
42       */
43      public void write(final int b) throws IOException {
44          stream.write(b);
45      }
46  
47      /**
48       * Writes to the stream.
49       */
50      public void write(final byte[] b) throws IOException {
51          stream.write(b);
52      }
53  
54      /**
55       * Writes to the stream.
56       */
57      public void write(final byte[] b, final int off, final int len) throws IOException {
58          stream.write(b, off, len);
59      }
60  }
61