Update of /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/api/src/java/org/jicarilla/http/util
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2537/components/http/api/src/java/org/jicarilla/http/util
Modified Files:
Base64.java NioUtil.java
Log Message:
Ran some code analysis tools on the code and changed approximately 200 small things based on that. Nothing shocking (I hope!)
Index: Base64.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/api/src/java/org/jicarilla/http/util/Base64.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- Base64.java 11 Jan 2004 12:28:11 -0000 1.3
+++ Base64.java 26 Feb 2004 16:51:54 -0000 1.4
@@ -57,6 +57,7 @@
package org.jicarilla.http.util;
import org.jicarilla.http.HTTPEncoding;
+import org.jicarilla.framework.CascadingRuntimeException;
import java.io.UnsupportedEncodingException;
@@ -83,7 +84,7 @@
public final class Base64
{
/** disable instantiation */
- protected Base64() {}
+ private Base64() {}
protected static final int BASELENGTH = 255;
protected static final int LOOKUPLENGTH = 64;
@@ -143,7 +144,7 @@
* @param isValidString The string to test.
* @return boolean True if the string is base64.
*/
- public static boolean isBase64( String isValidString )
+ public static boolean isBase64( final String isValidString )
{
return isArrayByteBase64( getAsciiBytes( isValidString ) );
}
@@ -154,7 +155,7 @@
* @param octect The octet to test.
* @return boolean True if the octect is base64.
*/
- static boolean isBase64( byte octect )
+ static boolean isBase64( final byte octect )
{
return (octect == PAD || BASE64_ALPHABET[octect] != -1);
}
@@ -165,9 +166,9 @@
* @param arrayOctect The array to test.
* @return boolean true if the specified byte array is base64
*/
- public static boolean isArrayByteBase64( byte[] arrayOctect )
+ public static boolean isArrayByteBase64( final byte[] arrayOctect )
{
- int length = arrayOctect.length;
+ final int length = arrayOctect.length;
if( length == 0 )
return true;
@@ -185,13 +186,13 @@
* @param binaryData Array containing binaryData
* @return Base64-encoded array
*/
- public static byte[] encode( byte[] binaryData )
+ public static byte[] encode( final byte[] binaryData )
{
- int lengthDataBits = binaryData.length * EIGHTBIT;
- int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
- int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
- byte encodedData[] = null;
+ final int lengthDataBits = binaryData.length * EIGHTBIT;
+ final int fewerThan24bits = lengthDataBits % TWENTYFOURBITGROUP;
+ final int numberTriplets = lengthDataBits / TWENTYFOURBITGROUP;
+ byte[] encodedData = null;
if( fewerThan24bits != 0 )
@@ -222,12 +223,12 @@
k = (byte) (b1 & 0x03);
encodedIndex = i * 4;
- byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2)
+ final byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2)
: (byte) ((b1) >> 2 ^ 0xc0);
- byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4)
+ final byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4)
: (byte) ((b2) >> 4 ^ 0xf0);
- byte val3 = ((b3 & SIGN) == 0) ? (byte) (b3 >> 6)
+ final byte val3 = ((b3 & SIGN) == 0) ? (byte) (b3 >> 6)
: (byte) ((b3) >> 6 ^ 0xfc);
encodedData[encodedIndex] = LOOKUP_BASE64_ALPHABET[val1];
@@ -245,7 +246,7 @@
{
b1 = binaryData[dataIndex];
k = (byte) (b1 & 0x03);
- byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2)
+ final byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2)
: (byte) ((b1) >> 2 ^ 0xc0);
encodedData[encodedIndex] = LOOKUP_BASE64_ALPHABET[val1];
encodedData[encodedIndex + 1] = LOOKUP_BASE64_ALPHABET[k << 4];
@@ -258,9 +259,9 @@
l = (byte) (b2 & 0x0f);
k = (byte) (b1 & 0x03);
- byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2)
+ final byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2)
: (byte) ((b1) >> 2 ^ 0xc0);
- byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4)
+ final byte val2 = ((b2 & SIGN) == 0) ? (byte) (b2 >> 4)
: (byte) ((b2) >> 4 ^ 0xf0);
encodedData[encodedIndex] = LOOKUP_BASE64_ALPHABET[val1];
@@ -279,7 +280,7 @@
* @param base64Data byte array containing Base64 data
* @return Array containing decoded data.
*/
- public static byte[] decode( byte[] base64Data )
+ public static byte[] decode( final byte[] base64Data )
{
// Should we throw away anything not in base64Data ?
@@ -287,8 +288,8 @@
if( base64Data.length == 0 )
return new byte[0];
- int numberQuadruple = base64Data.length / FOURBYTE;
- byte decodedData[] = null;
+ final int numberQuadruple = base64Data.length / FOURBYTE;
+ byte[] decodedData = null;
byte b1 = 0, b2 = 0, b3 = 0, b4 = 0, marker0 = 0, marker1 = 0;
int encodedIndex = 0;
@@ -359,7 +360,7 @@
}
catch( UnsupportedEncodingException uee )
{
- throw new RuntimeException( "The underlying JVM does not properly support US-ASCII!" );
+ throw new CascadingRuntimeException( "The underlying JVM does not properly support US-ASCII!", uee );
}
}
}
Index: NioUtil.java
===================================================================
RCS file: /cvsroot/jicarilla/jicarilla-sandbox/platform/components/http/api/src/java/org/jicarilla/http/util/NioUtil.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- NioUtil.java 20 Feb 2004 14:21:42 -0000 1.3
+++ NioUtil.java 26 Feb 2004 16:51:54 -0000 1.4
@@ -43,11 +43,11 @@
* @param buffer
* @param byteBuffer
*/
- public static void append( StringBuffer buffer, ByteBuffer byteBuffer )
+ public static void append( final StringBuffer buffer, final ByteBuffer byteBuffer )
{
- byte[] bytes = new byte[byteBuffer.remaining()];
+ final byte[] bytes = new byte[byteBuffer.remaining()];
byteBuffer.get( bytes );
- char[] chars = new char[bytes.length];
+ final char[] chars = new char[bytes.length];
for( int i = 0; i < bytes.length; i++ )
{
chars[i] = (char)bytes[i];
@@ -63,14 +63,14 @@
* @param byteBuffer
* @return
*/
- public static char[] toCharArray( ByteBuffer byteBuffer )
+ public static char[] toCharArray( final ByteBuffer byteBuffer )
{
if( byteBuffer == null )
return null;
- byte[] bytes = new byte[byteBuffer.remaining()];
+ final byte[] bytes = new byte[byteBuffer.remaining()];
byteBuffer.get( bytes );
- char[] chars = new char[bytes.length];
+ final char[] chars = new char[bytes.length];
for( int i = 0; i < bytes.length; i++ )
{
chars[i] = (char)bytes[i];
@@ -86,7 +86,7 @@
* @param byteBuffer
* @return
*/
- public static String toString( ByteBuffer byteBuffer )
+ public static String toString( final ByteBuffer byteBuffer )
{
if( byteBuffer == null )
return null;
@@ -102,27 +102,27 @@
* @param byteBuffers
* @return
*/
- public static String toString( ByteBuffer[] byteBuffers )
+ public static String toString( final ByteBuffer[] byteBuffers )
{
if( byteBuffers == null || byteBuffers.length == 0 )
return null;
- StringBuffer buffer = new StringBuffer();
+ final StringBuffer buffer = new StringBuffer();
for( int i = 0; i < byteBuffers.length; i++ )
{
- ByteBuffer byteBuffer = byteBuffers[i];
+ final ByteBuffer byteBuffer = byteBuffers[i];
buffer.append( toCharArray( byteBuffer ) );
}
return buffer.toString();
}
- public static ByteBuffer toByteBuffer( String string )
+ public static ByteBuffer toByteBuffer( final String string )
{
if( string == null )
return null;
- ByteBuffer bbuf = ByteBuffer.allocate( string.length() );
- StringBuffer sbuf = new StringBuffer( string );
+ final ByteBuffer bbuf = ByteBuffer.allocate( string.length() );
+ final StringBuffer sbuf = new StringBuffer( string );
for( int i = 0; i < string.length(); i++ )
{
bbuf.put( (byte)sbuf.charAt(i) );
@@ -131,13 +131,13 @@
return bbuf;
}
- public static ByteBuffer toByteBuffer( int num )
+ public static ByteBuffer toByteBuffer( final int num )
{
- String string = ""+num;
+ final String string = ""+num;
return toByteBuffer( string );
}
- public static int toInteger( ByteBuffer byteBuffer )
+ public static int toInteger( final ByteBuffer byteBuffer )
{
if( byteBuffer == null )
return 0;
-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.