org.codehaus.plexus.archiver.bzip2

Class CBZip2OutputStream

Implemented Interfaces:
BZip2Constants

public class CBZip2OutputStream
extends 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 13:20:41 -0400 (Thu, 01 Sep 2005) $ from org.apache.ant.tools.bzip2.CBZip2OutputStream v1.22

Nested Class Summary

private static class
CBZip2OutputStream.StackElem

Field Summary

protected static int
CLEARMASK
protected static int
DEPTH_THRESH
protected static int
GREATER_ICOST
protected static int
LESSER_ICOST
protected static int
QSORT_STACK_SIZE
protected static int
SETMASK
protected static int
SMALL_THRESH
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 OutputStream
bsStream
(package private) int
bytesOut
(package private) boolean
closed
private int
combinedCRC
private int
currentChar
private boolean
firstAttempt
private int[]
ftab
private boolean[]
inUse
private int[]
incs
(package private) int
last
(package private) CRC
mCrc
private int[]
mtfFreq
private int
nBlocksRandomised
private int
nInUse
private int
nMTF
(package private) int
origPtr
private int[]
quadrant
private int
runLength
private char[]
selector
private char[]
selectorMtf
private char[]
seqToUnseq
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

G_SIZE, MAX_ALPHA_SIZE, MAX_CODE_LEN, MAX_SELECTORS, NUM_OVERSHOOT_BYTES, N_GROUPS, N_ITERS, RUNA, RUNB, baseBlockSize, rNums

Constructor Summary

CBZip2OutputStream(OutputStream inStream)
CBZip2OutputStream(OutputStream inStream, int inBlockSize)

Method Summary

private void
allocateCompressStructures()
private void
bsFinishedWithStream()
private void
bsPutIntVS(int numBits, int c)
private void
bsPutUChar(int c)
private void
bsPutint(int u)
private void
bsSetStream(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()

Field Details

CLEARMASK

protected static final int CLEARMASK
Field Value:
-2097153

DEPTH_THRESH

protected static final int DEPTH_THRESH
Field Value:
10

GREATER_ICOST

protected static final int GREATER_ICOST
Field Value:
15

LESSER_ICOST

protected static final int LESSER_ICOST
Field Value:
0

QSORT_STACK_SIZE

protected static final int QSORT_STACK_SIZE
Field Value:
1000

SETMASK

protected static final int SETMASK
Field Value:
2097152

SMALL_THRESH

protected static final int SMALL_THRESH
Field Value:
20

allowableBlockSize

private int allowableBlockSize

block

private char[] block

blockCRC

private int blockCRC

blockRandomised

(package private)  boolean blockRandomised

blockSize100k

(package private)  int blockSize100k

bsBuff

(package private)  int bsBuff

bsLive

(package private)  int bsLive

bsStream

private OutputStream bsStream

bytesOut

(package private)  int bytesOut

closed

(package private)  boolean closed

combinedCRC

private int combinedCRC

currentChar

private int currentChar

firstAttempt

private boolean firstAttempt

ftab

private int[] ftab

inUse

private boolean[] inUse

incs

private int[] incs

last

(package private)  int last

mCrc

(package private)  CRC mCrc

mtfFreq

private int[] mtfFreq

nBlocksRandomised

private int nBlocksRandomised

nInUse

private int nInUse

nMTF

private int nMTF

origPtr

(package private)  int origPtr

quadrant

private int[] quadrant

runLength

private int runLength

selector

private char[] selector

selectorMtf

private char[] selectorMtf

seqToUnseq

private char[] seqToUnseq

szptr

private short[] szptr

unseqToSeq

private char[] unseqToSeq

workDone

private int workDone

workFactor

private int workFactor

workLimit

private int workLimit

zptr

private int[] zptr

Constructor Details

CBZip2OutputStream

public CBZip2OutputStream(OutputStream inStream)
            throws IOException

CBZip2OutputStream

public CBZip2OutputStream(OutputStream inStream,
                          int inBlockSize)
            throws IOException

Method Details

allocateCompressStructures

private void allocateCompressStructures()

bsFinishedWithStream

private void bsFinishedWithStream()
            throws IOException

bsPutIntVS

private void bsPutIntVS(int numBits,
                        int c)
            throws IOException

bsPutUChar

private void bsPutUChar(int c)
            throws IOException

bsPutint

private void bsPutint(int u)
            throws IOException

bsSetStream

private void bsSetStream(OutputStream f)

bsW

private void bsW(int n,
                 int v)
            throws IOException

close

public void close()
            throws IOException

doReversibleTransformation

private void doReversibleTransformation()

endBlock

private void endBlock()
            throws IOException

endCompression

private void endCompression()
            throws IOException

finalize

protected void finalize()
            throws Throwable

flush

public void flush()
            throws 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)

hbMakeCodeLengths

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

initBlock

private void initBlock()

initialize

private void initialize()
            throws IOException

mainSort

private void mainSort()

makeMaps

private void makeMaps()

med3

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

moveToFrontCodeAndSend

private void moveToFrontCodeAndSend()
            throws IOException

panic

private static void panic()

qSort3

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

randomiseBlock

private void randomiseBlock()

sendMTFValues

private void sendMTFValues()
            throws IOException

simpleSort

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

vswap

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

write

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

writeRun

private void writeRun()
            throws IOException