Class BZip2CompressorInputStream
java.lang.Object
java.io.InputStream
org.apache.commons.compress.compressors.CompressorInputStream
org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable,BZip2Constants,InputStreamStatistics
public class BZip2CompressorInputStream
extends CompressorInputStream
implements BZip2Constants, InputStreamStatistics
An input stream that decompresses from the BZip2 format to be read as any other stream.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate BitInputStreamprivate booleanprivate intalways: in the range 0 ..private intprivate final CRCprivate intprivate BZip2CompressorInputStream.DataAll memory intensive stuff.private final booleanprivate static final intprivate intIndex of the last char in the block, so the block size == last + 1.private intprivate static final intprivate static final intprivate static final intprivate intIndex in zptr[] of original string after sorting.private static final intprivate static final intprivate static final intprivate static final intprivate intprivate intprivate intprivate intprivate intprivate intprivate intprivate intprivate intprivate intprivate charFields inherited from interface org.apache.commons.compress.compressors.bzip2.BZip2Constants
BASEBLOCKSIZE, G_SIZE, MAX_ALPHA_SIZE, MAX_CODE_LEN, MAX_SELECTORS, N_GROUPS, N_ITERS, NUM_OVERSHOOT_BYTES, RUNA, RUNB -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream.BZip2CompressorInputStream(InputStream in, boolean decompressConcatenated) Constructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream. -
Method Summary
Modifier and TypeMethodDescriptionprivate static booleanbsGetBit(BitInputStream bin) private static intbsGetInt(BitInputStream bin) private static charbsGetUByte(BitInputStream bin) private static intbsR(BitInputStream bin, int n) read bits from the input streamprivate static voidcheckBounds(int checkVal, int limitExclusive, String name) voidclose()private booleancomplete()private voidcreateHuffmanDecodingTables(int alphaSize, int nGroups) Called by recvDecodingTables() exclusively.private voidendBlock()private voidprivate intlongGets the amount of raw or compressed bytes read by the stream.private static voidhbCreateDecodeTables(int[] limit, int[] base, int[] perm, char[] length, int minLen, int maxLen, int alphaSize) Called by createHuffmanDecodingTables() exclusively.private booleaninit(boolean isFirstStream) private voidprivate voidmakeMaps()static booleanmatches(byte[] signature, int length) Checks if the signature matches what is expected for a bzip2 file.intread()intread(byte[] dest, int offs, int len) private intread0()private intprivate voidprivate intprivate intprivate intprivate intprivate intprivate intprivate intMethods inherited from class org.apache.commons.compress.compressors.CompressorInputStream
count, count, getBytesRead, getCount, getUncompressedCount, pushedBackBytesMethods inherited from class java.io.InputStream
available, mark, markSupported, read, reset, skipMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.commons.compress.utils.InputStreamStatistics
getUncompressedCount
-
Field Details
-
EOF
private static final int EOF- See Also:
-
START_BLOCK_STATE
private static final int START_BLOCK_STATE- See Also:
-
RAND_PART_A_STATE
private static final int RAND_PART_A_STATE- See Also:
-
RAND_PART_B_STATE
private static final int RAND_PART_B_STATE- See Also:
-
RAND_PART_C_STATE
private static final int RAND_PART_C_STATE- See Also:
-
NO_RAND_PART_A_STATE
private static final int NO_RAND_PART_A_STATE- See Also:
-
NO_RAND_PART_B_STATE
private static final int NO_RAND_PART_B_STATE- See Also:
-
NO_RAND_PART_C_STATE
private static final int NO_RAND_PART_C_STATE- See Also:
-
last
private int lastIndex of the last char in the block, so the block size == last + 1. -
origPtr
private int origPtrIndex in zptr[] of original string after sorting. -
blockSize100k
private int blockSize100kalways: in the range 0 .. 9. The current block size is 100000 * this number. -
blockRandomised
private boolean blockRandomised -
crc
-
nInUse
private int nInUse -
bin
-
decompressConcatenated
private final boolean decompressConcatenated -
currentState
private int currentState -
storedBlockCRC
private int storedBlockCRC -
storedCombinedCRC
private int storedCombinedCRC -
computedCombinedCRC
private int computedCombinedCRC -
su_count
private int su_count -
su_ch2
private int su_ch2 -
su_chPrev
private int su_chPrev -
su_i2
private int su_i2 -
su_j2
private int su_j2 -
su_rNToGo
private int su_rNToGo -
su_rTPos
private int su_rTPos -
su_tPos
private int su_tPos -
su_z
private char su_z -
data
All memory intensive stuff. This field is initialized by initBlock().
-
-
Constructor Details
-
BZip2CompressorInputStream
Constructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream. This doesn't support decompressing concatenated .bz2 files.- Parameters:
in- the InputStream from which this object should be created- Throws:
IOException- if the stream content is malformed or an I/O error occurs.NullPointerException- ifin == null
-
BZip2CompressorInputStream
public BZip2CompressorInputStream(InputStream in, boolean decompressConcatenated) throws IOException Constructs a new BZip2CompressorInputStream which decompresses bytes read from the specified stream.- Parameters:
in- the InputStream from which this object should be createddecompressConcatenated- if true, decompress until the end of the input; if false, stop after the first .bz2 stream and leave the input position to point to the next byte after the .bz2 stream- Throws:
IOException- ifin == null, the stream content is malformed, or an I/O error occurs.
-
-
Method Details
-
bsGetBit
- Throws:
IOException
-
bsGetInt
- Throws:
IOException
-
bsGetUByte
- Throws:
IOException
-
bsR
read bits from the input stream- Parameters:
n- the number of bits to read, must not exceed 32?- Returns:
- the requested bits combined into an int
- Throws:
IOException
-
checkBounds
- Throws:
IOException
-
hbCreateDecodeTables
private static void hbCreateDecodeTables(int[] limit, int[] base, int[] perm, char[] length, int minLen, int maxLen, int alphaSize) throws IOException Called by createHuffmanDecodingTables() exclusively.- Throws:
IOException
-
matches
public static boolean matches(byte[] signature, int length) Checks if the signature matches what is expected for a bzip2 file.- Parameters:
signature- the bytes to checklength- the number of bytes to check- Returns:
- true, if this stream is a bzip2 compressed stream, false otherwise
- Since:
- 1.1
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
complete
- Throws:
IOException
-
createHuffmanDecodingTables
Called by recvDecodingTables() exclusively.- Throws:
IOException
-
endBlock
- Throws:
IOException
-
getAndMoveToFrontDecode
- Throws:
IOException
-
getAndMoveToFrontDecode0
- Throws:
IOException
-
getCompressedCount
public long getCompressedCount()Description copied from interface:InputStreamStatisticsGets the amount of raw or compressed bytes read by the stream.- Specified by:
getCompressedCountin interfaceInputStreamStatistics- Returns:
- the amount of raw or compressed bytes read by the stream.
- Since:
- 1.17
-
init
- Throws:
IOException
-
initBlock
- Throws:
IOException
-
makeMaps
private void makeMaps() -
read
- Specified by:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read0
- Throws:
IOException
-
readNextByte
- Throws:
IOException
-
recvDecodingTables
- Throws:
IOException
-
setupBlock
- Throws:
IOException
-
setupNoRandPartA
- Throws:
IOException
-
setupNoRandPartB
- Throws:
IOException
-
setupNoRandPartC
- Throws:
IOException
-
setupRandPartA
- Throws:
IOException
-
setupRandPartB
- Throws:
IOException
-
setupRandPartC
- Throws:
IOException
-