changes: now Inference engine works fine with the EyeTracking benchmark.
[IRC.git] / Robust / src / ClassLibrary / SSJavaInfer / FilterInputStream.java
1 /* FilterInputStream.java -- Base class for classes that filter input
2    Copyright (C) 1998, 1999, 2001, 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  * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
43  * Status:  Believed complete and correct.
44  */
45
46 /**
47  * This is the common superclass of all standard classes that filter input. It
48  * acts as a layer on top of an underlying <code>InputStream</code> and simply
49  * redirects calls made to it to the subordinate InputStream instead. Subclasses
50  * of this class perform additional filtering functions in addition to simply
51  * redirecting the call.
52  * <p>
53  * This class is not abstract. However, since it only redirects calls to a
54  * subordinate <code>InputStream</code> without adding any functionality on top
55  * of it, this class should not be used directly. Instead, various subclasses of
56  * this class should be used. This is enforced with a protected constructor. Do
57  * not try to hack around it.
58  * <p>
59  * When creating a subclass of <code>FilterInputStream</code>, override the
60  * appropriate methods to implement the desired filtering. However, note that
61  * the <code>read(byte[])</code> method does not need to be overridden as this
62  * class redirects calls to that method to <code>read(byte[], int, int)</code>
63  * instead of to the subordinate <code>InputStream read(byte[])</code> method.
64  * 
65  * @author Aaron M. Renn (arenn@urbanophile.com)
66  * @author Warren Levy (warrenl@cygnus.com)
67  */
68
69 public class FilterInputStream extends InputStream {
70   /**
71    * This is the subordinate <code>InputStream</code> to which method calls are
72    * redirected
73    */
74   protected InputStream in;
75
76   /**
77    * Create a <code>FilterInputStream</code> with the specified subordinate
78    * <code>InputStream</code>.
79    * 
80    * @param in
81    *          The subordinate <code>InputStream</code>
82    */
83   protected FilterInputStream(InputStream in) {
84     this.in = in;
85   }
86
87   /**
88    * Calls the <code>in.mark(int)</code> method.
89    * 
90    * @param readlimit
91    *          The parameter passed to <code>in.mark(int)</code>
92    */
93   public void mark(int readlimit) {
94     in.mark(readlimit);
95   }
96
97   /**
98    * Calls the <code>in.markSupported()</code> method.
99    * 
100    * @return <code>true</code> if mark/reset is supported, <code>false</code>
101    *         otherwise
102    */
103
104   public boolean markSupported() {
105     return in.markSupported();
106   }
107
108   /**
109    * Calls the <code>in.reset()</code> method.
110    * 
111    * @exception IOException
112    *              If an error occurs
113    */
114   public void reset() throws IOException {
115     in.reset();
116   }
117
118   /**
119    * Calls the <code>in.available()</code> method.
120    * 
121    * @return The value returned from <code>in.available()</code>
122    * 
123    * @exception IOException
124    *              If an error occurs
125    */
126   public int available() throws IOException {
127     return in.available();
128   }
129
130   /**
131    * Calls the <code>in.skip(long)</code> method
132    * 
133    * @param numBytes
134    *          The requested number of bytes to skip.
135    * 
136    * @return The value returned from <code>in.skip(long)</code>
137    * 
138    * @exception IOException
139    *              If an error occurs
140    */
141
142   public long skip(long numBytes) throws IOException {
143     return in.skip(numBytes);
144   }
145
146   /**
147    * Calls the <code>in.read()</code> method
148    * 
149    * @return The value returned from <code>in.read()</code>
150    * 
151    * @exception IOException
152    *              If an error occurs
153    */
154
155   public int read() throws IOException {
156     return in.read();
157   }
158
159   /**
160    * Calls the <code>read(byte[], int, int)</code> overloaded method. Note that
161    * this method does not redirect its call directly to a corresponding method
162    * in <code>in</code>. This allows subclasses to override only the three
163    * argument version of <code>read</code>.
164    * 
165    * @param buf
166    *          The buffer to read bytes into
167    * 
168    * @return The value retured from <code>in.read(byte[], int, int)</code>
169    * 
170    * @exception IOException
171    *              If an error occurs
172    */
173
174   public int read(byte[] buf) throws IOException {
175     return read(buf, 0, buf.length);
176   }
177
178   /**
179    * Calls the <code>in.read(byte[], int, int)</code> method.
180    * 
181    * @param buf
182    *          The buffer to read bytes into
183    * @param offset
184    *          The index into the buffer to start storing bytes
185    * @param len
186    *          The maximum number of bytes to read.
187    * 
188    * @return The value retured from <code>in.read(byte[], int, int)</code>
189    * 
190    * @exception IOException
191    *              If an error occurs
192    */
193
194   public int read(byte[] buf, int offset, int len) throws IOException {
195     return in.read(buf, offset, len);
196   }
197
198   /**
199    * This method closes the input stream by closing the input stream that this
200    * object is filtering. Future attempts to access this stream may throw an
201    * exception.
202    * 
203    * @exception IOException
204    *              If an error occurs
205    */
206
207   public void close() throws IOException {
208     in.close();
209   }
210 }