Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.jimi.core.util.lzw
Class LZWDecompressor

    java.lang.Object
      |
      +--com.sun.jimi.core.util.lzw.LZWDecompressor

public final class LZWDecompressor
extends java.lang.Object

Generic LZW decompressor, with support for the TIFF variation.

Field Summary
`protected int` | `codeSize_`
`protected int` | `count_`
`protected int` | `initialCodeSize_`
`protected BitInput` | `input_`
`protected boolean` | `isLeftOver_`
`protected int` | `leftOverCode_`
`protected int` | `leftOverIndex_`
`protected int` | `leftOverOldCode_`
`protected int` | `limit_`
`protected int` | `oldCode_`
`protected byte` | `oldCodeFirstChar_`
`protected com.sun.jimi.core.util.lzw.LZWDecompressionStringTable` | `table_`
`protected boolean` | `tiff_`

Constructor Summary
`LZWDecompressor(java.io.InputStream in, int codeSize, boolean TIFF)` Constructs an LZW decompressor to decode data from a stream.

Method Summary
`protected void` | `clearTable()` Clears the table and resets the bit-size of input data.
`int` | `decompress(byte[] buf)` Decompresses into a byte-array buffer.
`protected int` | `getNextCode()` Reads the next code from the encrypted input.
`void` | `gifFinishBlocks()` Due to the way that decompress() is written to just retreive the required data when the end of the compressed data is reached the trailing END OF INPUT code will never be read and the Zero lenght block as the last block will never be read.
`protected void` | `incrementCodeSize()` Increments the bit-size of input data by one bit.
`protected void` | `resetCodeSize()` Resets the bit-size of input data.
`void` | `setInputStream(java.io.InputStream in)` Sets a new InputStream as the LZW source and re-initializes the decoder.
`protected int` | `writeCode(byte[] buf, int index, int code)` Writes a code into the buffer at a specified index.
`protected int` | `writeCode(byte[] buf, int index, int code, int skip)` Writes a code into the buffer at a specified index.
`protected int` | `writeLeftOver(byte[] buf)` Writes leftover codes into a buffer.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### input_

    protected BitInput input_

### initialCodeSize_

    protected int initialCodeSize_

### codeSize_

    protected int codeSize_

### limit_

    protected int limit_

### tiff_

    protected boolean tiff_

### table_

    protected com.sun.jimi.core.util.lzw.LZWDecompressionStringTable table_

### count_

    protected int count_

### oldCode_

    protected int oldCode_

### oldCodeFirstChar_

    protected byte oldCodeFirstChar_

### leftOverCode_

    protected int leftOverCode_

### leftOverIndex_

    protected int leftOverIndex_

### leftOverOldCode_

    protected int leftOverOldCode_

### isLeftOver_

    protected boolean isLeftOver_

Constructor Detail

### LZWDecompressor

    public LZWDecompressor(java.io.InputStream in,
                           int codeSize,
                           boolean TIFF)

  Constructs an LZW decompressor to decode data from a stream.
  Parameters:
    `in` - The input stream to read LZW-encoded data from.
    `codeSize` - The number of bits in each value.
    `TIFF` - True if the TIFF variation of LZW is to be used.

Method Detail

### setInputStream

    public void setInputStream(java.io.InputStream in)

  Sets a new InputStream as the LZW source and re-initializes the decoder.
  Parameters:
    `in` - The InputStream to read LZW-encoded data from.

### decompress

    public int decompress(byte[] buf)
                   throws java.io.IOException

  Decompresses into a byte-array buffer.
  Parameters:
    `buf` - The buffer to fill with decoded data.
  Returns:
    The index in the buffer where the last value was written.

### writeCode

    protected int writeCode(byte[] buf,
                            int index,
                            int code)

  Writes a code into the buffer at a specified index. Left-over codes not written will be tracked, and can later be flushed into a buffer using writeLeftOver.
  Parameters:
    `buf` - The buffer to write into.
    `index` - The starting index in the buffer.
    `code` - The code to write a string for.
  Returns:
    The return value has a double-meaning. If the value is positive, it indicates how many bytes were written into the buffer. If the code is negative, it indicates how many bytes remain to be written for the code.
  See Also:
    `writeLeftOver(byte[])`

### writeCode

    protected int writeCode(byte[] buf,
                            int index,
                            int code,
                            int skip)

  Writes a code into the buffer at a specified index. Left-over codes not written will be tracked, and can later be flushed into a buffer using writeLeftOver.
  Parameters:
    `buf` - The buffer to write into.
    `index` - The starting index in the buffer.
    `code` - The code to write a string for.
    `skip` - The number of bytes to skip from the start of the string.
  Returns:
    The return value has a double-meaning. If the value is positive, it indicates how many bytes were written into the buffer. If the code is negative, it indicates how many bytes remain to be written for the code.
  See Also:
    `writeLeftOver(byte[])`

### writeLeftOver

    protected int writeLeftOver(byte[] buf)

  Writes leftover codes into a buffer. If there are further leftovers from the write, two things happen: The bytes are stored as leftovers again, queuing them for write by a subsequent call to writeLeftOver, and secondly a negative value is returned.
  Parameters:
    `buf` - The buffer to write into.
  Returns:
    Returns a value as described in writeCode.
  See Also:
    `writeCode(byte[], int, int)`

### getNextCode

    protected int getNextCode()
                       throws java.io.IOException

  Reads the next code from the encrypted input.
  Returns:
    The code read.

### clearTable

    protected void clearTable()

  Clears the table and resets the bit-size of input data.

### resetCodeSize

    protected void resetCodeSize()

  Resets the bit-size of input data.

### incrementCodeSize

    protected void incrementCodeSize()

  Increments the bit-size of input data by one bit.

### gifFinishBlocks

    public void gifFinishBlocks()
                         throws java.io.IOException

  Due to the way that decompress() is written to just retreive the required data when the end of the compressed data is reached the trailing END OF INPUT code will never be read and the Zero lenght block as the last block will never be read. This method drives the BitInput class to get past these

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD