Loading…

Kryptel/Java

ICompressor interface

Declaration

package com.kryptel.compressor;

import com.kryptel.IDataSink;

public interface ICompressor {
  void Init(IDataSink callback, Object arg) throws Exception;
  void Compress(byte[] src, int start, int size) throws Exception;
  void Decompress(byte[] src, int start, int size) throws Exception;
  void Done() throws Exception;
}

Description

This interface is used for compressing data stream of arbitrary length. It uses the data sink interface IDataSink to output the compressed stream.

Compress and Decompress calls are mutually exclusive and can't be mixed within the same Init-Done sequence. For example, if the first call is Compress, then no Decompress call will be allowed until Done and another Init.

Init

void Init(IDataSink callback, Object arg) throws Exception;

Initializes the compressor and prepares it for a new session. The next Compress or Decompress call determines the type of the operation (i.e. compression or decompression).

callback
The data sink interface to which the output data will be sent.
arg
This argument is passed to IDataSink.Init. It usually contains a link to an object, which will receive the output stream (for example, a file).

Compress

void Compress(byte[] src, int start, int size) throws Exception;

Compresses size bytes of data in src at position start. The result will be sent to the data sink interface specified in the starting Init call.

Decompress

void Decompress(byte[] src, int start, int size) throws Exception;

Decompresses size bytes of data in src at position start. The result will be sent to the data sink interface specified in the starting Init call.

Done

void Done() throws Exception;

Finishes processing, flushes buffers, and resets the compressor to the idle state.