com.mindbright.ssh2
Class SSH2CompressorZLib

java.lang.Object
  extended bycom.mindbright.ssh2.SSH2Compressor
      extended bycom.mindbright.ssh2.SSH2CompressorZLib

public class SSH2CompressorZLib
extends SSH2Compressor

Implements the zlib compression algorithm as described in the ssh protocol draft. It uses the jzlib provided by JCraft to handle the actual compression/uncompression.


Field Summary
 
Fields inherited from class com.mindbright.ssh2.SSH2Compressor
COMPRESS_MODE, UNCOMPRESS_MODE
 
Constructor Summary
SSH2CompressorZLib()
           
 
Method Summary
 void compress(SSH2DataBuffer data)
          Compress a block of data.
 void init(int mode, int level)
          Initialize the compressor.
 long numOfCompressedBytes()
          Get the total number of bytes compressed.
 long numOfUncompressedBytes()
          Get the total number of bytes uncompressed.
 int uncompress(SSH2DataBuffer data, int len)
          Uncompress a block of data.
 
Methods inherited from class com.mindbright.ssh2.SSH2Compressor
getInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SSH2CompressorZLib

public SSH2CompressorZLib()
Method Detail

init

public void init(int mode,
                 int level)
Description copied from class: SSH2Compressor
Initialize the compressor. Sets the mode (compress or uncompress) as well as the desired level of compression.

Specified by:
init in class SSH2Compressor
Parameters:
mode - Either COMPRESS_MODE or UNCOMPRESS_MODE.
level - The level of compression. The exact meaning of this is algorithm dependent.

compress

public void compress(SSH2DataBuffer data)
              throws SSH2CompressionException
Description copied from class: SSH2Compressor
Compress a block of data.

Specified by:
compress in class SSH2Compressor
Parameters:
data - The block of data to compress. The compressed data is left in the same buffer.
Throws:
SSH2CompressionException

uncompress

public int uncompress(SSH2DataBuffer data,
                      int len)
               throws SSH2CompressionException
Description copied from class: SSH2Compressor
Uncompress a block of data. The uncompressed data is stored in the SSH2DataBuffer given so this one has to be big enough to fit the uncompressed data block.

Specified by:
uncompress in class SSH2Compressor
Parameters:
data - The block of data to uncompress.
len - How much data can be stored in the given buffer.
Throws:
SSH2CompressionException

numOfCompressedBytes

public long numOfCompressedBytes()
Description copied from class: SSH2Compressor
Get the total number of bytes compressed.

Specified by:
numOfCompressedBytes in class SSH2Compressor
Returns:
The number of bytes sent into the algorithm.

numOfUncompressedBytes

public long numOfUncompressedBytes()
Description copied from class: SSH2Compressor
Get the total number of bytes uncompressed.

Specified by:
numOfUncompressedBytes in class SSH2Compressor
Returns:
The number of bytes output by the algorithm.