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

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

 class CBZip2OutputStream
extends java.io.OutputStream
implements BZip2Constants

An output stream that compresses into the BZip2 format (without the file header chars) into another stream. TODO: Update to BZip2 1.0.1

Author:
Keiron Liddle

Nested Class Summary
private static class CBZip2OutputStream.StackElem
           
 
Field Summary
private static int CLEARMASK
           
private static int DEPTH_THRESH
           
private static int GREATER_ICOST
           
private static int LESSER_ICOST
           
private static int LOWER_BYTE_MASK
           
private  int m_allowableBlockSize
           
private  char[] m_block
           
private  int m_blockCRC
           
private  boolean m_blockRandomised
           
private  int m_blockSize100k
           
private  int m_bsBuff
           
private  int m_bsLive
           
private  java.io.OutputStream m_bsStream
           
private  boolean m_closed
           
private  int m_combinedCRC
           
private  CRC m_crc
           
private  int m_currentChar
           
private  boolean m_firstAttempt
           
private  int[] m_ftab
           
private  int[] m_incs
           
private  boolean[] m_inUse
           
private  int m_last
           
private  int[] m_mtfFreq
           
private  int m_nInUse
           
private  int m_nMTF
           
private  int m_origPtr
           
private  int[] m_quadrant
           
private  int m_runLength
           
private  char[] m_selector
           
private  char[] m_selectorMtf
           
private  char[] m_seqToUnseq
           
private  short[] m_szptr
           
private  char[] m_unseqToSeq
           
private  int m_workDone
           
private  int m_workFactor
           
private  int m_workLimit
           
private  int[] m_zptr
           
private static int QSORT_STACK_SIZE
           
private static int SETMASK
           
private static int SMALL_THRESH
           
private static int UPPER_BYTE_MASK
           
 
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
CBZip2OutputStream(java.io.OutputStream output)
           
CBZip2OutputStream(java.io.OutputStream output, int blockSize)
           
 
Method Summary
private  void allocateCompressStructures()
           
private  void bsFinishedWithStream()
           
private  void bsPutint(int u)
           
private  void bsPutIntVS(int numBits, int c)
           
private  void bsPutUChar(int c)
           
private  void bsSetStream(java.io.OutputStream f)
           
private  void bsW(int n, int v)
           
private static int calculateWeight(int v1, int v2)
           
 void close()
           
private  void doReversibleTransformation()
           
private  void endBlock()
           
private  void endCompression()
           
 void finalize()
           
 void flush()
           
private  boolean fullGtU(int i1, int i2)
           
private  void generateMTFValues()
           
private  void hbAssignCodes(int[] code, char[] length, int minLen, int maxLen, int alphaSize)
           
private static void hbMakeCodeLengths(char[] len, int[] freq, int alphaSize, int maxLen)
           
private  void initBlock()
           
private  void initialize()
           
private  void mainSort()
           
private  void makeMaps()
           
private  char med3(char a, char b, char c)
           
private  void moveToFrontCodeAndSend()
           
private static void panic()
           
private  void qSort3(int loSt, int hiSt, int dSt)
           
private  void randomiseBlock()
           
private  void sendMTFValues()
           
private  void simpleSort(int lo, int hi, int d)
           
private  void vswap(int p1, int p2, int n)
           
 void write(int bv)
          modified by Oliver Merkel, 010128
private  void writeRun()
           
 
Methods inherited from class java.io.OutputStream
write, write
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOWER_BYTE_MASK

private static final int LOWER_BYTE_MASK
See Also:
Constant Field Values

UPPER_BYTE_MASK

private static final int UPPER_BYTE_MASK
See Also:
Constant Field Values

SETMASK

private static final int SETMASK
See Also:
Constant Field Values

CLEARMASK

private static final int CLEARMASK
See Also:
Constant Field Values

GREATER_ICOST

private static final int GREATER_ICOST
See Also:
Constant Field Values

LESSER_ICOST

private static final int LESSER_ICOST
See Also:
Constant Field Values

SMALL_THRESH

private static final int SMALL_THRESH
See Also:
Constant Field Values

DEPTH_THRESH

private static final int DEPTH_THRESH
See Also:
Constant Field Values

