IDataSink interface
Contents
- Introduction to the Library
- Basic support package (com.kryptel.bslx)
- Kryptel API Commons package (com.kryptel)
- ApiHelpers class
- Constants class
- IComponentCapabilities interface
- IComponentState interface
- ICompressionLevelCallback interface
- IDataSink interface
- IKryptelComponent interface
- INotification interface
- IProgressCallback interface
- IReplaceCallback interface
- Loader class
- Message class
- Progress class
- ProgressCallback class
- Cipher package (com.kryptel.cipher)
- Compressor package (com.kryptel.compressor)
- Exceptions package (com.kryptel.exceptions)
- Hash function package (com.kryptel.hash_function)
- MAC function package (com.kryptel.mac)
- Key-related functions (com.kryptel.key)
- Silver Key engine (com.kryptel.silver_key)
- Kryptel encrypted storage (com.kryptel.storage)
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.