Top Description Inners Fields Constructors Methods
org.bouncycastle.apache.bzip2

public Class CBZip2OutputStream

extends OutputStream
implements BZip2Constants
Class Inheritance
All Implemented Interfaces
org.bouncycastle.apache.bzip2.BZip2Constants
Known Direct Subclasses
org.bouncycastle.openpgp.PGPCompressedDataGenerator.SafeCBZip2OutputStream
Imports
java.io.IOException, .OutputStream, java.util.Vector, org.bouncycastle.util.Arrays, .Integers

An output stream that compresses into the BZip2 format (with the file header chars) into another stream.
Author
Keiron Liddle

TODO: Update to BZip2 1.0.1 NB: note this class has been modified to add a leading BZ to the start of the BZIP2 stream to make it compatible with other PGP programs.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final int
private byte[]
private final CRC
pack-priv boolean
private final int
private final Vector<E>
pack-priv int
pack-priv int
private OutputStream
protected static final int
pack-priv boolean
pack-priv int
private int
protected static final int
private boolean
private boolean
private int[]
protected static final int
private static final int[]
private boolean[]
protected static final int
private int[]
private int
private int
pack-priv int
private short[]
pack-priv static final short[]
private int
private byte[]
protected static final int
protected static final int
private int
private int[]
private int
private int
private int
private int[]

Constructor Summary

AccessConstructor and Description
public
public
CBZip2OutputStream(OutputStream outStream, int blockSize)

Method Summary

Modifier and TypeMethod and Description
private void
private void
bsPutBit(int v)

private void
bsPutBits(int n, int v)

private void
bsPutBitsSmall(int n, int v)

private void
bsPutInt32(int u)

private void
bsPutLong48(long u)

public void
close()

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Closes this output stream and releases any system resources associated with this stream.
private void
private void
private void
protected void
finalize()

Overrides java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
public void
public void
flush()

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Flushes this output stream and forces any buffered output bytes to be written out.
private boolean
fullGtU(int i1, int i2)

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

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

private void
private void
private int
med3(int a, int b, int c)

private void
private static void
pushStackElem(Vector<E> stack, int stackCount, int ll, int hh, int dd)

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

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

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

public void
write(int
the byte.
bv
)

Implements abstract java.io.OutputStream.write.

modified by Oliver Merkel, 010128
private void
Inherited from java.io.OutputStream:
nullOutputStreamwritewrite

Field Detail

allowableBlockSizeback to summary
private final int allowableBlockSize
blockBytesback to summary
private byte[] blockBytes
blockCRCback to summary
private final CRC blockCRC
blockRandomisedback to summary
pack-priv boolean blockRandomised
blockSize100kback to summary
private final int blockSize100k
blocksortStackback to summary
private final Vector<E> blocksortStack
bsBuffback to summary
pack-priv int bsBuff
bsLivePosback to summary
pack-priv int bsLivePos
bsStreamback to summary
private OutputStream bsStream
CLEARMASKback to summary
protected static final int CLEARMASK
closedback to summary
pack-priv boolean closed
countback to summary
pack-priv int count
currentByteback to summary
private int currentByte
DEPTH_THRESHback to summary
protected static final int DEPTH_THRESH
finishedback to summary
private boolean finished
firstAttemptback to summary
private boolean firstAttempt
ftabback to summary
private int[] ftab
GREATER_ICOSTback to summary
protected static final int GREATER_ICOST
INCSback to summary
private static final int[] INCS
inUseback to summary
private boolean[] inUse
LESSER_ICOSTback to summary
protected static final int LESSER_ICOST
mtfFreqback to summary
private int[] mtfFreq
nInUseback to summary
private int nInUse
nMTFback to summary
private int nMTF
origPtrback to summary
pack-priv int origPtr
quadrantShortsback to summary
private short[] quadrantShorts
R_NUMSback to summary
pack-priv static final short[] R_NUMS
runLengthback to summary
private int runLength
selectorsback to summary
private byte[] selectors
SETMASKback to summary
protected static final int SETMASK
SMALL_THRESHback to summary
protected static final int SMALL_THRESH
streamCRCback to summary
private int streamCRC
szptrback to summary
private int[] szptr
workDoneback to summary
private int workDone
workFactorback to summary
private int workFactor
workLimitback to summary
private int workLimit
zptrback to summary
private int[] zptr