QSORT_STACK_SIZE

private static final int QSORT_STACK_SIZE
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_mtfFreq

private int[] m_mtfFreq

m_currentChar

private int m_currentChar

m_runLength

private int m_runLength

m_closed

private boolean m_closed

m_incs

private int[] m_incs

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_last

private int m_last

m_origPtr

private int m_origPtr

m_allowableBlockSize

private int m_allowableBlockSize

m_block

private char[] m_block

m_blockCRC

private int m_blockCRC

m_combinedCRC

private int m_combinedCRC

m_bsStream

private java.io.OutputStream m_bsStream

m_firstAttempt

private boolean m_firstAttempt

m_ftab

private int[] m_ftab

m_nInUse

private int m_nInUse

m_nMTF

private int m_nMTF

m_quadrant

private int[] m_quadrant

m_szptr

private short[] m_szptr

m_workDone

private int m_workDone

m_workFactor

private int m_workFactor

m_workLimit

private int m_workLimit

m_zptr

private int[] m_zptr
Constructor Detail

CBZip2OutputStream

CBZip2OutputStream(java.io.OutputStream output)
             throws java.io.IOException
Throws:
java.io.IOException

CBZip2OutputStream

CBZip2OutputStream(java.io.OutputStream output,
                   int blockSize)
             throws java.io.IOException
Throws:
java.io.IOException
Method Detail

hbMakeCodeLengths

private static void hbMakeCodeLengths(char[] len,
                                      int[] freq,
                                      int alphaSize,
                                      int maxLen)

calculateWeight

private static int calculateWeight(int v1,
                                   int v2)

panic

private static void panic()

close

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

finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

flush

public void flush()
           throws java.io.IOException
Specified by:
flush in interface java.io.Flushable
Overrides:
flush in class java.io.OutputStream
Throws:
java.io.IOException

write

public void write(int bv)
           throws java.io.IOException
modified by Oliver Merkel, 010128

Specified by:
write in class java.io.OutputStream
Parameters:
bv - Description of Parameter
Throws:
java.io.IOException - Description of Exception

allocateCompressStructures

private void allocateCompressStructures()

bsFinishedWithStream

private void bsFinishedWithStream()
                           throws java.io.IOException
Throws:
java.io.IOException

bsPutIntVS

private void bsPutIntVS(int numBits,
                        int c)
                 throws java.io.IOException
Throws:
java.io.IOException

bsPutUChar

private void bsPutUChar(int c)
                 throws java.io.IOException
Throws:
java.io.IOException

bsPutint

private void bsPutint(int u)
               throws java.io.IOException
Throws:
java.io.IOException

bsSetStream

private void bsSetStream(java.io.OutputStream f)

bsW

private void bsW(int n,
                 int v)
          throws java.io.IOException
Throws:
java.io.IOException

doReversibleTransformation

private void doReversibleTransformation()

endBlock

private void endBlock()
               throws java.io.IOException
Throws:
java.io.IOException

endCompression

private void endCompression()
                     throws java.io.IOException
Throws:
java.io.IOException

fullGtU

private boolean fullGtU(int i1,
                        int i2)

generateMTFValues

private void generateMTFValues()

hbAssignCodes

private void hbAssignCodes(int[] code,
                           char[] length,
                           int minLen,
                           int maxLen,
                           int alphaSize)

initBlock

private void initBlock()

initialize

private void initialize()
                 throws java.io.IOException
Throws:
java.io.IOException

mainSort

private void mainSort()

makeMaps

private void makeMaps()

med3

private char med3(char a,
                  char b,
                  char c)

moveToFrontCodeAndSend

private void moveToFrontCodeAndSend()
                             throws java.io.IOException
Throws:
java.io.IOException

qSort3

private void qSort3(int loSt,
                    int hiSt,
                    int dSt)

randomiseBlock

private void randomiseBlock()

sendMTFValues

private void sendMTFValues()
                    throws java.io.IOException
Throws:
java.io.IOException

simpleSort

private void simpleSort(int lo,
                        int hi,
                        int d)

vswap

private void vswap(int p1,
                   int p2,
                   int n)

writeRun

private void writeRun()
               throws java.io.IOException
Throws:
java.io.IOException