eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'CompressionStream':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: CompressionStream


Inheritance:

   Object
   |
   +--Stream
      |
      +--CompressionStream
         |
         +--BZip2Stream
         |
         +--ZipStream

Package:
stx:libbasic2
Category:
Streams-Compressed
Version:
rev: 1.54 date: 2023/07/18 14:19:16
user: stefan
file: CompressionStream.st directory: libbasic2
module: stx stc-classLibrary: libbasic2

Description:


Abstract superclass of streams that compress or decompress data


[instance variables:]

[class variables:]

copyright

COPYRIGHT (c) 2002 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

Class protocol:

class initialization
o  initialize

defaults
o  defaultSuppressHeaderAndChecksum

error handling
o  zerror: anError

instance creation
o  readOpenOn: aStream
open to read data from an compressed stream

o  readOpenOn: aStream suppressHeaderAndChecksum: aBoolean
open to read data from an compressed stream

o  writeOpenOn: aStream
open to write data compressed to stream

o  writeOpenOn: aStream suppressHeaderAndChecksum: aBoolean
open to write data compressed to stream

queries
o  isAbstract
Return if this class is an abstract class.
True is returned here for myself only; false for subclasses.
Abstract subclasses must redefine this again.


Instance protocol:

accessing
o  binary
switch to binary mode - default is text

o  binary: beBinaryBool
ExternalStream protocol compatibility:
switch to binary or text mode - default is text

o  propagateClose

o  propagateClose: aBoolean
close the underlying stream if the zip stream is closed

o  text
switch to text mode - default is text

error handling
o  errorNotOpen
report an error, that the stream has not been opened

o  errorReadOnly
report an error, that the stream is a readOnly stream

o  errorWriteOnly
report an error, that the stream is a writeOnly stream

o  invalidArgument
called if a method is invoked with invalid parameters

o  zerror: anError

finalization
o  executor
redefined to return a lightweight copy
- all we need is the memory handle

o  finalize
the compressin-stream was garbage collected;
close the underlying zip-stream

o  finalizeCopy: aZStream
used for finalization to close the underlying zip-stream

low level
o  z_nextAvailableInto: aCollection startingAt: offset maxCount: maxCount
read the next available bytes into a collection, a string or byteArray;
returns the size read

o  zclose
low level close of the zip stream

** This method must be redefined in concrete classes (subclassResponsibility) **

o  zdeflate
low level - deflate
returns false if the deflate operation is finished, otherwise true

** This method must be redefined in concrete classes (subclassResponsibility) **

o  zdeflateInit
low level - deflateInit
initialize the deflate mode, write header

** This method must be redefined in concrete classes (subclassResponsibility) **

o  zget_avail_out
low level - get the number of available out bytes

** This method must be redefined in concrete classes (subclassResponsibility) **

o  zinflate
low level - inflate
returns nil if at uncompress is finished, or the number of
available bytes in the output-buffer

** This method must be redefined in concrete classes (subclassResponsibility) **

o  zinflateInit
low level - inflateInit
initialize the inflate mode, read and check header

** This method must be redefined in concrete classes (subclassResponsibility) **

o  zopen
low level - opens the zip stream
create the resources

** This method must be redefined in concrete classes (subclassResponsibility) **

o  zset_avail_in: count
set the 'avail_in' and compute the crc

** This method must be redefined in concrete classes (subclassResponsibility) **

private
o  closeZStream
close the zip-stream

o  contentsSpecies
return the kind of object to be returned by sub-collection builders

o  fillBuffer
Fill the inputBytes buffer.
returns true if data is available for reading;
false if the stream is at end.
Updates the readLimit and position.

o  onStreamPutBytes: count from: data
write compressed data to the (output) stream

queries
o  atEnd
return true if the end of the compressed input stream has been reached

o  bufferSizeForNormalCopy
chunk size when reading from/writing to a Stream

o  isBinary
return true, if the stream is in binary (as opposed to text-) mode.
The default when created is false

o  isHeaderAndChecksumSuppressed
answer true if the checksum and header are suppressed;
the default is true (backward compatibility)

o  isOpen
return true, if this stream is open

o  isReadable
return true, if this stream can be read from

o  isWritable
return true, if this stream can be written to

reading
o  contents
return the entire contents of and close the stream

o  next
return the next element,
as character (text mode) or byte (binary mode).
Possibly raises ReadPastEnd error, if there are no more elements

o  next: n
return the next count elements of the stream as a collection.
Redefined to return a String or ByteArray and for optimization

o  next: n into: aBuffer startingAt: startIndex
read the next n elements of the stream into aBuffer.
Return the number of bytes read.

o  nextByte
return the next element, a byte
raise an error, if there are no more elements

o  nextByteOrNil
return the next element, a byte
return nil, if there are no more elements

o  nextBytes: numBytes into: aByteCollection startingAt: initialIndex
can do it faster here than in super class

o  nextOrNil
return the next element,
as character (text mode) or byte (binary mode).
return nil, if there are no more elements

o  skip: count
skip count objects, return the receiver
redefined for optimization

startup & release
o  close
close the zip-stream

o  openWithMode: aMode on: aStream
open the zip-stream on a stream
can be reimplemented to do some additional stuff (e.g. gzip header) like
in the ZipStream

o  openWithMode: aMode on: aStream suppressHeaderAndChecksum: aBoolean
open the zip-stream on a stream
can be reimplemented to do some additional stuff (e.g. gzip header) like
in the ZipStream

o  setInputStream: aStream
change the input stream (i.e. continue reading from aStream).
Useful if the input arrives in chunks, and we have to continue decompressing
from the next chunk (passing a readStream on the next chunk here).

o  streamOpenWithMode: aMode on: aStream

o  streamOpenWithMode: aMode on: aStream suppressHeaderAndChecksum: aBoolean
open the compression stream on a stream
#readonly uncompress the data derived from the read-stream, aStream
#writeonly compress the data and write to the write-stream, aStream

writing
o  contents: contents
write the entire contents to and close the stream

o  flush
flush the input and output buffer

o  nextPut: aByteOrCharacter
write the argument, aByteOrCharacter.
Answer aByteOrCharacter

o  nextPutAll: aCollection
Write each of the objects in aCollection to the receiver stream.
Answer the receiver.

o  nextPutBytes: count from: aStringOrBytes startingAt: startIndex
Write each of the objects in aCollection to the receiver stream.
Answer the receiver.



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 16:49:17 GMT