commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject svn commit: r154556 - in jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io: input/ProxyInputStream.java input/ProxyReader.java output/ProxyOutputStream.java output/ProxyWriter.java
Date Sun, 20 Feb 2005 18:33:41 GMT
Author: scolebourne
Date: Sun Feb 20 10:33:39 2005
New Revision: 154556

URL: http://svn.apache.org/viewcvs?view=rev&rev=154556
Log:
Optimize implementation by using the superclass instance variable
bug 28977, from Lars Beuster

Modified:
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyInputStream.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyReader.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyOutputStream.java
    jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyWriter.java

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyInputStream.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyInputStream.java?view=diff&r1=154555&r2=154556
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyInputStream.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyInputStream.java
Sun Feb 20 10:33:39 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2004 The Apache Software Foundation.
+ * Copyright 2002-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,67 +23,70 @@
  * A Proxy stream which acts as expected, that is it passes the method 
  * calls on to the proxied stream and doesn't change which methods are 
  * being called. 
- * 
+ * <p>
  * It is an alternative base class to FilterInputStream
  * to increase reusability, because FilterInputStream changes the 
  * methods being called, such as read(byte[]) to read(byte[], int, int).
+ * 
+ * @author Henri Yandell
+ * @author Stephen Colebourne
+ * @version $Id$
  */
 public abstract class ProxyInputStream extends FilterInputStream {
 
-    private InputStream proxy;
-
     /**
      * Constructs a new ProxyInputStream.
-     * @param proxy InputStream to delegate to
+     * 
+     * @param proxy  the InputStream to delegate to
      */
     public ProxyInputStream(InputStream proxy) {
         super(proxy);
-        this.proxy = proxy;
+        // the proxy is stored in a protected superclass variable named 'in'
     }
 
     /** @see java.io.InputStream#read() */
     public int read() throws IOException {
-        return this.proxy.read();
+        return in.read();
     }
 
     /** @see java.io.InputStream#read(byte[]) */
     public int read(byte[] bts) throws IOException {
-        return this.proxy.read(bts);
+        return in.read(bts);
     }
 
     /** @see java.io.InputStream#read(byte[], int, int) */
     public int read(byte[] bts, int st, int end) throws IOException {
-        return this.proxy.read(bts, st, end);
+        return in.read(bts, st, end);
     }
 
     /** @see java.io.InputStream#skip(long) */
     public long skip(long ln) throws IOException {
-        return this.proxy.skip(ln);
+        return in.skip(ln);
     }
 
     /** @see java.io.InputStream#available() */
     public int available() throws IOException {
-        return this.proxy.available();
+        return in.available();
     }
 
     /** @see java.io.InputStream#close() */
     public void close() throws IOException {
-        this.proxy.close();
+        in.close();
     }
 
     /** @see java.io.InputStream#mark(int) */
     public synchronized void mark(int idx) {
-        this.proxy.mark(idx);
+        in.mark(idx);
     }
 
     /** @see java.io.InputStream#reset() */
     public synchronized void reset() throws IOException {
-        this.proxy.reset();
+        in.reset();
     }
 
     /** @see java.io.InputStream#markSupported() */
     public boolean markSupported() {
-        return this.proxy.markSupported();
+        return in.markSupported();
     }
 
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyReader.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyReader.java?view=diff&r1=154555&r2=154556
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyReader.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/input/ProxyReader.java
Sun Feb 20 10:33:39 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2004 The Apache Software Foundation.
+ * Copyright 2002-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,67 +23,70 @@
  * A Proxy stream which acts as expected, that is it passes the method 
  * calls on to the proxied stream and doesn't change which methods are 
  * being called. 
- * 
+ * <p>
  * It is an alternative base class to FilterReader
  * to increase reusability, because FilterReader changes the 
  * methods being called, such as read(char[]) to read(char[], int, int).
+ * 
+ * @author Henri Yandell
+ * @author Stephen Colebourne
+ * @version $Id$
  */
 public abstract class ProxyReader extends FilterReader {
 
-    private Reader proxy;
-
     /**
      * Constructs a new ProxyReader.
-     * @param proxy Reader to delegate to
+     * 
+     * @param proxy  the Reader to delegate to
      */
     public ProxyReader(Reader proxy) {
         super(proxy);
-        this.proxy = proxy;
+        // the proxy is stored in a protected superclass variable named 'in'
     }
 
     /** @see java.io.Reader#read() */
     public int read() throws IOException {
-        return this.proxy.read();
+        return in.read();
     }
 
     /** @see java.io.Reader#read(char[]) */
     public int read(char[] chr) throws IOException {
-        return this.proxy.read(chr);
+        return in.read(chr);
     }
 
     /** @see java.io.Reader#read(char[], int, int) */
     public int read(char[] chr, int st, int end) throws IOException {
-        return this.proxy.read(chr, st, end);
+        return in.read(chr, st, end);
     }
 
     /** @see java.io.Reader#skip(long) */
     public long skip(long ln) throws IOException {
-        return this.proxy.skip(ln);
+        return in.skip(ln);
     }
 
     /** @see java.io.Reader#ready() */
     public boolean ready() throws IOException {
-        return this.proxy.ready();
+        return in.ready();
     }
 
     /** @see java.io.Reader#close() */
     public void close() throws IOException {
-        this.proxy.close();
+        in.close();
     }
 
     /** @see java.io.Reader#mark(int) */
     public synchronized void mark(int idx) throws IOException {
-        this.proxy.mark(idx);
+        in.mark(idx);
     }
 
     /** @see java.io.Reader#reset() */
     public synchronized void reset() throws IOException {
-        this.proxy.reset();
+        in.reset();
     }
 
     /** @see java.io.Reader#markSupported() */
     public boolean markSupported() {
-        return this.proxy.markSupported();
+        return in.markSupported();
     }
 
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyOutputStream.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyOutputStream.java?view=diff&r1=154555&r2=154556
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyOutputStream.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyOutputStream.java
Sun Feb 20 10:33:39 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2004 The Apache Software Foundation.
+ * Copyright 2002-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,48 +20,50 @@
 import java.io.OutputStream;
 
 /**
- * 
  * A Proxy stream which acts as expected, that is it passes the method 
  * calls on to the proxied stream and doesn't change which methods are 
  * being called. It is an alternative base class to FilterOutputStream
  * to increase reusability.
+ * 
+ * @author Henri Yandell
+ * @author Stephen Colebourne
+ * @version $Id$
  */
 public class ProxyOutputStream extends FilterOutputStream {
 
-    private OutputStream proxy;
-
     /**
      * Constructs a new ProxyOutputStream.
-     * @param proxy OutputStream to delegate to
+     * 
+     * @param proxy  the OutputStream to delegate to
      */
     public ProxyOutputStream(OutputStream proxy) {
         super(proxy);
-        this.proxy = proxy;
+        // the proxy is stored in a protected superclass variable named 'out'
     }
 
     /** @see java.io.OutputStream#write(int) */
     public void write(int idx) throws IOException {
-        this.proxy.write(idx);
+        out.write(idx);
     }
 
     /** @see java.io.OutputStream#write(byte[]) */
     public void write(byte[] bts) throws IOException {
-        this.proxy.write(bts);
+        out.write(bts);
     }
 
     /** @see java.io.OutputStream#write(byte[], int, int) */
     public void write(byte[] bts, int st, int end) throws IOException {
-        this.proxy.write(bts, st, end);
+        out.write(bts, st, end);
     }
 
     /** @see java.io.OutputStream#flush() */
     public void flush() throws IOException {
-        this.proxy.flush();
+        out.flush();
     }
 
     /** @see java.io.OutputStream#close() */
     public void close() throws IOException {
-        this.proxy.close();
+        out.close();
     }
 
 }

Modified: jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyWriter.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyWriter.java?view=diff&r1=154555&r2=154556
==============================================================================
--- jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyWriter.java
(original)
+++ jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/output/ProxyWriter.java
Sun Feb 20 10:33:39 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 2002-2004 The Apache Software Foundation.
+ * Copyright 2002-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,60 +20,62 @@
 import java.io.Writer;
 
 /**
- * 
  * A Proxy stream which acts as expected, that is it passes the method 
  * calls on to the proxied stream and doesn't change which methods are 
  * being called. It is an alternative base class to FilterWriter
  * to increase reusability, because FilterWriter changes the 
  * methods being called, such as write(char[]) to write(char[], int, int)
  * and write(String) to write(String, int, int).
+ * 
+ * @author Henri Yandell
+ * @author Stephen Colebourne
+ * @version $Id$
  */
 public class ProxyWriter extends FilterWriter {
 
-    private Writer proxy;
-
     /**
      * Constructs a new ProxyWriter.
-     * @param proxy Writer to delegate to
+     * 
+     * @param proxy  the Writer to delegate to
      */
     public ProxyWriter(Writer proxy) {
         super(proxy);
-        this.proxy = proxy;
+        // the proxy is stored in a protected superclass variable named 'out'
     }
 
     /** @see java.io.Writer#write(int) */
     public void write(int idx) throws IOException {
-        this.proxy.write(idx);
+        out.write(idx);
     }
 
     /** @see java.io.Writer#write(char[]) */
     public void write(char[] chr) throws IOException {
-        this.proxy.write(chr);
+        out.write(chr);
     }
 
     /** @see java.io.Writer#write(char[], int, int) */
     public void write(char[] chr, int st, int end) throws IOException {
-        this.proxy.write(chr, st, end);
+        out.write(chr, st, end);
     }
 
     /** @see java.io.Writer#write(String) */
     public void write(String str) throws IOException {
-        this.proxy.write(str);
+        out.write(str);
     }
 
     /** @see java.io.Writer#write(String, int, int) */
     public void write(String str, int st, int end) throws IOException {
-        this.proxy.write(str, st, end);
+        out.write(str, st, end);
     }
 
     /** @see java.io.Writer#flush() */
     public void flush() throws IOException {
-        this.proxy.flush();
+        out.flush();
     }
 
     /** @see java.io.Writer#close() */
     public void close() throws IOException {
-        this.proxy.close();
+        out.close();
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message