Loading…

Kryptel/Java

IDataSink interface

Declaration

package com.kryptel;

public interface IDataSink {
    void Init(Object arg) throws Exception;
    void PutData(byte[] buf, int start, int size) throws Exception;
    void Done() throws Exception;
}

Description

When the size of the output data can not be predicted, components send result through caller-supplied IDataSink callback.

Init

void Init(Object arg) throws Exception;

Initialize the data sink for a new session. The argument arg is supplied by the client; the component just passes it to the data sink. It usually represents the execution context, or null is the operation is context-independent.

As an example let's see the ICipher interface. ICipher.Init is called with two arguments – IDataSink pointer, and arg object. The cipher does not use arg, it is passed to IDataSink.Init as is.

PutData

void PutData(byte[] buf, int start, int size) throws Exception;

Called when the component is ready to output a next chunk of data.

Done

void Done() throws Exception;

This function must flush buffers and finish processing.

Examples

For a simple usage example see File Encryption.

File Compression and Encryption is a more advanced example of several components linked via multiple datasink classes.