com.bigzip.plugin.compression.engine
Interface Compressor

All Known Implementing Classes:
NullCompression

public interface Compressor


Method Summary
 Compressor createInstance()
          Creates a new instance of the implemented Deflation class.
 int deflate(byte[] b)
          Fills specified buffer with compressed data.
 int deflate(byte[] b, int off, int len)
          Fills specified buffer with compressed data.
 void end()
          Discards unprocessed input and frees internal data.
 void finish()
          When called, indicates that compression should end with the current contents of the input buffer.
 boolean finished()
          Returns true if the end of the compressed data output stream has been reached.
 java.lang.String getName()
           
 int getTotalIn()
          Returns the total number of bytes input so far.
 int getTotalOut()
          Returns the total number of bytes output so far.
 int getVersion()
           
 boolean needsInput()
          Returns true if the input data buffer is empty and setInput() should be called in order to provide more input.
 void reset()
          Resets deflater so that a new set of input data can be processed.
 void setDictionary(byte[] b)
          Sets preset dictionary for compression.
 void setDictionary(byte[] b, int off, int len)
          Sets preset dictionary for compression.
 void setInput(byte[] b)
          Sets input data for compression.
 void setInput(byte[] b, int off, int len)
          Sets input data for compression.
 void setLevel(int level)
          Sets the current compression level to the specified value.
 void setStrategy(int strategy)
          Sets the compression strategy to the specified value.
 

Method Detail

getName

public java.lang.String getName()
Returns:
the name of the compression engine

getVersion

public int getVersion()
Returns:
the version of the engine

setInput

public void setInput(byte[] b,
                     int off,
                     int len)
Sets input data for compression. This should be called whenever needsInput() returns true indicating that more input data is required.
Parameters:
b - the input data bytes
off - the start offset of the data
len - the length of the data
See Also:
Deflater#needsInput

setInput

public void setInput(byte[] b)
Sets input data for compression. This should be called whenever needsInput() returns true indicating that more input data is required.
Parameters:
b - the input data bytes
See Also:
Deflater#needsInput

setDictionary

public void setDictionary(byte[] b,
                          int off,
                          int len)
Sets preset dictionary for compression. A preset dictionary is used when the history buffer can be predetermined. When the data is later uncompressed with Inflater.inflate(), Inflater.getAdler() can be called in order to get the Adler-32 value of the dictionary required for decompression.
Parameters:
b - the dictionary data bytes
off - the start offset of the data
len - the length of the data
See Also:
Inflater#inflate, Inflater#getAdler

setDictionary

public void setDictionary(byte[] b)
Sets preset dictionary for compression. A preset dictionary is used when the history buffer can be predetermined. When the data is later uncompressed with Inflater.inflate(), Inflater.getAdler() can be called in order to get the Adler-32 value of the dictionary required for decompression.
Parameters:
b - the dictionary data bytes
See Also:
Inflater#inflate, Inflater#getAdler

setStrategy

public void setStrategy(int strategy)
Sets the compression strategy to the specified value.
Parameters:
strategy - the new compression strategy
Throws:
java.lang.IllegalArgumentException - if the compression strategy is invalid

setLevel

public void setLevel(int level)
Sets the current compression level to the specified value.
Parameters:
level - the new compression level
Throws:
java.lang.IllegalArgumentException - if the compression level is invalid

needsInput

public boolean needsInput()
Returns true if the input data buffer is empty and setInput() should be called in order to provide more input.

finish

public void finish()
When called, indicates that compression should end with the current contents of the input buffer.

finished

public boolean finished()
Returns true if the end of the compressed data output stream has been reached.

deflate

public int deflate(byte[] b,
                   int off,
                   int len)
Fills specified buffer with compressed data. Returns actual number of bytes of compressed data. A return value of 0 indicates that needsInput() should be called in order to determine if more input data is required.
Parameters:
b - the buffer for the compressed data
off - the start offset of the data
len - the maximum number of bytes of compressed data
Returns:
the actual number of bytes of compressed data

deflate

public int deflate(byte[] b)
Fills specified buffer with compressed data. Returns actual number of bytes of compressed data. A return value of 0 indicates that needsInput() should be called in order to determine if more input data is required.
Parameters:
b - the buffer for the compressed data
Returns:
the actual number of bytes of compressed data

getTotalIn

public int getTotalIn()
Returns the total number of bytes input so far.

getTotalOut

public int getTotalOut()
Returns the total number of bytes output so far.

reset

public void reset()
Resets deflater so that a new set of input data can be processed. Keeps current compression level and strategy settings.

end

public void end()
Discards unprocessed input and frees internal data.

createInstance

public Compressor createInstance()
Creates a new instance of the implemented Deflation class.