Exemple #1
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");
     }
 }
Exemple #2
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");
     }
 }