public class BZip2CompressionMethod extends Object implements ZipEntryCompressionMethod, ZipEntryCompressionMethodFactory
This class cannot be instantiated. Use the singleton instance
INSTANCE
instead.
Modifier and Type | Field and Description |
---|---|
static UnsignedShort |
CODE
The unique code for this compression method.
|
static BZip2CompressionMethod |
INSTANCE
Singleton instance.
|
static String |
NAME |
static UnsignedShort |
VERSION_NEEDED_TO_EXTRACT
The PK-Zip version needed to extract entries compressed with this
compression method.
|
Constructor and Description |
---|
BZip2CompressionMethod()
This creates a bzip2 compression method that will use the default block
size (900k) for compression.
|
BZip2CompressionMethod(CompressionLevel level)
Create a bzip2 compression method that will have the supplied compression
level.
|
BZip2CompressionMethod(int blockSize)
Create a bzip2 compression method that will use the supplied block size.
|
Modifier and Type | Method and Description |
---|---|
BZip2CompressionMethod |
create(ZipGeneralPurposeBitFlags gbBitFlags)
Create a compression method instance.
|
InputStream |
createInputStream(InputStream is,
long compressedSize,
long uncompressedSize)
Create an
InputStream that clients can use to read uncompressed
file data from. |
OutputStream |
createOutputStream(OutputStream os)
Create an
OutputStream that compresses the data written to it and
writes it to the wrapped output stream. |
org.entityfs.RandomAccess |
createRandomAccess(org.entityfs.RandomAccess ra,
long compressedSize,
long uncompressedSize)
This method always throws an
UnsupportedOperationException . |
ZipEntryCompressionMethod |
createWithCompressionLevel(CompressionLevel level)
Create a new
ZipEntryCompressionMethod object that will have the
supplied compression level. |
UnsignedShort |
getCode()
Get the unique code that is used to identify this compression method in a
Zip entry's header.
|
String |
getName()
Get a human-readable name for the compression method.
|
UnsignedShort |
getVersionNeededToExtract()
Get the PK-Zip version needed to extract Zip entries compressed by this
compression method.
|
boolean |
isRandomAccessSupported()
This method always returns
false |
String |
toString() |
public static final UnsignedShort CODE
public static final String NAME
public static final UnsignedShort VERSION_NEEDED_TO_EXTRACT
ZipEntryCompressionMethod.getVersionNeededToExtract()
.public static final BZip2CompressionMethod INSTANCE
public BZip2CompressionMethod()
Instead of calling this constructor, consider using the singleton
instance INSTANCE
instead.
public BZip2CompressionMethod(int blockSize) throws IllegalArgumentException
blockSize
- The block size in hundreds of kilobytes. This number
must be between 1 and 9 (inclusive).IllegalArgumentException
- If the block size is not in the range
1 <= blockSize <= 9
.public BZip2CompressionMethod(CompressionLevel level)
level
- The compression level.public UnsignedShort getCode()
ZipEntryCompressionMethod
getCode
in interface ZipEntryCompressionMethod
getCode
in interface ZipEntryCompressionMethodFactory
public String getName()
ZipEntryCompressionMethod
getName
in interface ZipEntryCompressionMethod
public UnsignedShort getVersionNeededToExtract()
ZipEntryCompressionMethod
getVersionNeededToExtract
in interface ZipEntryCompressionMethod
UnsignedShort
representing the version number. 10
corresponds to version 1.0, 62
to 6.2, etc.public InputStream createInputStream(InputStream is, long compressedSize, long uncompressedSize) throws IOException
ZipEntryCompressionMethod
InputStream
that clients can use to read uncompressed
file data from.createInputStream
in interface ZipEntryCompressionMethod
is
- An open InputStream
on the compressed file data.compressedSize
- The total size of the compressed data.uncompressedSize
- The total size of the uncompressed data.InputStream
containing uncompressed file data.IOException
- On I/O errors.public OutputStream createOutputStream(OutputStream os) throws IOException, UnsupportedCompressionMethodException
ZipEntryCompressionMethod
OutputStream
that compresses the data written to it and
writes it to the wrapped output stream. This is used when building Zip
files.createOutputStream
in interface ZipEntryCompressionMethod
os
- The wrapped output stream.IOException
- On I/O errors.UnsupportedCompressionMethodException
- If the compression method
is not supported.public BZip2CompressionMethod create(ZipGeneralPurposeBitFlags gbBitFlags)
ZipEntryCompressionMethodFactory
create
in interface ZipEntryCompressionMethodFactory
gbBitFlags
- The Zip entry's general purpose bit flags. They may
contain compression algorithm parameters.public org.entityfs.RandomAccess createRandomAccess(org.entityfs.RandomAccess ra, long compressedSize, long uncompressedSize) throws UnsupportedOperationException
UnsupportedOperationException
.createRandomAccess
in interface ZipEntryCompressionMethod
ra
- An open random access object on the file entry's data.compressedSize
- The total size of the compressed data.uncompressedSize
- The total size of the uncompressed data.RandomAccess
that can be used to read
uncompressed data.UnsupportedOperationException
- Always.public boolean isRandomAccessSupported()
false
isRandomAccessSupported
in interface ZipEntryCompressionMethod
false
, always.public ZipEntryCompressionMethod createWithCompressionLevel(CompressionLevel level)
ZipEntryCompressionMethod
ZipEntryCompressionMethod
object that will have the
supplied compression level.
The reason for this method is that it makes it easier to set a custom compression level for a compression method, without having to create a new compression method object from scratch manually.
createWithCompressionLevel
in interface ZipEntryCompressionMethod
level
- The compression level.this
since ZipEntryCompressionMethod
objects are
immutable.