Merge from the pain train
[official-gcc.git] / libjava / java / io / FilterReader.java
blob4cc6940c51827d4a8fe9da2d0d32e2cb41a44964
1 /* FilterReader.java -- Base class for char stream classes that filter input
2 Copyright (C) 1998, 1999, 2001, 2003, 2005 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
66 /**
67 * This is the subordinate <code>Reader</code> to which method calls
68 * are redirected
70 protected Reader in;
72 /**
73 * Create a <code>FilterReader</code> with the specified subordinate
74 * <code>Reader</code>.
75 * The <code>lock</code> of the new <code>FilterReader</code> will be set
76 * to <code>in.lock</code>.
78 * @param in The subordinate <code>Reader</code>
80 protected FilterReader(Reader in)
82 super(in.lock);
83 this.in = in;
86 /**
87 * Calls the <code>in.mark(int)</code> method.
89 * @param readlimit The parameter passed to <code>in.mark(int)</code>
91 * @exception IOException If an error occurs
93 public void mark(int readlimit) throws IOException
95 in.mark(readlimit);
98 /**
99 * Calls the <code>in.markSupported()</code> method.
101 * @return <code>true</code> if mark/reset is supported,
102 * <code>false</code> otherwise
104 public boolean markSupported()
106 return(in.markSupported());
110 * Calls the <code>in.reset()</code> method.
112 * @exception IOException If an error occurs
114 public void reset() throws IOException
116 in.reset();
120 * Calls the <code>in.read()</code> method.
122 * @return The value returned from <code>in.available()</code>
124 * @exception IOException If an error occurs
126 public boolean ready() throws IOException
128 return(in.ready());
132 * Calls the <code>in.skip(long)</code> method
134 * @param numBytes The requested number of chars to skip.
136 * @return The value returned from <code>in.skip(long)</code>
138 * @exception IOException If an error occurs
140 public long skip(long num_chars) throws IOException
142 return(in.skip(num_chars));
146 * Calls the <code>in.read()</code> method
148 * @return The value returned from <code>in.read()</code>
150 * @exception IOException If an error occurs
152 public int read() throws IOException
154 return(in.read());
158 * Calls the <code>in.read(char[], int, int)</code> method.
160 * @param buf The buffer to read chars into
161 * @param offset The index into the buffer to start storing chars
162 * @param len The maximum number of chars to read.
164 * @return The value retured from <code>in.read(char[], int, int)</code>
166 * @exception IOException If an error occurs
168 public int read(char[] buf, int offset, int len) throws IOException
170 return(in.read(buf, offset, len));
174 * This method closes the stream by calling the <code>close()</code> method
175 * of the underlying stream.
177 * @exception IOException If an error occurs
179 public void close() throws IOException
181 in.close();
184 } // class FilterReader