org.codehaus.plexus.archiver.bzip2
Class CBZip2OutputStream

java.lang.Object
  extended byjava.io.OutputStream
      extended byorg.codehaus.plexus.archiver.bzip2.CBZip2OutputStream
All Implemented Interfaces:
BZip2Constants

public 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

Version:
$Revision: 2436 $ $Date: 2005-09-01 19:20:41 +0200 (Thu, 01 Sep 2005) $ from org.apache.ant.tools.bzip2.CBZip2OutputStream v1.22

Nested Class Summary
private static class CBZip2OutputStream.StackElem
           
 
Field Summary
private  int allowableBlockSize
           
private  char[] block
           
private  int blockCRC
           
(package private)  boolean blockRandomised
           
(package private)  int blockSize100k
           
(package private)  int bsBuff
           
(package private)  int bsLive
           
private  java.io.OutputStream bsStream
           
(package private)  int bytesOut
           
protected static int CLEARMASK
           
(package private)  boolean closed
           
private  int combinedCRC
           
private  int currentChar
           
protected static int DEPTH_THRESH
           
private  boolean firstAttempt
           
private  int[] ftab
           
protected static int GREATER_ICOST
           
private  int[] incs
           
private  boolean[] inUse
           
(package private)  int last
           
protected static int LESSER_ICOST
           
(package private)  CRC mCrc
           
private  int[] mtfFreq
           
private  int nBlocksRandomised
           
private  int nInUse
           
private  int nMTF
           
(package private)  int origPtr
           
protected static int QSORT_STACK_SIZE
           
private  int[] quadrant
           
private  int runLength
           
private  char[] selector
           
private  char[] selectorMtf
           
private  char[] seqToUnseq
           
protected static int SETMASK
           
protected static int SMALL_THRESH
           
private  short[] szptr
           
private  char[] unseqToSeq
           
private  int workDone
           
private  int workFactor
           
private  int workLimit
           
private  int[] zptr
           
 
Fields inherited from interface org.codehaus.plexus.archiver.bzip2.BZip2Constants
baseBlockSize, G_SIZE, MAX_ALPHA_SIZE, MAX_CODE_LEN, MAX_SELECTORS, N_GROUPS, N_ITERS, NUM_OVERSHOOT_BYTES, rNums, RUNA, RUNB
 
Constructor Summary
CBZip2OutputStream(java.io.OutputStream inStream)
           
CBZip2OutputStream(java.io.OutputStream inStream, int inBlockSize)
           
 
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)
           
 void close()
           
private  void doReversibleTransformation()
           
private  void endBlock()
           
private  void endCompression()
           
protected  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)
           
protected 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

SETMASK

protected static final int SETMASK
See Also:
Constant Field Values

CLEARMASK

protected static final int CLEARMASK
See Also:
Constant Field Values

GREATER_ICOST

protected static final int GREATER_ICOST
See Also:
Constant Field Values

LESSER_ICOST

protected static final int LESSER_ICOST
See Also:
Constant Field Values

SMALL_THRESH

protected static final int SMALL_THRESH
See Also:
Constant Field Values

DEPTH_THRESH

protected static final int DEPTH_THRESH
See Also:
Constant Field Values

QSORT_STACK_SIZE

protected static final int QSORT_STACK_SIZE
See Also:
Constant Field Values

last

int last

origPtr

int origPtr

blockSize100k

int blockSize100k

blockRandomised

boolean blockRandomised

bytesOut

int bytesOut

bsBuff

int bsBuff

bsLive

int bsLive

mCrc

CRC mCrc

inUse

private boolean[] inUse

nInUse

private int nInUse

seqToUnseq

private char[] seqToUnseq

unseqToSeq

private char[] unseqToSeq

selector

private char[] selector

selectorMtf

private char[] selectorMtf

block

private char[] block

quadrant

private int[] quadrant

zptr

private int[] zptr

szptr

private short[] szptr

ftab

private int[] ftab

nMTF

private int nMTF

mtfFreq

private int[] mtfFreq

workFactor

private int workFactor

workDone

private int workDone

workLimit

private int workLimit

firstAttempt

private boolean firstAttempt

nBlocksRandomised

private int nBlocksRandomised

currentChar

private int currentChar

runLength

private int runLength

closed

boolean closed

blockCRC

private int blockCRC

combinedCRC

private int combinedCRC

allowableBlockSize

private int allowableBlockSize

bsStream

private java.io.OutputStream bsStream

incs

private int[] incs
Constructor Detail

CBZip2OutputStream

public CBZip2OutputStream(java.io.OutputStream inStream)
                   throws java.io.IOException

CBZip2OutputStream

public CBZip2OutputStream(java.io.OutputStream inStream,
                          int inBlockSize)
                   throws java.io.IOException
Method Detail

panic

private static void panic()

makeMaps

private void makeMaps()

hbMakeCodeLengths

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

write

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

Throws:
java.io.IOException

writeRun

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

finalize

protected void finalize()
                 throws java.lang.Throwable
Throws:
java.lang.Throwable

close

public void close()
           throws java.io.IOException
Throws:
java.io.IOException

flush

public void flush()
           throws java.io.IOException
Throws:
java.io.IOException

initialize

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

initBlock

private void initBlock()

endBlock

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

endCompression

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

hbAssignCodes

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

bsSetStream

private void bsSetStream(java.io.OutputStream f)

bsFinishedWithStream

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

bsW

private void bsW(int n,
                 int v)
          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

bsPutIntVS

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

sendMTFValues

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

moveToFrontCodeAndSend

private void moveToFrontCodeAndSend()
                             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)

med3

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

qSort3

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

mainSort

private void mainSort()

randomiseBlock

private void randomiseBlock()

doReversibleTransformation

private void doReversibleTransformation()

fullGtU

private boolean fullGtU(int i1,
                        int i2)

allocateCompressStructures

private void allocateCompressStructures()

generateMTFValues

private void generateMTFValues()