commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1292625 - /commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
Date Thu, 23 Feb 2012 02:27:06 GMT
Author: sebb
Date: Thu Feb 23 02:27:05 2012
New Revision: 1292625

URL: http://svn.apache.org/viewvc?rev=1292625&view=rev
Log:
Replace init method with private ctor; allows several fields to be made final

Modified:
    commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java

Modified: commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
URL: http://svn.apache.org/viewvc/commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java?rev=1292625&r1=1292624&r2=1292625&view=diff
==============================================================================
--- commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
(original)
+++ commons/proper/compress/trunk/src/main/java/org/apache/commons/compress/archivers/tar/TarBuffer.java
Thu Feb 23 02:27:05 2012
@@ -44,14 +44,16 @@ class TarBuffer { // Not public, because
     /** Default block size */
     public static final int DEFAULT_BLKSIZE = (DEFAULT_RCDSIZE * 20);
 
+    // TODO make these final? (would need to change close() method)
     private InputStream     inStream;
     private OutputStream    outStream;
-    private byte[]          blockBuffer;
+    private final int             blockSize;
+    private final int             recordSize;
+    private final int             recsPerBlock;
+    private final byte[]          blockBuffer;
+
     private int             currBlkIdx;
     private int             currRecIdx;
-    private int             blockSize;
-    private int             recordSize;
-    private int             recsPerBlock;
     
     /**
      * Constructor for a TarBuffer on an input stream.
@@ -77,10 +79,7 @@ class TarBuffer { // Not public, because
      * @param recordSize the record size to use
      */
     public TarBuffer(InputStream inStream, int blockSize, int recordSize) {
-        this.inStream = inStream;
-        this.outStream = null;
-
-        this.initialize(blockSize, recordSize);
+        this(inStream, null, blockSize, recordSize);
     }
 
     /**
@@ -107,16 +106,15 @@ class TarBuffer { // Not public, because
      * @param recordSize the record size to use
      */
     public TarBuffer(OutputStream outStream, int blockSize, int recordSize) {
-        this.inStream = null;
-        this.outStream = outStream;
-
-        this.initialize(blockSize, recordSize);
+        this(null, outStream, blockSize, recordSize);
     }
 
     /**
-     * Initialization common to all constructors.
+     * Private constructor to perform common setup.
      */
-    private void initialize(int blockSize, int recordSize) {
+    private TarBuffer(InputStream inStream, OutputStream outStream, int blockSize, int recordSize)
{
+        this.inStream = inStream;
+        this.outStream = outStream;        
         this.blockSize = blockSize;
         this.recordSize = recordSize;
         this.recsPerBlock = (this.blockSize / this.recordSize);



Mime
View raw message