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...

List of all members.

Public Member Functions

 Deflater ()
 Creates a new deflater with default compression level.
 Deflater (int lvl)
 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
setInput(input, 0, input.length)</code>.

void SetInput (byte[] input, int off, int len)
 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 lvl)
 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[] dict)
 Sets the dictionary which should be used in the deflate process. This call is equivalent to
setDictionary(dict, 0, dict.Length)</code>.

void SetDictionary (byte[] dict, int offset, int length)
 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

static int BEST_COMPRESSION = 9
 The best and slowest compression level. This tries to find very long and distant string repetitions.
static int BEST_SPEED = 1
 The worst but fastest compression level.
static int DEFAULT_COMPRESSION = -1
 The default compression level.
static int NO_COMPRESSION = 0
 This level won't compress at all but output uncompressed blocks.
static 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
 Gets the current adler checksum of the data that was processed so far.
int TotalIn
 Gets the number of input bytes processed so far.
long TotalOut
 Gets the number of output bytes so far.
bool IsFinished
 Returns true if the stream was finished and no more output bytes are available.
bool IsNeedingInput
 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

static int IS_SETDICT = 0x01
static int IS_FLUSHING = 0x04
static int IS_FINISHING = 0x08
static int INIT_STATE = 0x00
static int SETDICT_STATE = 0x01
static int BUSY_STATE = 0x10
static int FLUSHING_STATE = 0x14
static int FINISHING_STATE = 0x1c
static int FINISHED_STATE = 0x1e
static 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

Definition at line 55 of file Deflater.cs.


Constructor & Destructor Documentation

ICSharpCode::SharpZipLib::Zip::Compression::Deflater::Deflater  )  [inline]
 

Creates a new deflater with default compression level.

Definition at line 166 of file Deflater.cs.

ICSharpCode::SharpZipLib::Zip::Compression::Deflater::Deflater int  lvl  )  [inline]
 

Creates a new deflater with given compression level.

Parameters:
lvl the compression level, a value between NO_COMPRESSION and BEST_COMPRESSION, or DEFAULT_COMPRESSION.
Exceptions:
System.ArgumentOutOfRangeException if lvl is out of range.

Definition at line 179 of file Deflater.cs.

ICSharpCode::SharpZipLib::Zip::Compression::Deflater::Deflater int  level,
bool  noZlibHeaderOrFooter
[inline]
 

Creates a new deflater with given compression level.

Parameters:
level the compression level, a value between NO_COMPRESSION and BEST_COMPRESSION.
noZlibHeaderOrFooter true, 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.ArgumentOutOfRangeException if lvl is out of range.

Definition at line 197 of file Deflater.cs.


Member Function Documentation

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::Deflate byte[]  output,
int  offset,
int  length
[inline]
 

Deflates the current input block to the given array.

Parameters:
output Buffer to store the compressed data.
offset Offset into the output array.
length The 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.InvalidOperationException If end() was previously called.
System.ArgumentOutOfRangeException If offset and/or length don't match the array length.

Definition at line 426 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::Deflate byte[]  output  )  [inline]
 

Deflates the current input block with to the given array.

Parameters:
output The buffer where compressed data is stored
Returns:
The number of compressed bytes added to the output, or 0 if either needsInput() or finished() returns true or length is zero.

Definition at line 399 of file Deflater.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Deflater::Finish  )  [inline]
 

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.

Definition at line 271 of file Deflater.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Deflater::Flush  )  [inline]
 

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().

Definition at line 261 of file Deflater.cs.

Referenced by ICSharpCode::SharpZipLib::Zip::Compression::Streams::DeflaterOutputStream::Flush().

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::GetLevel  )  [inline]
 

Get current compression level.

Returns:
Returns the current compression level

Definition at line 371 of file Deflater.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Deflater::Reset  )  [inline]
 

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

Definition at line 219 of file Deflater.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Deflater::SetDictionary byte[]  dict,
int  offset,
int  length
[inline]
 

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:
dict The dictionary data
offset An offset into the dictionary.
length The length of the dictionary data to use
Exceptions:
System.InvalidOperationException If setInput () or deflate () were already called or another dictionary was already set.

