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

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Arnaud Vandyck
  • Date: 2007-04-13 08:20:49 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070413082049-2hd3s5ixtxsgvnvm
Tags: 1.3.1.dfsg.1-1
* New upstream (closes: #418973)
* java-gcj-compat-dev and cdbs transition
* Removed junit at the moment (closes: #397567)
* No javadoc at the moment

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
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
 
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
 
3
 * contributor license agreements.  See the NOTICE file distributed with
 
4
 * this work for additional information regarding copyright ownership.
 
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
 
6
 * (the "License"); you may not use this file except in compliance with
 
7
 * the License.  You may obtain a copy of the License at
7
8
 * 
8
9
 *      http://www.apache.org/licenses/LICENSE-2.0
9
10
 * 
20
21
import java.io.OutputStream;
21
22
 
22
23
/**
23
 
 * 
24
24
 * A Proxy stream which acts as expected, that is it passes the method 
25
25
 * calls on to the proxied stream and doesn't change which methods are 
26
26
 * being called. It is an alternative base class to FilterOutputStream
27
27
 * to increase reusability.
 
28
 * 
 
29
 * @author Stephen Colebourne
 
30
 * @version $Id: ProxyOutputStream.java 471628 2006-11-06 04:06:45Z bayard $
28
31
 */
29
32
public class ProxyOutputStream extends FilterOutputStream {
30
33
 
31
 
    private OutputStream proxy;
32
 
 
33
34
    /**
34
35
     * Constructs a new ProxyOutputStream.
35
 
     * @param proxy OutputStream to delegate to
 
36
     * 
 
37
     * @param proxy  the OutputStream to delegate to
36
38
     */
37
39
    public ProxyOutputStream(OutputStream proxy) {
38
40
        super(proxy);
39
 
        this.proxy = proxy;
 
41
        // the proxy is stored in a protected superclass variable named 'out'
40
42
    }
41
43
 
42
44
    /** @see java.io.OutputStream#write(int) */
43
45
    public void write(int idx) throws IOException {
44
 
        this.proxy.write(idx);
 
46
        out.write(idx);
45
47
    }
46
48
 
47
49
    /** @see java.io.OutputStream#write(byte[]) */
48
50
    public void write(byte[] bts) throws IOException {
49
 
        this.proxy.write(bts);
 
51
        out.write(bts);
50
52
    }
51
53
 
52
54
    /** @see java.io.OutputStream#write(byte[], int, int) */
53
55
    public void write(byte[] bts, int st, int end) throws IOException {
54
 
        this.proxy.write(bts, st, end);
 
56
        out.write(bts, st, end);
55
57
    }
56
58
 
57
59
    /** @see java.io.OutputStream#flush() */
58
60
    public void flush() throws IOException {
59
 
        this.proxy.flush();
 
61
        out.flush();
60
62
    }
61
63
 
62
64
    /** @see java.io.OutputStream#close() */
63
65
    public void close() throws IOException {
64
 
        this.proxy.close();
 
66
        out.close();
65
67
    }
66
68
 
67
69
}