rwaldhoff 01/08/14 10:58:18
Modified: httpclient/src/java/org/apache/commons/httpclient Tag:
rlwrefactoring Base64.java
Log:
remove logging from this class
Revision Changes Path
No revision
No revision
1.4.2.1 +15 -27
jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Base64.java
Index: Base64.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Base64.java,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -r1.4 -r1.4.2.1
--- Base64.java 2001/08/02 20:30:57 1.4
+++ Base64.java 2001/08/14 17:58:18 1.4.2.1
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Base64.java,v
1.4 2001/08/02 20:30:57 rwaldhoff Exp $
- * $Revision: 1.4 $
- * $Date: 2001/08/02 20:30:57 $
+ * $Header:
/home/cvs/jakarta-commons/httpclient/src/java/org/apache/commons/httpclient/Base64.java,v
1.4.2.1 2001/08/14 17:58:18 rwaldhoff Exp $
+ * $Revision: 1.4.2.1 $
+ * $Date: 2001/08/14 17:58:18 $
* ====================================================================
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
@@ -12,19 +12,19 @@
package org.apache.commons.httpclient;
-import org.apache.commons.httpclient.log.*;
-
/**
- * This class provides encode/decode for RFC 2045 Base64 as
- * defined by RFC 2045, N. Freed and N. Borenstein.
+ * Base64 encoder and decoder.
+ * <p>
+ * This class provides encoding/decoding methods for
+ * the Base64 encoding as defined by RFC 2045,
+ * N. Freed and N. Borenstein.
* RFC 2045: Multipurpose Internet Mail Extensions (MIME)
* Part One: Format of Internet Message Bodies. Reference
- * 1996 Available at: http://www.ietf.org/rfc/rfc2045.txt
+ * 1996. Available at: http://www.ietf.org/rfc/rfc2045.txt
*
* @author Jeffrey Rodriguez
- * @version $Id: Base64.java,v 1.4 2001/08/02 20:30:57 rwaldhoff Exp $
+ * @version $Id: Base64.java,v 1.4.2.1 2001/08/14 17:58:18 rwaldhoff Exp $
*/
-
public final class Base64 {
static private final int BASELENGTH = 255;
static private final int LOOKUPLENGTH = 64;
@@ -37,7 +37,6 @@
static private final byte PAD = ( byte ) '=';
static private byte [] base64Alphabet = new byte[BASELENGTH];
static private byte [] lookUpBase64Alphabet = new byte[LOOKUPLENGTH];
- static private final Log log =
LogSource.getInstance("org.apache.commons.httpclient.Base64");
static {
@@ -77,7 +76,7 @@
public static boolean isBase64( byte octect ) {
- //shall we ignore white space? JEFF??
+ // Should we ignore white space?
return(octect == PAD || base64Alphabet[octect] != -1 );
}
@@ -85,8 +84,6 @@
public static boolean isArrayByteBase64( byte[] arrayOctect ) {
int length = arrayOctect.length;
if ( length == 0 ) {
- // shouldn't a 0 length array be valid base64 data?
- // return false;
return true;
}
for ( int i=0; i < length; i++ ) {
@@ -120,7 +117,6 @@
int encodedIndex = 0;
int dataIndex = 0;
int i = 0;
- log.debug("number of triplets = " + numberTriplets);
for ( i = 0; i<numberTriplets; i++ ) {
dataIndex = i*3;
@@ -128,8 +124,6 @@
b2 = binaryData[dataIndex + 1];
b3 = binaryData[dataIndex + 2];
- log.debug("b1= " + b1 +", b2= " + b2 + ", b3= " + b3);
-
l = (byte)(b2 & 0x0f);
k = (byte)(b1 & 0x03);
@@ -140,9 +134,6 @@
byte val3 = ((b3 & SIGN)==0)?(byte)(b3>>6):(byte)((b3)>>6^0xfc);
encodedData[encodedIndex] = lookUpBase64Alphabet[ val1 ];
- log.debug( "val2 = " + val2 );
- log.debug( "k4 = " + (k<<4) );
- log.debug( "vak = " + (val2 | (k<<4)) );
encodedData[encodedIndex+1] = lookUpBase64Alphabet[ val2 | ( k<<4 )];
encodedData[encodedIndex+2] = lookUpBase64Alphabet[ (l <<2 ) | val3 ];
encodedData[encodedIndex+3] = lookUpBase64Alphabet[ b3 & 0x3f ];
@@ -154,15 +145,12 @@
if (fewerThan24bits == EIGHTBIT ) {
b1 = binaryData[dataIndex];
k = (byte) ( b1 &0x03 );
- log.debug("b1=" + b1);
- log.debug("b1<<2 = " + (b1>>2) );
byte val1 = ((b1 & SIGN)==0)?(byte)(b1>>2):(byte)((b1)>>2^0xc0);
encodedData[encodedIndex] = lookUpBase64Alphabet[ val1 ];
encodedData[encodedIndex + 1] = lookUpBase64Alphabet[ k<<4 ];
encodedData[encodedIndex + 2] = PAD;
encodedData[encodedIndex + 3] = PAD;
} else if ( fewerThan24bits == SIXTEENBIT ) {
-
b1 = binaryData[dataIndex];
b2 = binaryData[dataIndex +1 ];
l = ( byte ) ( b2 &0x0f );
@@ -187,6 +175,8 @@
* @return Array containing decoded data.
*/
public static byte[] decode( byte[] base64Data ) {
+ // Should we throw away anything not in base64Data ?
+
// handle the edge case, so we don't have to worry about it later
if(base64Data.length == 0) { return new byte[0]; }
@@ -194,12 +184,10 @@
byte decodedData[] = null;
byte b1=0,b2=0,b3=0, b4=0, marker0=0, marker1=0;
- // Throw away anything not in base64Data
-
int encodedIndex = 0;
int dataIndex = 0;
{
- // this sizes the output array properly - rlw
+ // this block sizes the output array properly - rlw
int lastData = base64Data.length;
// ignore the '=' padding
while(base64Data[lastData-1] == PAD) {
@@ -234,6 +222,6 @@
encodedIndex += 3;
}
return decodedData;
-
}
+
}