~ubuntu-branches/ubuntu/karmic/commons-io/karmic

« back to all changes in this revision

Viewing changes to src/java/org/apache/commons/io/output/ProxyWriter.java

  • Committer: Bazaar Package Importer
  • Author(s): Wolfgang Baer
  • Date: 2005-10-16 13:44:21 UTC
  • Revision ID: james.westby@ubuntu.com-20051016134421-v2gfddy6iovz449t
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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;
 
19
import java.io.FilterWriter;
 
20
import java.io.Writer;
 
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 {
 
32
 
 
33
    private Writer proxy;
 
34
 
 
35
    /**
 
36
     * Constructs a new ProxyWriter.
 
37
     * @param proxy Writer to delegate to
 
38
     */
 
39
    public ProxyWriter(Writer 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 {
 
46
        this.proxy.write(idx);
 
47
    }
 
48
 
 
49
    /** @see java.io.Writer#write(char[]) */
 
50
    public void write(char[] chr) throws IOException {
 
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 {
 
56
        this.proxy.write(chr, st, end);
 
57
    }
 
58
 
 
59
    /** @see java.io.Writer#write(String) */
 
60
    public void write(String str) throws IOException {
 
61
        this.proxy.write(str);
 
62
    }
 
63
 
 
64
    /** @see java.io.Writer#write(String, int, int) */
 
65
    public void write(String str, int st, int end) throws IOException {
 
66
        this.proxy.write(str, st, end);
 
67
    }
 
68
 
 
69
    /** @see java.io.Writer#flush() */
 
70
    public void flush() throws IOException {
 
71
        this.proxy.flush();
 
72
    }
 
73
 
 
74
    /** @see java.io.Writer#close() */
 
75
    public void close() throws IOException {
 
76
        this.proxy.close();
 
77
    }
 
78
 
 
79
}