public abstract class LZWInputStream extends CompressorInputStream
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 |
---|---|
protected static int |
DEFAULT_CODE_SIZE |
protected BitInputStream |
in |
protected static int |
UNUSED_PREFIX |
Modifier | Constructor and Description |
---|---|
protected |
LZWInputStream(InputStream inputStream,
ByteOrder byteOrder) |
Modifier and Type | Method and Description |
---|---|
protected abstract int |
addEntry(int previousCode,
byte character)
Add a new entry to the dictionary.
|
protected int |
addEntry(int previousCode,
byte character,
int maxTableSize)
Adds a new entry if the maximum table size hasn't been exceeded
and returns the new index.
|
protected int |
addRepeatOfPreviousCode()
Add entry for repeat of previousCode we haven't added, yet.
|
void |
close() |
protected abstract int |
decompressNextSymbol()
Read the next code and expand it.
|
protected int |
expandCodeToOutputStack(int code,
boolean addedUnfinishedEntry)
Expands the entry with index code to the output stack and may
create a new entry
|
protected int |
getClearCode() |
protected int |
getCodeSize() |
protected int |
getPrefix(int offset) |
protected int |
getPrefixesLength() |
protected int |
getTableSize() |
protected void |
incrementCodeSize() |
protected void |
initializeTables(int maxCodeSize)
Initializes the arrays based on the maximum code size.
|
int |
read() |
int |
read(byte[] b,
int off,
int len) |
protected int |
readNextCode()
Reads the next code from the stream.
|
protected void |
resetCodeSize() |
protected void |
resetPreviousCode() |
protected void |
setClearCode(int codeSize)
Sets the clear code based on the code size.
|
protected void |
setCodeSize(int cs) |
protected void |
setPrefix(int offset,
int value) |
protected void |
setTableSize(int newSize) |
count, count, getBytesRead, getCount, pushedBackBytes
available, mark, markSupported, read, reset, skip
protected static final int DEFAULT_CODE_SIZE
protected static final int UNUSED_PREFIX
protected final BitInputStream in
protected LZWInputStream(InputStream inputStream, ByteOrder byteOrder)
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
public int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
protected abstract int decompressNextSymbol() throws IOException
IOException
protected abstract int addEntry(int previousCode, byte character) throws IOException
IOException
protected void setClearCode(int codeSize)
protected void initializeTables(int maxCodeSize)
protected int readNextCode() throws IOException
IOException
protected int addEntry(int previousCode, byte character, int maxTableSize)
protected int addRepeatOfPreviousCode() throws IOException
IOException
protected int expandCodeToOutputStack(int code, boolean addedUnfinishedEntry) throws IOException
IOException
protected int getCodeSize()
protected void resetCodeSize()
protected void setCodeSize(int cs)
protected void incrementCodeSize()
protected void resetPreviousCode()
protected int getPrefix(int offset)
protected void setPrefix(int offset, int value)
protected int getPrefixesLength()
protected int getClearCode()
protected int getTableSize()
protected void setTableSize(int newSize)
Copyright © 2015 The Apache Software Foundation. All rights reserved.