org.apache.commons.vfs.provider.bzip2
Class CBZip2InputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.apache.commons.vfs.provider.bzip2.CBZip2InputStream
All Implemented Interfaces:
java.io.Closeable, BZip2Constants

 class CBZip2InputStream
extends java.io.InputStream
implements BZip2Constants

An input stream that decompresses from the BZip2 format (without the file header chars) to be read as any other stream.

Author:
Keiron Liddle

Field Summary
private  int ch2
           
private  int chPrev
           
private  int count
           
private  int i2
           
private  int j2
           
private  int[][] m_base
           
private  boolean m_blockRandomised
           
private  int m_blockSize100k
           
private  int m_bsBuff
           
private  int m_bsLive
           
private  int m_computedBlockCRC
           
private  int m_computedCombinedCRC
           
private  CRC m_crc
           
private  int m_currentChar
           
private  int m_currentState
           
private  java.io.InputStream m_input
           
private  boolean[] m_inUse
           
private  int m_last
           
private  int[][] m_limit
           
private  char[] m_ll8
           
private  int[] m_minLens
           
private  int m_nInUse
           
private  int m_origPtr
           
private  int[][] m_perm
           
private  int m_rNToGo
           
private  int m_rTPos
           
private  char[] m_selector
           
private  char[] m_selectorMtf
           
private  char[] m_seqToUnseq
           
private  int m_storedBlockCRC
           
private  int m_storedCombinedCRC
           
private  boolean m_streamEnd
           
private  int m_tPos
           
private  int[] m_tt
           
private  char[] m_unseqToSeq
           
private  int[] m_unzftab
           
private static int NO_RAND_PART_A_STATE
           
private static int NO_RAND_PART_B_STATE
           
private static int NO_RAND_PART_C_STATE
           
private static int RAND_PART_A_STATE
           
private static int RAND_PART_B_STATE
           
private static int RAND_PART_C_STATE
           
private static int START_BLOCK_STATE
           
private  char z
           
 
Fields inherited from interface org.apache.commons.vfs.provider.bzip2.BZip2Constants
BASE_BLOCK_SIZE, G_SIZE, MAX_ALPHA_SIZE, MAX_CODE_LEN, MAX_SELECTORS, N_GROUPS, N_ITERS, NUM_OVERSHOOT_BYTES, RAND_NUMS, RUNA, RUNB
 
Constructor Summary
CBZip2InputStream(java.io.InputStream input)
           
 
Method Summary
 int available()
          a fake available which always returns 1 as long as the stream is not at end.
private static void badBlockHeader()
           
private static void blockOverrun()
           
private  void bsFinishedWithStream()
           
private  int bsR(int n)
           
private  void bsSetStream(java.io.InputStream input)
           
private  void buildInUseTable()
           
private static void cadvise()
           
 void close()
           
private  void complete()
           
private static void compressedStreamEOF()
           
private static void crcError()
           
private  void endBlock()
           
private  void getAndMoveToFrontDecode()
           
private  void hbCreateDecodeTables(int[] limit, int[] base, int[] perm, char[] length, int minLen, int maxLen, int alphaSize)
           
private  void initBlock()
           
private  void initialize()
           
private  void makeMaps()
           
 int read()
           
private  int readInt()
           
private  char readUnsignedChar()
           
private  int readVariableSizedInt(int numBits)
           
private  void recvDecodingTables()
           
private  void setDecompressStructureSizes(int newSize100k)
           
private  void setupBlock()
           
private  void setupNoRandPartA()
           
private  void setupNoRandPartB()
           
private  void setupNoRandPartC()
           
private  void setupRandPartA()
           
private  void setupRandPartB()
           
private  void setupRandPartC()
           
 
Methods inherited from class java.io.InputStream
mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

START_BLOCK_STATE

private static final int START_BLOCK_STATE
See Also:
Constant Field Values

RAND_PART_A_STATE

private static final int RAND_PART_A_STATE
See Also:
Constant Field Values

