You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by rg...@apache.org on 2009/04/13 06:06:06 UTC
svn commit: r764356 [6/11] - in /commons/proper/vfs/trunk: ./
core/src/main/java/org/apache/commons/vfs/
core/src/main/java/org/apache/commons/vfs/auth/
core/src/main/java/org/apache/commons/vfs/cache/
core/src/main/java/org/apache/commons/vfs/events/ ...
Modified: commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/CBZip2InputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/CBZip2InputStream.java?rev=764356&r1=764355&r2=764356&view=diff
==============================================================================
--- commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/CBZip2InputStream.java (original)
+++ commons/proper/vfs/trunk/core/src/main/java/org/apache/commons/vfs/provider/bzip2/CBZip2InputStream.java Mon Apr 13 04:06:01 2009
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -32,8 +32,8 @@
* @author <a href="mailto:keiron@aftexsw.com">Keiron Liddle</a>
*/
class CBZip2InputStream
- extends InputStream
- implements BZip2Constants
+ extends InputStream
+ implements BZip2Constants
{
private static final int START_BLOCK_STATE = 1;
private static final int RAND_PART_A_STATE = 2;
@@ -43,31 +43,31 @@
private static final int NO_RAND_PART_B_STATE = 6;
private static final int NO_RAND_PART_C_STATE = 7;
- private CRC m_crc = new CRC();
- private boolean[] m_inUse = new boolean[ 256 ];
- private char[] m_seqToUnseq = new char[ 256 ];
- private char[] m_unseqToSeq = new char[ 256 ];
- private char[] m_selector = new char[ MAX_SELECTORS ];
- private char[] m_selectorMtf = new char[ MAX_SELECTORS ];
+ private CRC crc = new CRC();
+ private boolean[] inUse = new boolean[256];
+ private char[] seqToUnseq = new char[256];
+ private char[] unseqToSeq = new char[256];
+ private char[] selector = new char[MAX_SELECTORS];
+ private char[] selectorMtf = new char[MAX_SELECTORS];
/*
* freq table collected to save a pass over the data
* during decompression.
*/
- private int[] m_unzftab = new int[ 256 ];
+ private int[] unzftab = new int[256];
- private int[][] m_limit = new int[ N_GROUPS ][ MAX_ALPHA_SIZE ];
- private int[][] m_base = new int[ N_GROUPS ][ MAX_ALPHA_SIZE ];
- private int[][] m_perm = new int[ N_GROUPS ][ MAX_ALPHA_SIZE ];
- private int[] m_minLens = new int[ N_GROUPS ];
-
- private boolean m_streamEnd;
- private int m_currentChar = -1;
-
- private int m_currentState = START_BLOCK_STATE;
- private int m_rNToGo;
- private int m_rTPos;
- private int m_tPos;
+ private int[][] limit = new int[N_GROUPS][MAX_ALPHA_SIZE];
+ private int[][] base = new int[N_GROUPS][MAX_ALPHA_SIZE];
+ private int[][] perm = new int[N_GROUPS][MAX_ALPHA_SIZE];
+ private int[] minLens = new int[N_GROUPS];
+
+ private boolean streamEnd;
+ private int currentChar = -1;
+
+ private int currentState = START_BLOCK_STATE;
+ private int rNToGo;
+ private int rTPos;
+ private int tPos;
private int i2;
private int count;
@@ -82,35 +82,35 @@
* always: in the range 0 .. 9.
* The current block size is 100000 * this number.
*/
- private int m_blockSize100k;
- private int m_bsBuff;
- private int m_bsLive;
+ private int blockSize100k;
+ private int bsBuff;
+ private int bsLive;
private InputStream m_input;
- private int m_computedBlockCRC;
- private int m_computedCombinedCRC;
+ private int computedBlockCRC;
+ private int computedCombinedCRC;
/*
* index of the last char in the block, so
* the block size == last + 1.
*/
- private int m_last;
- private char[] m_ll8;
- private int m_nInUse;
+ private int last;
+ private char[] mll8;
+ private int nInUse;
/*
* index in zptr[] of original string after sorting.
*/
- private int m_origPtr;
+ private int origPtr;
- private int m_storedBlockCRC;
- private int m_storedCombinedCRC;
- private int[] m_tt;
+ private int storedBlockCRC;
+ private int storedCombinedCRC;
+ private int[] tt;
- CBZip2InputStream( final InputStream input )
+ CBZip2InputStream(final InputStream input)
{
- bsSetStream( input );
+ bsSetStream(input);
initialize();
initBlock();
setupBlock();
@@ -128,7 +128,7 @@
private static void cadvise()
{
- System.out.println( "CRC Error" );
+ System.out.println("CRC Error");
//throw new CCoruptionError();
}
@@ -142,31 +142,30 @@
cadvise();
}
- /**
- * a fake <code>available</code> which always returns 1 as long as the stream is not at end.
- * This is required to make this stream work if wrapped in an BufferedInputStream.
- *
- * @author imario@apache.org
- */
- public int available() throws IOException
- {
- if (!m_streamEnd)
- {
- return 1;
- }
- return 0;
- }
+ /**
+ * a fake <code>available</code> which always returns 1 as long as the stream is not at end.
+ * This is required to make this stream work if wrapped in an BufferedInputStream.
+ *
+ */
+ public int available() throws IOException
+ {
+ if (!streamEnd)
+ {
+ return 1;
+ }
+ return 0;
+ }
- public int read()
+ public int read()
{
- if( m_streamEnd )
+ if (streamEnd)
{
return -1;
}
else
{
- int retChar = m_currentChar;
- switch( m_currentState )
+ int retChar = currentChar;
+ switch (currentState)
{
case START_BLOCK_STATE:
break;
@@ -193,50 +192,50 @@
}
}
- private void setDecompressStructureSizes( int newSize100k )
+ private void setDecompressStructureSizes(int newSize100k)
{
- if( !( 0 <= newSize100k && newSize100k <= 9 && 0 <= m_blockSize100k
- && m_blockSize100k <= 9 ) )
+ if (!(0 <= newSize100k && newSize100k <= 9 && 0 <= blockSize100k
+ && blockSize100k <= 9))
{
// throw new IOException("Invalid block size");
}
- m_blockSize100k = newSize100k;
+ blockSize100k = newSize100k;
- if( newSize100k == 0 )
+ if (newSize100k == 0)
{
return;
}
int n = BASE_BLOCK_SIZE * newSize100k;
- m_ll8 = new char[ n ];
- m_tt = new int[ n ];
+ mll8 = new char[n];
+ tt = new int[n];
}
private void setupBlock()
{
- int[] cftab = new int[ 257 ];
+ int[] cftab = new int[257];
char ch;
- cftab[ 0 ] = 0;
- for( int i = 1; i <= 256; i++ )
+ cftab[0] = 0;
+ for (int i = 1; i <= 256; i++)
{
- cftab[ i ] = m_unzftab[ i - 1 ];
+ cftab[i] = unzftab[i - 1];
}
- for( int i = 1; i <= 256; i++ )
+ for (int i = 1; i <= 256; i++)
{
- cftab[ i ] += cftab[ i - 1 ];
+ cftab[i] += cftab[i - 1];
}
- for( int i = 0; i <= m_last; i++ )
+ for (int i = 0; i <= last; i++)
{
- ch = m_ll8[ i ];
- m_tt[ cftab[ ch ] ] = i;
- cftab[ ch ]++;
+ ch = mll8[i];
+ tt[cftab[ch]] = i;
+ cftab[ch]++;
}
cftab = null;
- m_tPos = m_tt[ m_origPtr ];
+ tPos = tt[origPtr];
count = 0;
i2 = 0;
@@ -244,10 +243,10 @@
/*
* not a char and not EOF
*/
- if( m_blockRandomised )
+ if (m_blockRandomised)
{
- m_rNToGo = 0;
- m_rTPos = 0;
+ rNToGo = 0;
+ rTPos = 0;
setupRandPartA();
}
else
@@ -258,16 +257,16 @@
private void setupNoRandPartA()
{
- if( i2 <= m_last )
+ if (i2 <= last)
{
chPrev = ch2;
- ch2 = m_ll8[ m_tPos ];
- m_tPos = m_tt[ m_tPos ];
+ ch2 = mll8[tPos];
+ tPos = tt[tPos];
i2++;
- m_currentChar = ch2;
- m_currentState = NO_RAND_PART_B_STATE;
- m_crc.updateCRC( ch2 );
+ currentChar = ch2;
+ currentState = NO_RAND_PART_B_STATE;
+ crc.updateCRC(ch2);
}
else
{
@@ -279,26 +278,26 @@
private void setupNoRandPartB()
{
- if( ch2 != chPrev )
+ if (ch2 != chPrev)
{
- m_currentState = NO_RAND_PART_A_STATE;
+ currentState = NO_RAND_PART_A_STATE;
count = 1;
setupNoRandPartA();
}
else
{
count++;
- if( count >= 4 )
+ if (count >= 4)
{
- z = m_ll8[ m_tPos ];
- m_tPos = m_tt[ m_tPos ];
- m_currentState = NO_RAND_PART_C_STATE;
+ z = mll8[tPos];
+ tPos = tt[tPos];
+ currentState = NO_RAND_PART_C_STATE;
j2 = 0;
setupNoRandPartC();
}
else
{
- m_currentState = NO_RAND_PART_A_STATE;
+ currentState = NO_RAND_PART_A_STATE;
setupNoRandPartA();
}
}
@@ -306,15 +305,15 @@
private void setupNoRandPartC()
{
- if( j2 < z )
+ if (j2 < z)
{
- m_currentChar = ch2;
- m_crc.updateCRC( ch2 );
+ currentChar = ch2;
+ crc.updateCRC(ch2);
j2++;
}
else
{
- m_currentState = NO_RAND_PART_A_STATE;
+ currentState = NO_RAND_PART_A_STATE;
i2++;
count = 0;
setupNoRandPartA();
@@ -323,27 +322,27 @@
private void setupRandPartA()
{
- if( i2 <= m_last )
+ if (i2 <= last)
{
chPrev = ch2;
- ch2 = m_ll8[ m_tPos ];
- m_tPos = m_tt[ m_tPos ];
- if( m_rNToGo == 0 )
+ ch2 = mll8[tPos];
+ tPos = tt[tPos];
+ if (rNToGo == 0)
{
- m_rNToGo = RAND_NUMS[ m_rTPos ];
- m_rTPos++;
- if( m_rTPos == 512 )
+ rNToGo = RAND_NUMS[rTPos];
+ rTPos++;
+ if (rTPos == 512)
{
- m_rTPos = 0;
+ rTPos = 0;
}
}
- m_rNToGo--;
- ch2 ^= ( ( m_rNToGo == 1 ) ? 1 : 0 );
+ rNToGo--;
+ ch2 ^= ((rNToGo == 1) ? 1 : 0);
i2++;
- m_currentChar = ch2;
- m_currentState = RAND_PART_B_STATE;
- m_crc.updateCRC( ch2 );
+ currentChar = ch2;
+ currentState = RAND_PART_B_STATE;
+ crc.updateCRC(ch2);
}
else
{
@@ -355,37 +354,37 @@
private void setupRandPartB()
{
- if( ch2 != chPrev )
+ if (ch2 != chPrev)
{
- m_currentState = RAND_PART_A_STATE;
+ currentState = RAND_PART_A_STATE;
count = 1;
setupRandPartA();
}
else
{
count++;
- if( count >= 4 )
+ if (count >= 4)
{
- z = m_ll8[ m_tPos ];
- m_tPos = m_tt[ m_tPos ];
- if( m_rNToGo == 0 )
- {
- m_rNToGo = RAND_NUMS[ m_rTPos ];
- m_rTPos++;
- if( m_rTPos == 512 )
+ z = mll8[tPos];
+ tPos = tt[tPos];
+ if (rNToGo == 0)
+ {
+ rNToGo = RAND_NUMS[rTPos];
+ rTPos++;
+ if (rTPos == 512)
{
- m_rTPos = 0;
+ rTPos = 0;
}
}
- m_rNToGo--;
- z ^= ( ( m_rNToGo == 1 ) ? 1 : 0 );
+ rNToGo--;
+ z ^= ((rNToGo == 1) ? 1 : 0);
j2 = 0;
- m_currentState = RAND_PART_C_STATE;
+ currentState = RAND_PART_C_STATE;
setupRandPartC();
}
else
{
- m_currentState = RAND_PART_A_STATE;
+ currentState = RAND_PART_A_STATE;
setupRandPartA();
}
}
@@ -393,15 +392,15 @@
private void setupRandPartC()
{
- if( j2 < z )
+ if (j2 < z)
{
- m_currentChar = ch2;
- m_crc.updateCRC( ch2 );
+ currentChar = ch2;
+ crc.updateCRC(ch2);
j2++;
}
else
{
- m_currentState = RAND_PART_A_STATE;
+ currentState = RAND_PART_A_STATE;
i2++;
count = 0;
setupRandPartA();
@@ -412,11 +411,11 @@
{
int nextSym;
- int limitLast = BASE_BLOCK_SIZE * m_blockSize100k;
- m_origPtr = readVariableSizedInt( 24 );
+ int limitLast = BASE_BLOCK_SIZE * blockSize100k;
+ origPtr = readVariableSizedInt(24);
recvDecodingTables();
- int EOB = m_nInUse + 1;
+ int EOB = nInUse + 1;
int groupNo = -1;
int groupPos = 0;
@@ -426,18 +425,18 @@
* in a separate pass, and so saves a block's worth of
* cache misses.
*/
- for( int i = 0; i <= 255; i++ )
+ for (int i = 0; i <= 255; i++)
{
- m_unzftab[ i ] = 0;
+ unzftab[i] = 0;
}
- final char[] yy = new char[ 256 ];
- for( int i = 0; i <= 255; i++ )
+ final char[] yy = new char[256];
+ for (int i = 0; i <= 255; i++)
{
- yy[ i ] = (char)i;
+ yy[i] = (char) i;
}
- m_last = -1;
+ last = -1;
int zt;
int zn;
int zvec;
@@ -445,116 +444,117 @@
groupNo++;
groupPos = G_SIZE - 1;
- zt = m_selector[ groupNo ];
- zn = m_minLens[ zt ];
- zvec = bsR( zn );
- while( zvec > m_limit[ zt ][ zn ] )
+ zt = selector[groupNo];
+ zn = minLens[zt];
+ zvec = bsR(zn);
+ while (zvec > limit[zt][zn])
{
zn++;
- while( m_bsLive < 1 )
+ while (bsLive < 1)
{
int zzi = 0;
try
{
zzi = m_input.read();
}
- catch( IOException e )
+ catch (IOException e)
{
compressedStreamEOF();
}
- if( zzi == -1 )
+ if (zzi == -1)
{
compressedStreamEOF();
}
- m_bsBuff = ( m_bsBuff << 8 ) | ( zzi & 0xff );
- m_bsLive += 8;
+ bsBuff = (bsBuff << 8) | (zzi & 0xff);
+ bsLive += 8;
}
- zj = ( m_bsBuff >> ( m_bsLive - 1 ) ) & 1;
- m_bsLive--;
+ zj = (bsBuff >> (bsLive - 1)) & 1;
+ bsLive--;
- zvec = ( zvec << 1 ) | zj;
+ zvec = (zvec << 1) | zj;
}
- nextSym = m_perm[ zt ][ zvec - m_base[ zt ][ zn ] ];
+ nextSym = perm[zt][zvec - base[zt][zn]];
- while( true )
+ while (true)
{
- if( nextSym == EOB )
+ if (nextSym == EOB)
{
break;
}
- if( nextSym == RUNA || nextSym == RUNB )
+ if (nextSym == RUNA || nextSym == RUNB)
{
char ch;
int s = -1;
int N = 1;
do
{
- if( nextSym == RUNA )
+ if (nextSym == RUNA)
{
- s = s + ( 0 + 1 ) * N;
+ s = s + (0 + 1) * N;
}
else// if( nextSym == RUNB )
{
- s = s + ( 1 + 1 ) * N;
+ s = s + (1 + 1) * N;
}
N = N * 2;
- if( groupPos == 0 )
+ if (groupPos == 0)
{
groupNo++;
groupPos = G_SIZE;
}
groupPos--;
- zt = m_selector[ groupNo ];
- zn = m_minLens[ zt ];
- zvec = bsR( zn );
- while( zvec > m_limit[ zt ][ zn ] )
+ zt = selector[groupNo];
+ zn = minLens[zt];
+ zvec = bsR(zn);
+ while (zvec > limit[zt][zn])
{
zn++;
- while( m_bsLive < 1 )
+ while (bsLive < 1)
{
int zzi = 0;
try
{
zzi = m_input.read();
}
- catch( IOException e )
+ catch (IOException e)
{
compressedStreamEOF();
}
- if( zzi == -1 )
+ if (zzi == -1)
{
compressedStreamEOF();
}
- m_bsBuff = ( m_bsBuff << 8 ) | ( zzi & 0xff );
- m_bsLive += 8;
+ bsBuff = (bsBuff << 8) | (zzi & 0xff);
+ bsLive += 8;
}
- zj = ( m_bsBuff >> ( m_bsLive - 1 ) ) & 1;
- m_bsLive--;
- zvec = ( zvec << 1 ) | zj;
+ zj = (bsBuff >> (bsLive - 1)) & 1;
+ bsLive--;
+ zvec = (zvec << 1) | zj;
}
- nextSym = m_perm[ zt ][ zvec - m_base[ zt ][ zn ] ];
+ nextSym = perm[zt][zvec - base[zt][zn]];
- } while( nextSym == RUNA || nextSym == RUNB );
+ }
+ while (nextSym == RUNA || nextSym == RUNB);
s++;
- ch = m_seqToUnseq[ yy[ 0 ] ];
- m_unzftab[ ch ] += s;
+ ch = seqToUnseq[yy[0]];
+ unzftab[ch] += s;
- while( s > 0 )
+ while (s > 0)
{
- m_last++;
- m_ll8[ m_last ] = ch;
+ last++;
+ mll8[last] = ch;
s--;
}
- if( m_last >= limitLast )
+ if (last >= limitLast)
{
blockOverrun();
}
@@ -563,15 +563,15 @@
else
{
char tmp;
- m_last++;
- if( m_last >= limitLast )
+ last++;
+ if (last >= limitLast)
{
blockOverrun();
}
- tmp = yy[ nextSym - 1 ];
- m_unzftab[ m_seqToUnseq[ tmp ] ]++;
- m_ll8[ m_last ] = m_seqToUnseq[ tmp ];
+ tmp = yy[nextSym - 1];
+ unzftab[seqToUnseq[tmp]]++;
+ mll8[last] = seqToUnseq[tmp];
/*
* This loop is hammered during decompression,
@@ -579,55 +579,55 @@
* for (j = nextSym-1; j > 0; j--) yy[j] = yy[j-1];
*/
int j = nextSym - 1;
- for( ; j > 3; j -= 4 )
+ for (; j > 3; j -= 4)
{
- yy[ j ] = yy[ j - 1 ];
- yy[ j - 1 ] = yy[ j - 2 ];
- yy[ j - 2 ] = yy[ j - 3 ];
- yy[ j - 3 ] = yy[ j - 4 ];
+ yy[j] = yy[j - 1];
+ yy[j - 1] = yy[j - 2];
+ yy[j - 2] = yy[j - 3];
+ yy[j - 3] = yy[j - 4];
}
- for( ; j > 0; j-- )
+ for (; j > 0; j--)
{
- yy[ j ] = yy[ j - 1 ];
+ yy[j] = yy[j - 1];
}
- yy[ 0 ] = tmp;
+ yy[0] = tmp;
- if( groupPos == 0 )
+ if (groupPos == 0)
{
groupNo++;
groupPos = G_SIZE;
}
groupPos--;
- zt = m_selector[ groupNo ];
- zn = m_minLens[ zt ];
- zvec = bsR( zn );
- while( zvec > m_limit[ zt ][ zn ] )
+ zt = selector[groupNo];
+ zn = minLens[zt];
+ zvec = bsR(zn);
+ while (zvec > limit[zt][zn])
{
zn++;
- while( m_bsLive < 1 )
+ while (bsLive < 1)
{
char ch = 0;
try
{
- ch = (char)m_input.read();
+ ch = (char) m_input.read();
}
- catch( IOException e )
+ catch (IOException e)
{
compressedStreamEOF();
}
- m_bsBuff = ( m_bsBuff << 8 ) | ( ch & 0xff );
- m_bsLive += 8;
+ bsBuff = (bsBuff << 8) | (ch & 0xff);
+ bsLive += 8;
}
- zj = ( m_bsBuff >> ( m_bsLive - 1 ) ) & 1;
- m_bsLive--;
+ zj = (bsBuff >> (bsLive - 1)) & 1;
+ bsLive--;
- zvec = ( zvec << 1 ) | zj;
+ zvec = (zvec << 1) | zj;
}
- nextSym = m_perm[ zt ][ zvec - m_base[ zt ][ zn ] ];
+ nextSym = perm[zt][zvec - base[zt][zn]];
continue;
}
@@ -642,148 +642,148 @@
{
m_input.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
}
}
m_input = null;
}
- private int readVariableSizedInt( final int numBits )
+ private int readVariableSizedInt(final int numBits)
{
- return bsR( numBits );
+ return bsR(numBits);
}
private char readUnsignedChar()
{
- return (char)bsR( 8 );
+ return (char) bsR(8);
}
private int readInt()
{
int u = 0;
- u = ( u << 8 ) | bsR( 8 );
- u = ( u << 8 ) | bsR( 8 );
- u = ( u << 8 ) | bsR( 8 );
- u = ( u << 8 ) | bsR( 8 );
+ u = (u << 8) | bsR(8);
+ u = (u << 8) | bsR(8);
+ u = (u << 8) | bsR(8);
+ u = (u << 8) | bsR(8);
return u;
}
- private int bsR( final int n )
+ private int bsR(final int n)
{
- while( m_bsLive < n )
+ while (bsLive < n)
{
int ch = 0;
try
{
ch = m_input.read();
}
- catch( final IOException ioe )
+ catch (final IOException ioe)
{
compressedStreamEOF();
}
- if( ch == -1 )
+ if (ch == -1)
{
compressedStreamEOF();
}
- m_bsBuff = ( m_bsBuff << 8 ) | ( ch & 0xff );
- m_bsLive += 8;
+ bsBuff = (bsBuff << 8) | (ch & 0xff);
+ bsLive += 8;
}
- final int result = ( m_bsBuff >> ( m_bsLive - n ) ) & ( ( 1 << n ) - 1 );
- m_bsLive -= n;
+ final int result = (bsBuff >> (bsLive - n)) & ((1 << n) - 1);
+ bsLive -= n;
return result;
}
- private void bsSetStream( final InputStream input )
+ private void bsSetStream(final InputStream input)
{
m_input = input;
- m_bsLive = 0;
- m_bsBuff = 0;
+ bsLive = 0;
+ bsBuff = 0;
}
private void complete()
{
- m_storedCombinedCRC = readInt();
- if( m_storedCombinedCRC != m_computedCombinedCRC )
+ storedCombinedCRC = readInt();
+ if (storedCombinedCRC != computedCombinedCRC)
{
crcError();
}
bsFinishedWithStream();
- m_streamEnd = true;
+ streamEnd = true;
}
private void endBlock()
{
- m_computedBlockCRC = m_crc.getFinalCRC();
+ computedBlockCRC = crc.getFinalCRC();
/*
* A bad CRC is considered a fatal error.
*/
- if( m_storedBlockCRC != m_computedBlockCRC )
+ if (storedBlockCRC != computedBlockCRC)
{
crcError();
}
- m_computedCombinedCRC = ( m_computedCombinedCRC << 1 )
- | ( m_computedCombinedCRC >>> 31 );
- m_computedCombinedCRC ^= m_computedBlockCRC;
+ computedCombinedCRC = (computedCombinedCRC << 1)
+ | (computedCombinedCRC >>> 31);
+ computedCombinedCRC ^= computedBlockCRC;
}
- private void hbCreateDecodeTables( final int[] limit,
- final int[] base,
- final int[] perm,
- final char[] length,
- final int minLen,
- final int maxLen,
- final int alphaSize )
+ private void hbCreateDecodeTables(final int[] limit,
+ final int[] base,
+ final int[] perm,
+ final char[] length,
+ final int minLen,
+ final int maxLen,
+ final int alphaSize)
{
int pp = 0;
- for( int i = minLen; i <= maxLen; i++ )
+ for (int i = minLen; i <= maxLen; i++)
{
- for( int j = 0; j < alphaSize; j++ )
+ for (int j = 0; j < alphaSize; j++)
{
- if( length[ j ] == i )
+ if (length[j] == i)
{
- perm[ pp ] = j;
+ perm[pp] = j;
pp++;
}
}
}
- for( int i = 0; i < MAX_CODE_LEN; i++ )
+ for (int i = 0; i < MAX_CODE_LEN; i++)
{
- base[ i ] = 0;
+ base[i] = 0;
}
- for( int i = 0; i < alphaSize; i++ )
+ for (int i = 0; i < alphaSize; i++)
{
- base[ length[ i ] + 1 ]++;
+ base[length[i] + 1]++;
}
- for( int i = 1; i < MAX_CODE_LEN; i++ )
+ for (int i = 1; i < MAX_CODE_LEN; i++)
{
- base[ i ] += base[ i - 1 ];
+ base[i] += base[i - 1];
}
- for( int i = 0; i < MAX_CODE_LEN; i++ )
+ for (int i = 0; i < MAX_CODE_LEN; i++)
{
- limit[ i ] = 0;
+ limit[i] = 0;
}
int vec = 0;
- for( int i = minLen; i <= maxLen; i++ )
+ for (int i = minLen; i <= maxLen; i++)
{
- vec += ( base[ i + 1 ] - base[ i ] );
- limit[ i ] = vec - 1;
+ vec += (base[i + 1] - base[i]);
+ limit[i] = vec - 1;
vec <<= 1;
}
- for( int i = minLen + 1; i <= maxLen; i++ )
+ for (int i = minLen + 1; i <= maxLen; i++)
{
- base[ i ] = ( ( limit[ i - 1 ] + 1 ) << 1 ) - base[ i ];
+ base[i] = ((limit[i - 1] + 1) << 1) - base[i];
}
}
@@ -795,24 +795,24 @@
final char magic4 = readUnsignedChar();
final char magic5 = readUnsignedChar();
final char magic6 = readUnsignedChar();
- if( magic1 == 0x17 && magic2 == 0x72 && magic3 == 0x45 &&
- magic4 == 0x38 && magic5 == 0x50 && magic6 == 0x90 )
+ if (magic1 == 0x17 && magic2 == 0x72 && magic3 == 0x45 &&
+ magic4 == 0x38 && magic5 == 0x50 && magic6 == 0x90)
{
complete();
return;
}
- if( magic1 != 0x31 || magic2 != 0x41 || magic3 != 0x59 ||
- magic4 != 0x26 || magic5 != 0x53 || magic6 != 0x59 )
+ if (magic1 != 0x31 || magic2 != 0x41 || magic3 != 0x59 ||
+ magic4 != 0x26 || magic5 != 0x53 || magic6 != 0x59)
{
badBlockHeader();
- m_streamEnd = true;
+ streamEnd = true;
return;
}
- m_storedBlockCRC = readInt();
+ storedBlockCRC = readInt();
- if( bsR( 1 ) == 1 )
+ if (bsR(1) == 1)
{
m_blockRandomised = true;
}
@@ -824,35 +824,35 @@
// currBlockNo++;
getAndMoveToFrontDecode();
- m_crc.initialiseCRC();
- m_currentState = START_BLOCK_STATE;
+ crc.initialiseCRC();
+ currentState = START_BLOCK_STATE;
}
private void initialize()
{
final char magic3 = readUnsignedChar();
final char magic4 = readUnsignedChar();
- if( magic3 != 'h' || magic4 < '1' || magic4 > '9' )
+ if (magic3 != 'h' || magic4 < '1' || magic4 > '9')
{
bsFinishedWithStream();
- m_streamEnd = true;
+ streamEnd = true;
return;
}
- setDecompressStructureSizes( magic4 - '0' );
- m_computedCombinedCRC = 0;
+ setDecompressStructureSizes(magic4 - '0');
+ computedCombinedCRC = 0;
}
private void makeMaps()
{
- m_nInUse = 0;
- for( int i = 0; i < 256; i++ )
+ nInUse = 0;
+ for (int i = 0; i < 256; i++)
{
- if( m_inUse[ i ] )
+ if (inUse[i])
{
- m_seqToUnseq[ m_nInUse ] = (char)i;
- m_unseqToSeq[ i ] = (char)m_nInUse;
- m_nInUse++;
+ seqToUnseq[nInUse] = (char) i;
+ unseqToSeq[i] = (char) nInUse;
+ nInUse++;
}
}
}
@@ -861,57 +861,57 @@
{
buildInUseTable();
makeMaps();
- final int alphaSize = m_nInUse + 2;
+ final int alphaSize = nInUse + 2;
/*
* Now the selectors
*/
- final int groupCount = bsR( 3 );
- final int selectorCount = bsR( 15 );
- for( int i = 0; i < selectorCount; i++ )
+ final int groupCount = bsR(3);
+ final int selectorCount = bsR(15);
+ for (int i = 0; i < selectorCount; i++)
{
int run = 0;
- while( bsR( 1 ) == 1 )
+ while (bsR(1) == 1)
{
run++;
}
- m_selectorMtf[ i ] = (char)run;
+ selectorMtf[i] = (char) run;
}
/*
* Undo the MTF values for the selectors.
*/
- final char[] pos = new char[ N_GROUPS ];
- for( char v = 0; v < groupCount; v++ )
+ final char[] pos = new char[N_GROUPS];
+ for (char v = 0; v < groupCount; v++)
{
- pos[ v ] = v;
+ pos[v] = v;
}
- for( int i = 0; i < selectorCount; i++ )
+ for (int i = 0; i < selectorCount; i++)
{
- int v = m_selectorMtf[ i ];
- final char tmp = pos[ v ];
- while( v > 0 )
+ int v = selectorMtf[i];
+ final char tmp = pos[v];
+ while (v > 0)
{
- pos[ v ] = pos[ v - 1 ];
+ pos[v] = pos[v - 1];
v--;
}
- pos[ 0 ] = tmp;
- m_selector[ i ] = tmp;
+ pos[0] = tmp;
+ selector[i] = tmp;
}
- final char[][] len = new char[ N_GROUPS ][ MAX_ALPHA_SIZE ];
+ final char[][] len = new char[N_GROUPS][MAX_ALPHA_SIZE];
/*
* Now the coding tables
*/
- for( int i = 0; i < groupCount; i++ )
+ for (int i = 0; i < groupCount; i++)
{
- int curr = bsR( 5 );
- for( int j = 0; j < alphaSize; j++ )
+ int curr = bsR(5);
+ for (int j = 0; j < alphaSize; j++)
{
- while( bsR( 1 ) == 1 )
+ while (bsR(1) == 1)
{
- if( bsR( 1 ) == 0 )
+ if (bsR(1) == 0)
{
curr++;
}
@@ -920,75 +920,75 @@
curr--;
}
}
- len[ i ][ j ] = (char)curr;
+ len[i][j] = (char) curr;
}
}
/*
* Create the Huffman decoding tables
*/
- for( int k = 0; k < groupCount; k++ )
+ for (int k = 0; k < groupCount; k++)
{
int minLen = 32;
int maxLen = 0;
- for( int i = 0; i < alphaSize; i++ )
+ for (int i = 0; i < alphaSize; i++)
{
- if( len[ k ][ i ] > maxLen )
+ if (len[k][i] > maxLen)
{
- maxLen = len[ k ][ i ];
+ maxLen = len[k][i];
}
- if( len[ k ][ i ] < minLen )
+ if (len[k][i] < minLen)
{
- minLen = len[ k ][ i ];
+ minLen = len[k][i];
}
}
- hbCreateDecodeTables( m_limit[ k ], m_base[ k ], m_perm[ k ], len[ k ], minLen,
- maxLen, alphaSize );
- m_minLens[ k ] = minLen;
+ hbCreateDecodeTables(limit[k], base[k], perm[k], len[k], minLen,
+ maxLen, alphaSize);
+ minLens[k] = minLen;
}
}
private void buildInUseTable()
{
- final boolean[] inUse16 = new boolean[ 16 ];
+ final boolean[] inUse16 = new boolean[16];
/*
* Receive the mapping table
*/
- for( int i = 0; i < 16; i++ )
+ for (int i = 0; i < 16; i++)
{
- if( bsR( 1 ) == 1 )
+ if (bsR(1) == 1)
{
- inUse16[ i ] = true;
+ inUse16[i] = true;
}
else
{
- inUse16[ i ] = false;
+ inUse16[i] = false;
}
}
- for( int i = 0; i < 256; i++ )
+ for (int i = 0; i < 256; i++)
{
- m_inUse[ i ] = false;
+ inUse[i] = false;
}
- for( int i = 0; i < 16; i++ )
+ for (int i = 0; i < 16; i++)
{
- if( inUse16[ i ] )
+ if (inUse16[i])
{
- for( int j = 0; j < 16; j++ )
+ for (int j = 0; j < 16; j++)
{
- if( bsR( 1 ) == 1 )
+ if (bsR(1) == 1)
{
- m_inUse[ i * 16 + j ] = true;
+ inUse[i * 16 + j] = true;
}
}
}
}
}
-
- public void close() throws IOException
+
+ public void close() throws IOException
{
- bsFinishedWithStream();
+ bsFinishedWithStream();
}
}