Fingerprint_Card
Loading...
Searching...
No Matches
ICSharpCode.SharpZipLib.Zip.Compression.Deflater Class Reference

This is the Deflater class. The deflater class compresses input with the deflate algorithm described in RFC 1951. It has several compression levels and three different strategies described below. More...

Collaboration diagram for ICSharpCode.SharpZipLib.Zip.Compression.Deflater:

Public Member Functions

 Deflater ()
 Creates a new deflater with default compression level.
 Deflater (int level)
 Creates a new deflater with given compression level.
 Deflater (int level, bool noZlibHeaderOrFooter)
 Creates a new deflater with given compression level.
void Reset ()
 Resets the deflater. The deflater acts afterwards as if it was just created with the same compression level and strategy as it had before.
void Flush ()
 Flushes the current input block. Further calls to deflate() will produce enough output to inflate everything in the current input block. This is not part of Sun's JDK so I have made it package private. It is used by DeflaterOutputStream to implement flush().
void Finish ()
 Finishes the deflater with the current input block. It is an error to give more input after this method was called. This method must be called to force all bytes to be flushed.
void SetInput (byte[] input)
 Sets the data which should be compressed next. This should be only called when needsInput indicates that more input is needed. If you call setInput when needsInput() returns false, the previous input that is still pending will be thrown away. The given byte array should not be changed, before needsInput() returns true again. This call is equivalent to.
void SetInput (byte[] input, int offset, int count)
 Sets the data which should be compressed next. This should be only called when needsInput indicates that more input is needed. The given byte array should not be changed, before needsInput() returns true again.
void SetLevel (int level)
 Sets the compression level. There is no guarantee of the exact position of the change, but if you call this when needsInput is true the change of compression level will occur somewhere near before the end of the so far given input.
int GetLevel ()
 Get current compression level.
void SetStrategy (DeflateStrategy strategy)
 Sets the compression strategy. Strategy is one of DEFAULT_STRATEGY, HUFFMAN_ONLY and FILTERED. For the exact position where the strategy is changed, the same as for SetLevel() applies.
int Deflate (byte[] output)
 Deflates the current input block with to the given array.
int Deflate (byte[] output, int offset, int length)
 Deflates the current input block to the given array.
void SetDictionary (byte[] dictionary)
 Sets the dictionary which should be used in the deflate process. This call is equivalent to.
void SetDictionary (byte[] dictionary, int index, int count)
 Sets the dictionary which should be used in the deflate process. The dictionary is a byte array containing strings that are likely to occur in the data which should be compressed. The dictionary is not stored in the compressed output, only a checksum. To decompress the output you need to supply the same dictionary again.

Static Public Attributes

const int BEST_COMPRESSION = 9
 The best and slowest compression level. This tries to find very long and distant string repetitions.
const int BEST_SPEED = 1
 The worst but fastest compression level.
const int DEFAULT_COMPRESSION = -1
 The default compression level.
const int NO_COMPRESSION = 0
 This level won't compress at all but output uncompressed blocks.
const int DEFLATED = 8
 The compression method. This is the only method supported so far. There is no need to use this constant at all.

Properties

int Adler [get]
 Gets the current adler checksum of the data that was processed so far.
long TotalIn [get]
 Gets the number of input bytes processed so far.
long TotalOut [get]
 Gets the number of output bytes so far.
bool IsFinished [get]
 Returns true if the stream was finished and no more output bytes are available.
bool IsNeedingInput [get]
 Returns true, if the input buffer is empty. You should then call setInput(). NOTE: This method can also return true when the stream was finished.

Private Attributes

int level
 Compression level.
bool noZlibHeaderOrFooter
 If true no Zlib/RFC1950 headers or footers are generated.
int state
 The current state.
long totalOut
 The total bytes of output written.
DeflaterPending pending
 The pending output.
DeflaterEngine engine
 The deflater engine.

Static Private Attributes

const int IS_SETDICT = 0x01
const int IS_FLUSHING = 0x04
const int IS_FINISHING = 0x08
const int INIT_STATE = 0x00
const int SETDICT_STATE = 0x01
const int BUSY_STATE = 0x10
const int FLUSHING_STATE = 0x14
const int FINISHING_STATE = 0x1c
const int FINISHED_STATE = 0x1e
const int CLOSED_STATE = 0x7f

Detailed Description

This is the Deflater class. The deflater class compresses input with the deflate algorithm described in RFC 1951. It has several compression levels and three different strategies described below.

This class is not thread safe. This is inherent in the API, due to the split of deflate and setInput.

