FSF GCC merge 02/23/03
[official-gcc.git] / libjava / java / io / FilterReader.java
blob3ccc83d9bc3e3b14db24a0cfcb10a62472cf7af1
1 /* FilterReader.java -- Base class for char stream classes that filter input
2 Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc.
4 This file is part of GNU Classpath.
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.
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.
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., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA.
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.
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. */
39 package java.io;
41 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
42 * "The Java Language Specification", ISBN 0-201-63451-1
43 * plus online API docs for JDK 1.2 beta from http://www.javasoft.com.
44 * Status: Believed complete and correct.
47 /**
48 * This is the common superclass of all standard classes that filter
49 * input. It acts as a layer on top of an underlying <code>Reader</code>
50 * and simply redirects calls made to it to the subordinate Reader
51 * instead. Subclasses of this class perform additional filtering
52 * functions in addition to simply redirecting the call.
53 * <p>
54 * When creating a subclass of <code>FilterReader</code>, override the
55 * appropriate methods to implement the desired filtering. However, note
56 * that the <code>read(char[])</code> method does not need to be overridden
57 * as this class redirects calls to that method to
58 * <code>read(yte[], int, int)</code> instead of to the subordinate
59 * <code>Reader} read(yte[])</code> method.
61 * @author Aaron M. Renn (arenn@urbanophile.com)
62 * @author Warren Levy <warrenl@cygnus.com>
64 public abstract class FilterReader extends Reader
67 /*************************************************************************/
70 * Instance Variables
73 /**
74 * This is the subordinate <code>Reader</code> to which method calls
75 * are redirected
77 protected Reader in;
79 /*************************************************************************/
82 * Constructors
85 /**
86 * Create a <code>FilterReader</code> with the specified subordinate
87 * <code>Reader</code>.
88 * The <code>lock</code> of the new <code>FilterReader</code> will be set
89 * to <code>in.lock</code>.
91 * @param in The subordinate <code>Reader</code>
93 protected
94 FilterReader(Reader in)
96 super(in.lock);
97 this.in = in;
100 /*************************************************************************/
103 * Instance Methods
107 * Calls the <code>in.mark(int)</code> method.
109 * @param readlimit The parameter passed to <code>in.mark(int)</code>
111 * @exception IOException If an error occurs
113 public void
114 mark(int readlimit) throws IOException
116 in.mark(readlimit);
119 /*************************************************************************/
122 * Calls the <code>in.markSupported()</code> method.
124 * @return <code>true</code> if mark/reset is supported, <code>false</code> otherwise
126 public boolean
127 markSupported()
129 return(in.markSupported());
132 /*************************************************************************/
135 * Calls the <code>in.reset()</code> method.
137 * @exception IOException If an error occurs
139 public void
140 reset() throws IOException
142 in.reset();
145 /*************************************************************************/
148 * Calls the <code>in.read()</code> method.
150 * @return The value returned from <code>in.available()</code>
152 * @exception IOException If an error occurs
154 public boolean
155 ready() throws IOException
157 return(in.ready());
160 /*************************************************************************/
163 * Calls the <code>in.skip(long)</code> method
165 * @param The requested number of chars to skip.
167 * @return The value returned from <code>in.skip(long)</code>
169 * @exception IOException If an error occurs
171 public long
172 skip(long num_chars) throws IOException
174 return(in.skip(num_chars));
177 /*************************************************************************/
180 * Calls the <code>in.read()</code> method
182 * @return The value returned from <code>in.read()</code>
184 * @exception IOException If an error occurs
186 public int
187 read() throws IOException
189 return(in.read());
192 /*************************************************************************/
195 * Calls the <code>in.read(char[], int, int)</code> method.
197 * @param buf The buffer to read chars into
198 * @param offset The index into the buffer to start storing chars
199 * @param len The maximum number of chars to read.
201 * @return The value retured from <code>in.read(char[], int, int)</code>
203 * @exception IOException If an error occurs
205 public int
206 read(char[] buf, int offset, int len) throws IOException
208 return(in.read(buf, offset, len));
211 /*************************************************************************/
214 * This method closes the stream by calling the <code>close()</code> method
215 * of the underlying stream.
217 * @exception IOException If an error occurs
219 public void
220 close() throws IOException
222 in.close();
225 } // class FilterReader