Generic LZW implementation. It is used internally for the Z decompressor and the Unshrinking Zip file compression method, but may be useful for third-party projects in implementing their own LZW variations.
| Modifier and Type | Field and Description |
|---|---|
| private byte[] | |
| private int | |
| private int | |
| protected static final int | |
| protected final BitInputStream | |
| private final byte[] | |
| private byte[] | |
| private int | |
| private int[] | |
| private int | |
| private byte | |
| private int | |
| protected static final int |
| Access | Constructor and Description |
|---|---|
| protected |
| Modifier and Type | Method and Description |
|---|---|
| protected abstract int | Returns: the new codethe previous code previousCode, byte the next character to append character)Add a new entry to the dictionary. |
| protected int | Returns: the new code or -1 if maxTableSize has been reached alreadythe previous code previousCode, final byte the character to append character, final int the maximum table size maxTableSize)Adds a new entry if the maximum table size hasn't been exceeded and returns the new index. |
| protected int | Returns: new code for a repeat of the previous code or -1 if maxTableSize has been reached alreadyAdd entry for repeat of previousCode we haven't added, yet. |
| public void | close()
Overrides java. Implements java. |
| protected abstract int | Returns: the expanded next code, negative on EOFRead the next code and expand it. |
| protected int | Returns: the new location of the output stackthe code code, final boolean whether unfinished entries have been added addedUnfinishedEntry)Expands the entry with index code to the output stack and may create a new entry |
| protected int | |
| protected int | |
| public long | getCompressedCount()
Implements org. |
| protected int | |
| protected int | |
| protected int | |
| protected void | |
| protected void | initializeTables(final int
maximum code size maxCodeSize)Initializes the arrays based on the maximum code size. |
| protected void | initializeTables(final int
maximum code size maxCodeSize, final int maximum allowed estimated memory usage in Kb memoryLimitInKb)Initializes the arrays based on the maximum code size. |
| public int | read()
Implements abstract java. |
| public int | read(final byte[]
the buffer into which the data is read. b, final int the start offset in array off, final int b
at which the data is written.the maximum number of bytes to read. len)Overrides java. len bytes of data from the input stream into
an array of bytes.
|
| private int | |
| protected int | |
| protected void | |
| protected void | |
| protected void | |
| protected void | |
| protected void | |
| protected void |
| characters | back to summary |
|---|---|
| private byte[] characters | |
| clearCode | back to summary |
|---|---|
| private int clearCode | |
| codeSize | back to summary |
|---|---|
| private int codeSize | |
| DEFAULT_CODE_SIZE | back to summary |
|---|---|
| protected static final int DEFAULT_CODE_SIZE | |
| in | back to summary |
|---|---|
| protected final BitInputStream in | |
| oneByte | back to summary |
|---|---|
| private final byte[] oneByte | |
| outputStack | back to summary |
|---|---|
| private byte[] outputStack | |
| outputStackLocation | back to summary |
|---|---|
| private int outputStackLocation | |
| prefixes | back to summary |
|---|---|
| private int[] prefixes | |
| previousCode | back to summary |
|---|---|
| private int previousCode | |
| previousCodeFirstChar | back to summary |
|---|---|
| private byte previousCodeFirstChar | |
| tableSize | back to summary |
|---|---|
| private int tableSize | |
| UNUSED_PREFIX | back to summary |
|---|---|
| protected static final int UNUSED_PREFIX | |
| LZWInputStream | back to summary |
|---|---|
| protected LZWInputStream(final InputStream inputStream, final ByteOrder byteOrder) | |
| addEntry | back to summary |
|---|---|
| protected abstract int addEntry(int previousCode, byte character) throws IOException Add a new entry to the dictionary.
| |
| addEntry | back to summary |
|---|---|
| protected int addEntry(final int previousCode, final byte character, final int maxTableSize) Adds a new entry if the maximum table size hasn't been exceeded and returns the new index.
| |
| addRepeatOfPreviousCode | back to summary |
|---|---|
| protected int addRepeatOfPreviousCode() throws IOException Add entry for repeat of previousCode we haven't added, yet.
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this input stream and releases any system resources associated with the stream.
| |
| decompressNextSymbol | back to summary |
|---|---|
| protected abstract int decompressNextSymbol() throws IOException Read the next code and expand it.
| |
| expandCodeToOutputStack | back to summary |
|---|---|
| protected int expandCodeToOutputStack(final int code, final boolean addedUnfinishedEntry) throws IOException Expands the entry with index code to the output stack and may create a new entry
| |
| getClearCode | back to summary |
|---|---|
| protected int getClearCode() | |
| getCodeSize | back to summary |
|---|---|
| protected int getCodeSize() | |
| getCompressedCount | back to summary |
|---|---|
| public long getCompressedCount() Implements org. Doc from org. Gets the amount of raw or compressed bytes read by the stream.
| |
| getPrefix | back to summary |
|---|---|
| protected int getPrefix(final int offset) | |
| getPrefixesLength | back to summary |
|---|---|
| protected int getPrefixesLength() | |
| getTableSize | back to summary |
|---|---|
| protected int getTableSize() | |
| incrementCodeSize | back to summary |
|---|---|
| protected void incrementCodeSize() | |
| initializeTables | back to summary |
|---|---|
| protected void initializeTables(final int maxCodeSize) Initializes the arrays based on the maximum code size.
| |
| initializeTables | back to summary |
|---|---|
| protected void initializeTables(final int maxCodeSize, final int memoryLimitInKb) throws MemoryLimitException Initializes the arrays based on the maximum code size. First checks that the estimated memory usage is below memoryLimitInKb
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Doc from java. Reads the next byte of data from the input stream. The value byte is
returned as an
| |
| read | back to summary |
|---|---|
| public int read(final byte[] b, final int off, final int len) throws IOException Overrides java. Doc from java. Reads up to This method blocks until input data is available, end of file is detected, or an exception is thrown. If The first byte read is stored into element In every case, elements
| |
| readFromStack | back to summary |
|---|---|
| private int readFromStack(final byte[] b, final int off, final int len) | |
| readNextCode | back to summary |
|---|---|
| protected int readNextCode() throws IOException Reads the next code from the stream.
| |
| resetCodeSize | back to summary |
|---|---|
| protected void resetCodeSize() | |
| resetPreviousCode | back to summary |
|---|---|
| protected void resetPreviousCode() | |
| setClearCode | back to summary |
|---|---|
| protected void setClearCode(final int codeSize) Sets the clear code based on the code size.
| |
| setCodeSize | back to summary |
|---|---|
| protected void setCodeSize(final int cs) | |
| setPrefix | back to summary |
|---|---|
| protected void setPrefix(final int offset, final int value) | |
| setTableSize | back to summary |
|---|---|
| protected void setTableSize(final int newSize) | |