KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > io > output > ProxyWriter


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.commons.io.output;
17
18 import java.io.IOException JavaDoc;
19 import java.io.FilterWriter JavaDoc;
20 import java.io.Writer JavaDoc;
21
22 /**
23  *
24  * A Proxy stream which acts as expected, that is it passes the method
25  * calls on to the proxied stream and doesn't change which methods are
26  * being called. It is an alternative base class to FilterWriter
27  * to increase reusability, because FilterWriter changes the
28  * methods being called, such as write(char[]) to write(char[], int, int)
29  * and write(String) to write(String, int, int).
30  */

31 public class ProxyWriter extends FilterWriter JavaDoc {
32
33     private Writer JavaDoc proxy;
34
35     /**
36      * Constructs a new ProxyWriter.
37      * @param proxy Writer to delegate to
38      */

39     public ProxyWriter(Writer JavaDoc proxy) {
40         super(proxy);
41         this.proxy = proxy;
42     }
43
44     /** @see java.io.Writer#write(int) */
45     public void write(int idx) throws IOException JavaDoc {
46         this.proxy.write(idx);
47     }
48
49     /** @see java.io.Writer#write(char[]) */
50     public void write(char[] chr) throws IOException JavaDoc {
51         this.proxy.write(chr);
52     }
53
54     /** @see java.io.Writer#write(char[], int, int) */
55     public void write(char[] chr, int st, int end) throws IOException JavaDoc {
56         this.proxy.write(chr, st, end);
57     }
58
59     /** @see java.io.Writer#write(String) */
60     public void write(String JavaDoc str) throws IOException JavaDoc {
61         this.proxy.write(str);
62     }
63
64     /** @see java.io.Writer#write(String, int, int) */
65     public void write(String JavaDoc str, int st, int end) throws IOException JavaDoc {
66         this.proxy.write(str, st, end);
67     }
68
69     /** @see java.io.Writer#flush() */
70     public void flush() throws IOException JavaDoc {
71         this.proxy.flush();
72     }
73
74     /** @see java.io.Writer#close() */
75     public void close() throws IOException JavaDoc {
76         this.proxy.close();
77     }
78
79 }
80
Popular Tags