Definition at line 542 of file Deflater.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Deflater::SetDictionary byte[]  dict  )  [inline]
 

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

setDictionary(dict, 0, dict.Length)</code>.

Parameters:
dict the dictionary.
Exceptions:
System.InvalidOperationException if setInput () or deflate () were already called or another dictionary was already set.

Definition at line 517 of file Deflater.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Deflater::SetInput byte[]  input,
int  off,
int  len
[inline]
 

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:
input the buffer containing the input data.
off the start of the data.
len the length of the data.
Exceptions:
System.InvalidOperationException if the buffer was finished() or ended() or if previous input is still pending.

Definition at line 336 of file Deflater.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Deflater::SetInput byte[]  input  )  [inline]
 

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)</code>.

Parameters:
input the buffer containing the input data.
Exceptions:
System.InvalidOperationException if the buffer was finished() or ended().

Definition at line 313 of file Deflater.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Deflater::SetLevel int  lvl  )  [inline]
 

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:
lvl the new compression level.

Definition at line 353 of file Deflater.cs.

void ICSharpCode::SharpZipLib::Zip::Compression::Deflater::SetStrategy DeflateStrategy  strategy  )  [inline]
 

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:
strategy The new compression strategy.

Definition at line 384 of file Deflater.cs.


Member Data Documentation

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.

Definition at line 61 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::BEST_SPEED = 1 [static]
 

The worst but fastest compression level.

Definition at line 66 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::BUSY_STATE = 0x10 [static, private]
 

Definition at line 127 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::CLOSED_STATE = 0x7f [static, private]
 

Definition at line 131 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::DEFAULT_COMPRESSION = -1 [static]
 

The default compression level.

Definition at line 71 of file Deflater.cs.

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.

Definition at line 82 of file Deflater.cs.

DeflaterEngine ICSharpCode::SharpZipLib::Zip::Compression::Deflater::engine [private]
 

The deflater engine.

Definition at line 161 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::FINISHED_STATE = 0x1e [static, private]
 

Definition at line 130 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::FINISHING_STATE = 0x1c [static, private]
 

Definition at line 129 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::FLUSHING_STATE = 0x14 [static, private]
 

Definition at line 128 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::INIT_STATE = 0x00 [static, private]
 

Definition at line 123 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::IS_FINISHING = 0x08 [static, private]
 

Definition at line 121 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::IS_FLUSHING = 0x04 [static, private]
 

Definition at line 120 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::IS_SETDICT = 0x01 [static, private]
 

Definition at line 119 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::level [private]
 

Compression level.

Definition at line 136 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::NO_COMPRESSION = 0 [static]
 

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

Definition at line 76 of file Deflater.cs.

bool ICSharpCode::SharpZipLib::Zip::Compression::Deflater::noZlibHeaderOrFooter [private]
 

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

Definition at line 141 of file Deflater.cs.

DeflaterPending ICSharpCode::SharpZipLib::Zip::Compression::Deflater::pending [private]
 

The pending output.

Definition at line 156 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::SETDICT_STATE = 0x01 [static, private]
 

Definition at line 124 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::state [private]
 

The current state.

Definition at line 146 of file Deflater.cs.

long ICSharpCode::SharpZipLib::Zip::Compression::Deflater::totalOut [private]
 

The total bytes of output written.

Definition at line 151 of file Deflater.cs.


Property Documentation

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::Adler [get]
 

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

Definition at line 230 of file Deflater.cs.

bool ICSharpCode::SharpZipLib::Zip::Compression::Deflater::IsFinished [get]
 

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

Definition at line 280 of file Deflater.cs.

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.

Definition at line 292 of file Deflater.cs.

int ICSharpCode::SharpZipLib::Zip::Compression::Deflater::TotalIn [get]
 

Gets the number of input bytes processed so far.

Definition at line 239 of file Deflater.cs.

long ICSharpCode::SharpZipLib::Zip::Compression::Deflater::TotalOut [get]
 

Gets the number of output bytes so far.

Definition at line 248 of file Deflater.cs.


The documentation for this class was generated from the following file:
Generated on Fri Jun 23 21:50:07 2006 for OblivionModTranslator by  doxygen 1.4.6-NO