@@ -24,7 +24,10 @@ class TarUtils
* @param buf Description of Parameter
* @param buf Description of Parameter
* @return The integer value of the entry's checksum.
* @return The integer value of the entry's checksum.
*/
*/
public static int getCheckSumOctalBytes( long value, byte[] buf, int offset, int length )
public static int getCheckSumOctalBytes( final long value,
final byte[] buf,
final int offset,
final int length )
{
{
getOctalBytes( value, buf, offset, length );
getOctalBytes( value, buf, offset, length );
@@ -43,7 +46,10 @@ class TarUtils
* @param buf Description of Parameter
* @param buf Description of Parameter
* @return The long value of the octal bytes.
* @return The long value of the octal bytes.
*/
*/
public static int getLongOctalBytes( long value, byte[] buf, int offset, int length )
public static int getLongOctalBytes( final long value,
final byte[] buf,
final int offset,
final int length )
{
{
byte[] temp = new byte[ length + 1 ];
byte[] temp = new byte[ length + 1 ];
@@ -62,18 +68,21 @@ class TarUtils
* @param buf Description of Parameter
* @param buf Description of Parameter
* @return The number of bytes in a header's entry name.
* @return The number of bytes in a header's entry name.
*/
*/
public static int getNameBytes( StringBuffer name, byte[] buf, int offset, int length )
public static int getNameBytes( final StringBuffer name,
final byte[] buffer,
final int offset,
final int length )
{
{
int i;
int i;
for( i = 0; i < length && i < name.length(); ++i )
for( i = 0; i < length && i < name.length(); ++i )
{
{
buf[ offset + i ] = (byte)name.charAt( i );
buffer [ offset + i ] = (byte)name.charAt( i );
}
}
for( ; i < length; ++i )
for( ; i < length; ++i )
{
{
buf[ offset + i ] = 0;
buffer [ offset + i ] = 0;
}
}
return offset + length;
return offset + length;
@@ -87,34 +96,37 @@ class TarUtils
* @return The integer value of the octal bytes.
* @return The integer value of the octal bytes.
*/
*/
public static int getOctalBytes( final long value,
public static int getOctalBytes( final long value,
final byte[] buf,
final byte[] buffer ,
final int offset,
final int offset,
final int length )
final int length )
{
{
int idx = length - 1;
int idx = length - 1;
buf[ offset + idx ] = 0;
buffer [ offset + idx ] = 0;
--idx;
--idx;
buf[ offset + idx ] = (byte)' ';
buffer [ offset + idx ] = (byte)' ';
--idx;
--idx;
if( value == 0 )
if( value == 0 )
{
{
buf[ offset + idx ] = (byte)'0';
buffer [ offset + idx ] = (byte)'0';
--idx;
--idx;
}
}
else
else
{
{
for( long val = value; idx >= 0 && val > 0; --idx )
long val = value;
while( idx >= 0 && val > 0 )
{
{
buf[ offset + idx ] = (byte)( (byte)'0' + (byte)( val & 7 ) );
buffer [ offset + idx ] = (byte)( (byte)'0' + (byte)( val & 7 ) );
val = val >> 3;
val = val >> 3;
idx--;
}
}
}
}
for( ; idx >= 0; --idx )
while( idx >= 0 )
{
{
buf[ offset + idx ] = (byte)' ';
buffer[ offset + idx ] = (byte)' ';
idx--;
}
}
return offset + length;
return offset + length;
@@ -126,13 +138,13 @@ class TarUtils
* @param buf The tar entry's header buffer.
* @param buf The tar entry's header buffer.
* @return The computed checksum.
* @return The computed checksum.
*/
*/
public static long computeCheckSum( byte[] buf )
public static long computeCheckSum( final byte[] buffer )
{
{
long sum = 0;
long sum = 0;
for( int i = 0; i < buf.length; ++i )
for( int i = 0; i < buffer .length; ++i )
{
{
sum += 255 & buf[ i ];
sum += 255 & buffer [ i ];
}
}
return sum;
return sum;
@@ -146,7 +158,9 @@ class TarUtils
* @param length The number of header bytes to parse.
* @param length The number of header bytes to parse.
* @return The header's entry name.
* @return The header's entry name.
*/
*/
public static StringBuffer parseName( byte[] header, int offset, int length )
public static StringBuffer parseName( final byte[] header,
final int offset,
final int length )
{
{
StringBuffer result = new StringBuffer( length );
StringBuffer result = new StringBuffer( length );
int end = offset + length;
int end = offset + length;
@@ -173,7 +187,9 @@ class TarUtils
* @param length The number of header bytes to parse.
* @param length The number of header bytes to parse.
* @return The long value of the octal string.
* @return The long value of the octal string.
*/
*/
public static long parseOctal( byte[] header, int offset, int length )
public static long parseOctal( final byte[] header,
final int offset,
final int length )
{
{
long result = 0;
long result = 0;
boolean stillPadding = true;
boolean stillPadding = true;