author of the original java version : Jochen Hoenicke

Constructor & Destructor Documentation

◆ Deflater() [1/3]

ICSharpCode.SharpZipLib.Zip.Compression.Deflater.Deflater ( )

Creates a new deflater with default compression level.

◆ Deflater() [2/3]

ICSharpCode.SharpZipLib.Zip.Compression.Deflater.Deflater ( int level)

Creates a new deflater with given compression level.

Parameters
levelthe compression level, a value between NO_COMPRESSION and BEST_COMPRESSION, or DEFAULT_COMPRESSION.
Exceptions
System.ArgumentOutOfRangeExceptionif lvl is out of range.

◆ Deflater() [3/3]

ICSharpCode.SharpZipLib.Zip.Compression.Deflater.Deflater ( int level,
bool noZlibHeaderOrFooter )

Creates a new deflater with given compression level.

Parameters
levelthe compression level, a value between NO_COMPRESSION and BEST_COMPRESSION.
noZlibHeaderOrFootertrue, if we should suppress the Zlib/RFC1950 header at the beginning and the adler checksum at the end of the output. This is useful for the GZIP/PKZIP formats.
Exceptions
System.ArgumentOutOfRangeExceptionif lvl is out of range.
Here is the call graph for this function:

Member Function Documentation

◆ Deflate() [1/2]

int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.Deflate ( byte[] output)

Deflates the current input block with to the given array.

Parameters
outputThe buffer where compressed data is stored
Returns
The number of compressed bytes added to the output, or 0 if either IsNeedingInput() or IsFinished returns true or length is zero.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Deflate() [2/2]

int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.Deflate ( byte[] output,
int offset,
int length )

Deflates the current input block to the given array.

Parameters
outputBuffer to store the compressed data.
offsetOffset into the output array.
lengthThe maximum number of bytes that may be stored.
Returns
The number of compressed bytes added to the output, or 0 if either needsInput() or finished() returns true or length is zero.
Exceptions
System.InvalidOperationExceptionIf Finish() was previously called.
System.ArgumentOutOfRangeExceptionIf offset or length don't match the array length.

◆ Finish()

void ICSharpCode.SharpZipLib.Zip.Compression.Deflater.Finish ( )

Finishes the deflater with the current input block. It is an error to give more input after this method was called. This method must be called to force all bytes to be flushed.

◆ Flush()

void ICSharpCode.SharpZipLib.Zip.Compression.Deflater.Flush ( )

Flushes the current input block. Further calls to deflate() will produce enough output to inflate everything in the current input block. This is not part of Sun's JDK so I have made it package private. It is used by DeflaterOutputStream to implement flush().

◆ GetLevel()

int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.GetLevel ( )

Get current compression level.

Returns
Returns the current compression level

◆ Reset()

void ICSharpCode.SharpZipLib.Zip.Compression.Deflater.Reset ( )

Resets the deflater. The deflater acts afterwards as if it was just created with the same compression level and strategy as it had before.

Here is the caller graph for this function:

◆ SetDictionary() [1/2]

void ICSharpCode.SharpZipLib.Zip.Compression.Deflater.SetDictionary ( byte[] dictionary)

Sets the dictionary which should be used in the deflate process. This call is equivalent to.

setDictionary(dict, 0, dict.Length)

.

Parameters
dictionarythe dictionary.
Exceptions
System.InvalidOperationExceptionif SetInput () or Deflate () were already called or another dictionary was already set.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetDictionary() [2/2]

void ICSharpCode.SharpZipLib.Zip.Compression.Deflater.SetDictionary ( byte[] dictionary,
int index,
int count )

Sets the dictionary which should be used in the deflate process. The dictionary is a byte array containing strings that are likely to occur in the data which should be compressed. The dictionary is not stored in the compressed output, only a checksum. To decompress the output you need to supply the same dictionary again.

Parameters
dictionaryThe dictionary data
indexThe index where dictionary information commences.
countThe number of bytes in the dictionary.
Exceptions
System.InvalidOperationExceptionIf SetInput () or Deflate() were already called or another dictionary was already set.

◆ SetInput() [1/2]

void ICSharpCode.SharpZipLib.Zip.Compression.Deflater.SetInput ( byte[] input)

Sets the data which should be compressed next. This should be only called when needsInput indicates that more input is needed. If you call setInput when needsInput() returns false, the previous input that is still pending will be thrown away. The given byte array should not be changed, before needsInput() returns true again. This call is equivalent to.

setInput(input, 0, input.length)

.

Parameters
inputthe buffer containing the input data.
Exceptions
System.InvalidOperationExceptionif the buffer was finished() or ended().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetInput() [2/2]