RAND_PART_B_STATE

private static final int RAND_PART_B_STATE
See Also:
Constant Field Values

RAND_PART_C_STATE

private static final int RAND_PART_C_STATE
See Also:
Constant Field Values

NO_RAND_PART_A_STATE

private static final int NO_RAND_PART_A_STATE
See Also:
Constant Field Values

NO_RAND_PART_B_STATE

private static final int NO_RAND_PART_B_STATE
See Also:
Constant Field Values

NO_RAND_PART_C_STATE

private static final int NO_RAND_PART_C_STATE
See Also:
Constant Field Values

m_crc

private CRC m_crc

m_inUse

private boolean[] m_inUse

m_seqToUnseq

private char[] m_seqToUnseq

m_unseqToSeq

private char[] m_unseqToSeq

m_selector

private char[] m_selector

m_selectorMtf

private char[] m_selectorMtf

m_unzftab

private int[] m_unzftab

m_limit

private int[][] m_limit

m_base

private int[][] m_base

m_perm

private int[][] m_perm

m_minLens

private int[] m_minLens

m_streamEnd

private boolean m_streamEnd

m_currentChar

private int m_currentChar

m_currentState

private int m_currentState

m_rNToGo

private int m_rNToGo

m_rTPos

private int m_rTPos

m_tPos

private int m_tPos

i2

private int i2

count

private int count

chPrev

private int chPrev

ch2

private int ch2

j2

private int j2

z

private char z

m_blockRandomised

private boolean m_blockRandomised

m_blockSize100k

private int m_blockSize100k

m_bsBuff

private int m_bsBuff

m_bsLive

private int m_bsLive

m_input

private java.io.InputStream m_input

m_computedBlockCRC

private int m_computedBlockCRC

m_computedCombinedCRC

private int m_computedCombinedCRC

m_last

private int m_last

m_ll8

private char[] m_ll8

m_nInUse

private int m_nInUse

m_origPtr

private int m_origPtr

m_storedBlockCRC

private int m_storedBlockCRC

m_storedCombinedCRC

private int m_storedCombinedCRC

m_tt

private int[] m_tt
Constructor Detail

CBZip2InputStream

CBZip2InputStream(java.io.InputStream input)
Method Detail

badBlockHeader

private static void badBlockHeader()

blockOverrun

private static void blockOverrun()

cadvise

private static void cadvise()

compressedStreamEOF

private static void compressedStreamEOF()

crcError

private static void crcError()

available

public int available()
              throws java.io.IOException
a fake available 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.

Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException

read

public int read()
Specified by:
read in class java.io.InputStream

setDecompressStructureSizes

private void setDecompressStructureSizes(int newSize100k)

setupBlock

private void setupBlock()

setupNoRandPartA

private void setupNoRandPartA()

setupNoRandPartB

private void setupNoRandPartB()

setupNoRandPartC

private void setupNoRandPartC()

setupRandPartA

private void setupRandPartA()

setupRandPartB

private void setupRandPartB()

setupRandPartC

private void setupRandPartC()

getAndMoveToFrontDecode

private void getAndMoveToFrontDecode()

bsFinishedWithStream

private void bsFinishedWithStream()

readVariableSizedInt

private int readVariableSizedInt(int numBits)

readUnsignedChar

private char readUnsignedChar()

readInt

private int readInt()

bsR

private int bsR(int n)

bsSetStream

private void bsSetStream(java.io.InputStream input)

complete

private void complete()

endBlock

private void endBlock()

hbCreateDecodeTables

private void hbCreateDecodeTables(int[] limit,
                                  int[] base,
                                  int[] perm,
                                  char[] length,
                                  int minLen,
                                  int maxLen,
                                  int alphaSize)

initBlock

private void initBlock()

initialize

private void initialize()

makeMaps

private void makeMaps()

recvDecodingTables

private void recvDecodingTables()

buildInUseTable

private void buildInUseTable()

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException