Merge from mainline (gomp-merge-2005-02-26).
[official-gcc.git] / libjava / java / io / FilterWriter.java
blob5a8ede572dbfa5dc7651b4f1782b9391622bb914
1 /* FilterWriter.java -- Parent class for output streams that filter
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 * Status: Complete to version 1.1.
46 /**
47 * This class is the common superclass of output character stream classes
48 * that filter the output they write. These classes typically transform the
49 * data in some way prior to writing it out to another underlying
50 * <code>Writer</code>. This class simply overrides all the
51 * methods in <code>Writer</code> to redirect them to the
52 * underlying stream. Subclasses provide actual filtering.
54 * @author Aaron M. Renn (arenn@urbanophile.com)
55 * @author Tom Tromey (tromey@cygnus.com)
57 public abstract class FilterWriter extends Writer
59 /**
60 * This is the subordinate <code>Writer</code> that this class
61 * redirects its method calls to.
63 protected Writer out;
65 /**
66 * This method initializes an instance of <code>FilterWriter</code>
67 * to write to the specified subordinate <code>Writer</code>.
68 * The given <code>Writer</code> will be used as <code>lock</code> for
69 * the newly created <code>FilterWriter</code>.
71 * @param out The <code>Writer</code> to write to
73 protected FilterWriter(Writer out)
75 super(out.lock);
76 this.out = out;
79 /**
80 * This method closes the underlying <code>Writer</code>. Any
81 * further attempts to write to this stream may throw an exception.
83 * @exception IOException If an error occurs
85 public void close() throws IOException
87 out.close();
90 /**
91 * This method attempt to flush all buffered output to be written to the
92 * underlying output sink.
94 * @exception IOException If an error occurs
96 public void flush() throws IOException
98 out.flush();
102 * This method writes a single char of output to the underlying
103 * <code>Writer</code>.
105 * @param b The char to write, passed as an int.
107 * @exception IOException If an error occurs
109 public void write(int b) throws IOException
111 out.write(b);
115 * This method writes <code>len</code> chars from the array <code>buf</code>
116 * starting at index <code>offset</code> to the underlying
117 * <code>Writer</code>.
119 * @param buf The char array to write chars from
120 * @param offset The index into the array to start writing chars from
121 * @param len The number of chars to write
123 * @exception IOException If an error occurs
125 public void write(char[] buf, int offset, int len) throws IOException
127 out.write(buf, offset, len);
131 * This method writes <code>len</code> chars from the <code>String</code>
132 * starting at position <code>offset</code>.
134 * @param str The <code>String</code> that is to be written
135 * @param offset The character offset into the <code>String</code>
136 * to start writing from
137 * @param len The number of chars to write
139 * @exception IOException If an error occurs
141 public void write(String str, int offset, int len) throws IOException
143 out.write(str, offset, len);
146 } // class FilterWriter