Class Compression

  • All Implemented Interfaces:
    Compression

    public class Compression
    extends java.lang.Object
    implements Compression
    This example demonstrates the packet compression without using jzlib[1].

    The ssh protocol adopts zlib[2] for the packet compression. Fortunately, JDK has provided wrapper classes for zlib(j.u.z.{Deflater, Inflater}), but it does not expose enough functionality of zlib, unfortunately; it must not allow to compress data with SYNC_FLUSH. So, JSch has been using jzlib by the default. After 12 years of bug parade entry[3] filing, Java7 has revised j.u.z.Deflater, and SYNC_FLUSH has been supported at last. This example shows how to enable the packet compression by using JDK's java.util.zip package.

    [1] http://www.jcraft.com/jzlib/ [2] http://www.zlib.net/ [3] https://bugs.openjdk.java.net/browse/JDK-4206909

    • Constructor Summary

      Constructors 
      Constructor Description
      Compression()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      byte[] compress​(byte[] buf, int start, int[] end)  
      void end()  
      void init​(int type, int level)  
      void init​(int type, int level, Session session)  
      byte[] uncompress​(byte[] buf, int start, int[] len)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Compression

        public Compression()
    • Method Detail

      • end

        public void end()
        Specified by:
        end in interface Compression
      • init

        public void init​(int type,
                         int level,
                         Session session)
        Specified by:
        init in interface Compression
      • init

        public void init​(int type,
                         int level)
        Specified by:
        init in interface Compression
      • compress

        public byte[] compress​(byte[] buf,
                               int start,
                               int[] end)
        Specified by:
        compress in interface Compression
      • uncompress

        public byte[] uncompress​(byte[] buf,
                                 int start,
                                 int[] len)
        Specified by:
        uncompress in interface Compression