void ICSharpCode.SharpZipLib.Zip.Compression.Deflater.SetInput ( byte[] input,
int offset,
int count )

Sets the data which should be compressed next. This should be only called when needsInput indicates that more input is needed. The given byte array should not be changed, before needsInput() returns true again.

Parameters
inputthe buffer containing the input data.
offsetthe start of the data.
countthe number of data bytes of input.
Exceptions
System.InvalidOperationExceptionif the buffer was Finish()ed or if previous input is still pending.

◆ SetLevel()

void ICSharpCode.SharpZipLib.Zip.Compression.Deflater.SetLevel ( int level)

Sets the compression level. There is no guarantee of the exact position of the change, but if you call this when needsInput is true the change of compression level will occur somewhere near before the end of the so far given input.

Parameters
levelthe new compression level.
Here is the caller graph for this function:

◆ SetStrategy()

void ICSharpCode.SharpZipLib.Zip.Compression.Deflater.SetStrategy ( DeflateStrategy strategy)

Sets the compression strategy. Strategy is one of DEFAULT_STRATEGY, HUFFMAN_ONLY and FILTERED. For the exact position where the strategy is changed, the same as for SetLevel() applies.

Parameters
strategyThe new compression strategy.
Here is the caller graph for this function:

Member Data Documentation

◆ BEST_COMPRESSION

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.BEST_COMPRESSION = 9
static

The best and slowest compression level. This tries to find very long and distant string repetitions.

◆ BEST_SPEED

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.BEST_SPEED = 1
static

The worst but fastest compression level.

◆ BUSY_STATE

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.BUSY_STATE = 0x10
staticprivate

◆ CLOSED_STATE

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.CLOSED_STATE = 0x7f
staticprivate

◆ DEFAULT_COMPRESSION

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.DEFAULT_COMPRESSION = -1
static

The default compression level.

◆ DEFLATED

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.DEFLATED = 8
static

The compression method. This is the only method supported so far. There is no need to use this constant at all.

◆ engine

DeflaterEngine ICSharpCode.SharpZipLib.Zip.Compression.Deflater.engine
private

The deflater engine.

◆ FINISHED_STATE

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.FINISHED_STATE = 0x1e
staticprivate

◆ FINISHING_STATE

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.FINISHING_STATE = 0x1c
staticprivate

◆ FLUSHING_STATE

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.FLUSHING_STATE = 0x14
staticprivate

◆ INIT_STATE

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.INIT_STATE = 0x00
staticprivate

◆ IS_FINISHING

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.IS_FINISHING = 0x08
staticprivate

◆ IS_FLUSHING

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.IS_FLUSHING = 0x04
staticprivate

◆ IS_SETDICT

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.IS_SETDICT = 0x01
staticprivate

◆ level

int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.level
private

Compression level.

◆ NO_COMPRESSION

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.NO_COMPRESSION = 0
static

This level won't compress at all but output uncompressed blocks.

◆ noZlibHeaderOrFooter

bool ICSharpCode.SharpZipLib.Zip.Compression.Deflater.noZlibHeaderOrFooter
private

If true no Zlib/RFC1950 headers or footers are generated.

◆ pending

DeflaterPending ICSharpCode.SharpZipLib.Zip.Compression.Deflater.pending
private

The pending output.

◆ SETDICT_STATE

const int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.SETDICT_STATE = 0x01
staticprivate

◆ state

int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.state
private

The current state.

◆ totalOut

long ICSharpCode.SharpZipLib.Zip.Compression.Deflater.totalOut
private

The total bytes of output written.

Property Documentation

◆ Adler

int ICSharpCode.SharpZipLib.Zip.Compression.Deflater.Adler
get

Gets the current adler checksum of the data that was processed so far.

◆ IsFinished

bool ICSharpCode.SharpZipLib.Zip.Compression.Deflater.IsFinished
get

Returns true if the stream was finished and no more output bytes are available.

◆ IsNeedingInput

bool ICSharpCode.SharpZipLib.Zip.Compression.Deflater.IsNeedingInput
get

Returns true, if the input buffer is empty. You should then call setInput(). NOTE: This method can also return true when the stream was finished.

◆ TotalIn

long ICSharpCode.SharpZipLib.Zip.Compression.Deflater.TotalIn
get

Gets the number of input bytes processed so far.

◆ TotalOut

long ICSharpCode.SharpZipLib.Zip.Compression.Deflater.TotalOut
get

Gets the number of output bytes so far.


The documentation for this class was generated from the following file: