com.mindbright.ssh2
Class SSH2Compressor

java.lang.Object
  extended by com.mindbright.ssh2.SSH2Compressor
Direct Known Subclasses:
SSH2CompressorZLib

public abstract class SSH2Compressor
extends java.lang.Object

This is the abstract base class for compressors which compress/uncompress the ssh stream.


Field Summary
static int COMPRESS_MODE
           
static int UNCOMPRESS_MODE
           
 
Constructor Summary
SSH2Compressor()
           
 
Method Summary
 void authSucceeded()
          Tell compression library that uiser has authenticated
abstract  void compress(SSH2DataBuffer data)
          Compress a block of data.
static SSH2Compressor getInstance(java.lang.String algorithm)
          Get an instance of a compressor which implements the given algorithm.
abstract  void init(int mode, int level)
          Initialize the compressor.
abstract  long numOfCompressedBytes()
          Get the total number of bytes compressed.
abstract  long numOfUncompressedBytes()
          Get the total number of bytes uncompressed.
abstract  int uncompress(SSH2DataBuffer data, int len)
          Uncompress a block of data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPRESS_MODE

public static final int COMPRESS_MODE
See Also:
Constant Field Values

UNCOMPRESS_MODE

public static final int UNCOMPRESS_MODE
See Also:
Constant Field Values
Constructor Detail

SSH2Compressor

public SSH2Compressor()
Method Detail

getInstance

public static SSH2Compressor getInstance(java.lang.String algorithm)
                                  throws SSH2CompressionException
Get an instance of a compressor which implements the given algorithm.

Parameters:
algorithm - The compression algorithm to implement.
Returns:
An instance of SSH2Compressor or null.
Throws:
SSH2CompressionException

init

public abstract void init(int mode,
                          int level)
Initialize the compressor. Sets the mode (compress or uncompress) as well as the desired level of compression.

Parameters:
mode - Either COMPRESS_MODE or UNCOMPRESS_MODE.
level - The level of compression. The exact meaning of this is algorithm dependent.

compress

public abstract void compress(SSH2DataBuffer data)
                       throws SSH2CompressionException
Compress a block of data.

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

uncompress

public abstract int uncompress(SSH2DataBuffer data,
                               int len)
                        throws SSH2CompressionException
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.

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

numOfCompressedBytes

public abstract long numOfCompressedBytes()
Get the total number of bytes compressed.

Returns:
The number of bytes sent into the algorithm.

numOfUncompressedBytes

public abstract long numOfUncompressedBytes()
Get the total number of bytes uncompressed.

Returns:
The number of bytes output by the algorithm.

authSucceeded

public void authSucceeded()
Tell compression library that uiser has authenticated