commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1301754 - in /commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary: BaseNCodec.java BaseNCodecInputStream.java BaseNCodecOutputStream.java
Date Fri, 16 Mar 2012 20:50:18 GMT
Author: ggregory
Date: Fri Mar 16 20:50:18 2012
New Revision: 1301754

URL: http://svn.apache.org/viewvc?rev=1301754&view=rev
Log:
Replace magic number (-1) with EOF constant.

Modified:
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java
    commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java?rev=1301754&r1=1301753&r2=1301754&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
(original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodec.java
Fri Mar 16 20:50:18 2012
@@ -32,6 +32,8 @@ import org.apache.commons.codec.EncoderE
  */
 public abstract class BaseNCodec implements BinaryEncoder, BinaryDecoder {
 
+    static final int EOF = -1;
+
     /**
      *  MIME chunk size per RFC 2045 section 6.8.
      *
@@ -213,7 +215,7 @@ public abstract class BaseNCodec impleme
             }
             return len;
         }
-        return eof ? -1 : 0;
+        return eof ? EOF : 0;
     }
 
     /**
@@ -319,7 +321,7 @@ public abstract class BaseNCodec impleme
             return pArray;
         }
         decode(pArray, 0, pArray.length);
-        decode(pArray, 0, -1); // Notify decoder of EOF.
+        decode(pArray, 0, EOF); // Notify decoder of EOF.
         byte[] result = new byte[pos];
         readResults(result, 0, result.length);
         return result;
@@ -338,7 +340,7 @@ public abstract class BaseNCodec impleme
             return pArray;
         }
         encode(pArray, 0, pArray.length);
-        encode(pArray, 0, -1); // Notify encoder of EOF.
+        encode(pArray, 0, EOF); // Notify encoder of EOF.
         byte[] buf = new byte[pos - readPos];
         readResults(buf, 0, buf.length);
         return buf;

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java?rev=1301754&r1=1301753&r2=1301754&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java
(original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecInputStream.java
Fri Mar 16 20:50:18 2012
@@ -17,6 +17,8 @@
 
 package org.apache.commons.codec.binary;
 
+import static org.apache.commons.codec.binary.BaseNCodec.EOF;
+
 import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
@@ -57,7 +59,7 @@ public class BaseNCodecInputStream exten
             final byte b = singleByte[0];
             return b < 0 ? 256 + b : b;
         }
-        return -1;
+        return EOF;
     }
 
     /**

Modified: commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java?rev=1301754&r1=1301753&r2=1301754&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java
(original)
+++ commons/proper/codec/trunk/src/main/java/org/apache/commons/codec/binary/BaseNCodecOutputStream.java
Fri Mar 16 20:50:18 2012
@@ -17,6 +17,8 @@
 
 package org.apache.commons.codec.binary;
 
+import static org.apache.commons.codec.binary.BaseNCodec.EOF;
+
 import java.io.FilterOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -134,9 +136,9 @@ public class BaseNCodecOutputStream exte
     public void close() throws IOException {
         // Notify encoder of EOF (-1).
         if (doEncode) {
-            baseNCodec.encode(singleByte, 0, -1);
+            baseNCodec.encode(singleByte, 0, EOF);
         } else {
-            baseNCodec.decode(singleByte, 0, -1);
+            baseNCodec.decode(singleByte, 0, EOF);
         }
         flush();
         out.close();



Mime
View raw message