reformat benchmark source codes to meet the requirements of the annotation generation.
[IRC.git] / Robust / src / ClassLibrary / SSJavaInfer / FilterOutputStream.java
1 /* FilterOutputStream.java -- Parent class for output streams that filter
2    Copyright (C) 1998, 1999, 2001, 2003, 2005  Free Software Foundation, Inc.
3
4 This file is part of GNU Classpath.
5
6 GNU Classpath is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
10  
11 GNU Classpath is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with GNU Classpath; see the file COPYING.  If not, write to the
18 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 02110-1301 USA.
20
21 Linking this library statically or dynamically with other modules is
22 making a combined work based on this library.  Thus, the terms and
23 conditions of the GNU General Public License cover the whole
24 combination.
25
26 As a special exception, the copyright holders of this library give you
27 permission to link this library with independent modules to produce an
28 executable, regardless of the license terms of these independent
29 modules, and to copy and distribute the resulting executable under
30 terms of your choice, provided that you also meet, for each linked
31 independent module, the terms and conditions of the license of that
32 module.  An independent module is a module which is not derived from
33 or based on this library.  If you modify this library, you may extend
34 this exception to your version of the library, but you are not
35 obligated to do so.  If you do not wish to do so, delete this
36 exception statement from your version. */
37
38 //package java.io;
39
40 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
41  * "The Java Language Specification", ISBN 0-201-63451-1
42  * Status:  Complete to version 1.1.
43  */
44
45 /**
46  * This class is the common superclass of output stream classes that filter the
47  * output they write. These classes typically transform the data in some way
48  * prior to writing it out to another underlying <code>OutputStream</code>. This
49  * class simply overrides all the methods in <code>OutputStream</code> to
50  * redirect them to the underlying stream. Subclasses provide actual filtering.
51  * 
52  * @author Aaron M. Renn (arenn@urbanophile.com)
53  * @author Tom Tromey (tromey@cygnus.com)
54  */
55 public class FilterOutputStream extends OutputStream {
56   /**
57    * This is the subordinate <code>OutputStream</code> that this class redirects
58    * its method calls to.
59    */
60   protected OutputStream out;
61
62   /**
63    * This method initializes an instance of <code>FilterOutputStream</code> to
64    * write to the specified subordinate <code>OutputStream</code>.
65    * 
66    * @param out
67    *          The <code>OutputStream</code> to write to
68    */
69   public FilterOutputStream(OutputStream out) {
70     this.out = out;
71   }
72
73   /**
74    * This method closes the underlying <code>OutputStream</code>. Any further
75    * attempts to write to this stream may throw an exception.
76    * 
77    * @exception IOException
78    *              If an error occurs
79    */
80   public void close() // throws IOException
81   {
82     flush();
83     out.close();
84   }
85
86   /**
87    * This method attempt to flush all buffered output to be written to the
88    * underlying output sink.
89    * 
90    * @exception IOException
91    *              If an error occurs
92    */
93   public void flush() // throws IOException
94   {
95     out.flush();
96   }
97
98   /**
99    * This method writes a single byte of output to the underlying
100    * <code>OutputStream</code>.
101    * 
102    * @param b
103    *          The byte to write, passed as an int.
104    * 
105    * @exception IOException
106    *              If an error occurs
107    */
108   public void write(int b) // throws IOException
109   {
110     out.write(b);
111   }
112
113   /**
114    * This method writes all the bytes in the specified array to the underlying
115    * <code>OutputStream</code>. It does this by calling the three parameter
116    * version of this method - <code>write(byte[], int, int)</code> in this class
117    * instead of writing to the underlying <code>OutputStream</code> directly.
118    * This allows most subclasses to avoid overriding this method.
119    * 
120    * @param buf
121    *          The byte array to write bytes from
122    * 
123    * @exception IOException
124    *              If an error occurs
125    */
126   public void write(byte[] buf) // throws IOException
127   {
128     // Don't do checking here, per Java Lang Spec.
129     write(buf, 0, buf.length);
130   }
131
132   /**
133    * This method calls the <code>write(int)</code> method <code>len</code> times
134    * for all bytes from the array <code>buf</code> starting at index
135    * <code>offset</code>. Subclasses should overwrite this method to get a more
136    * efficient implementation.
137    * 
138    * @param buf
139    *          The byte array to write bytes from
140    * @param offset
141    *          The index into the array to start writing bytes from
142    * @param len
143    *          The number of bytes to write
144    * 
145    * @exception IOException
146    *              If an error occurs
147    */
148   public void write(byte[] buf, int offset, int len) // throws IOException
149   {
150     // Don't do checking here, per Java Lang Spec.
151     for (int i = 0; i < len; i++)
152       write(buf[offset + i]);
153
154   }
155
156 } // class FilterOutputStream
157