Constructor Detail

CBZip2OutputStreamback to summary
public CBZip2OutputStream(OutputStream outStream) throws IOException
CBZip2OutputStreamback to summary
public CBZip2OutputStream(OutputStream outStream, int blockSize) throws IOException

Method Detail

bsFinishedWithStreamback to summary
private void bsFinishedWithStream() throws IOException
bsPutBitback to summary
private void bsPutBit(int v) throws IOException
bsPutBitsback to summary
private void bsPutBits(int n, int v) throws IOException
bsPutBitsSmallback to summary
private void bsPutBitsSmall(int n, int v) throws IOException
bsPutInt32back to summary
private void bsPutInt32(int u) throws IOException
bsPutLong48back to summary
private void bsPutLong48(long u) throws IOException
closeback to summary
public void close() throws IOException

Overrides java.io.OutputStream.close.

Implements java.io.Closeable.close.

Doc from java.io.OutputStream.close.

Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.

Exceptions
IOException:
if an I/O error occurs.
doReversibleTransformationback to summary
private void doReversibleTransformation()
endBlockback to summary
private void endBlock() throws IOException
endCompressionback to summary
private void endCompression() throws IOException
finalizeback to summary
protected void finalize() throws Throwable

Overrides java.lang.Object.finalize.

Doc from java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

When running in a Java virtual machine in which finalization has been disabled or removed, the garbage collector will never call finalize(). In a Java virtual machine in which finalization is enabled, the garbage collector might call finalize only after an indefinite delay.

The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Exceptions
Throwable:
the Exception raised by this method
finishback to summary
public void finish() throws IOException
flushback to summary
public void flush() throws IOException

Overrides java.io.OutputStream.flush.

Implements java.io.Flushable.flush.

Doc from java.io.OutputStream.flush.

Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.

If the intended destination of this stream is an abstraction provided by the underlying operating system, for example a file, then flushing the stream guarantees only that bytes previously written to the stream are passed to the operating system for writing; it does not guarantee that they are actually written to a physical device such as a disk drive.

Exceptions
IOException:
if an I/O error occurs.
fullGtUback to summary
private boolean fullGtU(int i1, int i2)
generateMTFValuesback to summary
private void generateMTFValues()
hbAssignCodesback to summary
private void hbAssignCodes(int[] code, byte[] length, int minLen, int maxLen, int alphaSize)
hbMakeCodeLengthsback to summary
protected static void hbMakeCodeLengths(byte[] len, int[] freq, int alphaSize, int maxLen)
initBlockback to summary
private void initBlock()
mainSortback to summary
private void mainSort()
med3back to summary
private int med3(int a, int b, int c)
moveToFrontCodeAndSendback to summary
private void moveToFrontCodeAndSend() throws IOException
pushStackElemback to summary
private static void pushStackElem(Vector<E> stack, int stackCount, int ll, int hh, int dd)
qSort3back to summary
private void qSort3(int loSt, int hiSt, int dSt)
randomiseBlockback to summary
private void randomiseBlock()
sendMTFValuesback to summary
private void sendMTFValues() throws IOException
simpleSortback to summary
private void simpleSort(int lo, int hi, int d)
vswapback to summary
private void vswap(int p1, int p2, int n)
writeback to summary
public void write(int bv) throws IOException

Implements abstract java.io.OutputStream.write.

modified by Oliver Merkel, 010128

Parameters
bv:int

Doc from java.io.OutputStream.write.

the byte.

Exceptions
IOException:

Doc from java.io.OutputStream.write.

if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.

writeRunback to summary
private void writeRun() throws IOException
org.bouncycastle.apache.bzip2 back to summary

private Class CBZip2OutputStream.StackElem

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv int
pack-priv int

Constructor Summary

AccessConstructor and Description
private

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ddback to summary
pack-priv int dd
hhback to summary
pack-priv int hh
llback to summary
pack-priv int ll

Constructor Detail

StackElemback to summary
private StackElem()