Пример #1
0
 /// <summary>Creates a new compressor using the specified compression level.</summary>
 /// <remarks>
 /// Creates a new compressor using the specified compression level.
 /// Compressed data will be generated in ZLIB format.
 /// </remarks>
 /// <param name="level">Compression level #CompressionLevel</param>
 /// <param name="strategy">Compression strategy #CompressionStrategy</param>
 /// <param name="header">Compression header #CompressionHeader</param>
 /// <param name="directBufferSize">Size of the direct buffer to be used.</param>
 public ZlibCompressor(ZlibCompressor.CompressionLevel level, ZlibCompressor.CompressionStrategy
                       strategy, ZlibCompressor.CompressionHeader header, int directBufferSize)
 {
     this.level      = level;
     this.strategy   = strategy;
     this.windowBits = header;
     stream          = Init(this.level.CompressionLevel(), this.strategy.CompressionStrategy(),
                            this.windowBits.WindowBits());
     this.directBufferSize = directBufferSize;
     uncompressedDirectBuf = ByteBuffer.AllocateDirect(directBufferSize);
     compressedDirectBuf   = ByteBuffer.AllocateDirect(directBufferSize);
     compressedDirectBuf.Position(directBufferSize);
 }
Пример #2
0
 /// <summary>
 /// Prepare the compressor to be used in a new stream with settings defined in
 /// the given Configuration.
 /// </summary>
 /// <remarks>
 /// Prepare the compressor to be used in a new stream with settings defined in
 /// the given Configuration. It will reset the compressor's compression level
 /// and compression strategy.
 /// </remarks>
 /// <param name="conf">Configuration storing new settings</param>
 public virtual void Reinit(Configuration conf)
 {
     Reset();
     if (conf == null)
     {
         return;
     }
     End(stream);
     level    = ZlibFactory.GetCompressionLevel(conf);
     strategy = ZlibFactory.GetCompressionStrategy(conf);
     stream   = Init(level.CompressionLevel(), strategy.CompressionStrategy(), windowBits
                     .WindowBits());
     if (Log.IsDebugEnabled())
     {
         Log.Debug("Reinit compressor with new compression configuration");
     }
 }
Пример #3
0
 /// <summary>reinit the compressor with the given configuration.</summary>
 /// <remarks>
 /// reinit the compressor with the given configuration. It will reset the
 /// compressor's compression level and compression strategy. Different from
 /// <tt>ZlibCompressor</tt>, <tt>BuiltInZlibDeflater</tt> only support three
 /// kind of compression strategy: FILTERED, HUFFMAN_ONLY and DEFAULT_STRATEGY.
 /// It will use DEFAULT_STRATEGY as default if the configured compression
 /// strategy is not supported.
 /// </remarks>
 public virtual void Reinit(Configuration conf)
 {
     Reset();
     if (conf == null)
     {
         return;
     }
     SetLevel(ZlibFactory.GetCompressionLevel(conf).CompressionLevel());
     ZlibCompressor.CompressionStrategy strategy = ZlibFactory.GetCompressionStrategy(
         conf);
     try
     {
         SetStrategy(strategy.CompressionStrategy());
     }
     catch (ArgumentException)
     {
         Log.Warn(strategy + " not supported by BuiltInZlibDeflater.");
         SetStrategy(DefaultStrategy);
     }
     if (Log.IsDebugEnabled())
     {
         Log.Debug("Reinit compressor with new compression configuration");
     }
 }
Пример #4
0
 public static void SetCompressionStrategy(Configuration conf, ZlibCompressor.CompressionStrategy
                                           strategy)
 {
     conf.SetEnum("zlib.compress.strategy", strategy);
 }
Пример #5
0
 protected internal void Construct(ZlibCompressor.CompressionLevel level, ZlibCompressor.CompressionStrategy
                                   strategy, ZlibCompressor.CompressionHeader header, int directBufferSize)
 {
 }