01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.commons.io.output;
18:
19: import java.io.IOException;
20: import java.io.FilterWriter;
21: import java.io.Writer;
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: * @author Stephen Colebourne
32: * @version $Id: ProxyWriter.java 471628 2006-11-06 04:06:45Z bayard $
33: */
34: public class ProxyWriter extends FilterWriter {
35:
36: /**
37: * Constructs a new ProxyWriter.
38: *
39: * @param proxy the Writer to delegate to
40: */
41: public ProxyWriter(Writer proxy) {
42: super (proxy);
43: // the proxy is stored in a protected superclass variable named 'out'
44: }
45:
46: /** @see java.io.Writer#write(int) */
47: public void write(int idx) throws IOException {
48: out.write(idx);
49: }
50:
51: /** @see java.io.Writer#write(char[]) */
52: public void write(char[] chr) throws IOException {
53: out.write(chr);
54: }
55:
56: /** @see java.io.Writer#write(char[], int, int) */
57: public void write(char[] chr, int st, int end) throws IOException {
58: out.write(chr, st, end);
59: }
60:
61: /** @see java.io.Writer#write(String) */
62: public void write(String str) throws IOException {
63: out.write(str);
64: }
65:
66: /** @see java.io.Writer#write(String, int, int) */
67: public void write(String str, int st, int end) throws IOException {
68: out.write(str, st, end);
69: }
70:
71: /** @see java.io.Writer#flush() */
72: public void flush() throws IOException {
73: out.flush();
74: }
75:
76: /** @see java.io.Writer#close() */
77: public void close() throws IOException {
78: out.close();
79: }
80:
81: }
|