org.bouncycastle.openpgp

Class PGPCompressedDataGenerator

Implemented Interfaces:
CompressionAlgorithmTags, org.bouncycastle.openpgp.StreamGenerator

public class PGPCompressedDataGenerator
extends java.lang.Object
implements CompressionAlgorithmTags, org.bouncycastle.openpgp.StreamGenerator

class for producing compressed data packets.

Fields inherited from interface org.bouncycastle.bcpg.CompressionAlgorithmTags

BZIP2, UNCOMPRESSED, ZIP, ZLIB

Constructor Summary

PGPCompressedDataGenerator(int algorithm)
PGPCompressedDataGenerator(int algorithm, int compression)

Method Summary

void
close()
Close the compressed object - this is equivalent to calling close on the stream returned by the open() method.
OutputStream
open(OutputStream out)
Return an outputstream which will save the data being written to the compressed object.
OutputStream
open(OutputStream out, byte[] buffer)
Return an outputstream which will compress the data as it is written to it.

Constructor Details

PGPCompressedDataGenerator

public PGPCompressedDataGenerator(int algorithm)

PGPCompressedDataGenerator

public PGPCompressedDataGenerator(int algorithm,
                                  int compression)

Method Details

close

public void close()
            throws IOException
Close the compressed object - this is equivalent to calling close on the stream returned by the open() method.
Specified by:
close in interface org.bouncycastle.openpgp.StreamGenerator

open

public OutputStream open(OutputStream out)
            throws IOException
Return an outputstream which will save the data being written to the compressed object.

The stream created can be closed off by either calling close() on the stream or close() on the generator. Closing the returned stream does not close off the OutputStream parameter out.

Parameters:
out - underlying OutputStream to be used.
Returns:
OutputStream

open

public OutputStream open(OutputStream out,
                         byte[] buffer)
            throws IOException,
                   PGPException
Return an outputstream which will compress the data as it is written to it. The stream will be written out in chunks according to the size of the passed in buffer.

The stream created can be closed off by either calling close() on the stream or close() on the generator. Closing the returned stream does not close off the OutputStream parameter out.

Note: if the buffer is not a power of 2 in length only the largest power of 2 bytes worth of the buffer will be used.

Note: using this may break compatability with RFC 1991 compliant tools. Only recent OpenPGP implementations are capable of accepting these streams.

Parameters:
out - underlying OutputStream to be used.
buffer - the buffer to use.
Returns:
OutputStream
Throws:
PGPException -