Loading…

Kryptel/Java

IProgressCallback interface

Declaration

package com.kryptel;

public interface IProgressCallback {
	static final int PROGRESS_STEPS = 100;
	static final int MIN_SIZE_TO_STEP = (16 * 1024);
	static final int NO_TOTAL_PROGRESS_BAR = -1;
	
	boolean Callback(Object arg, String curFile, int stepFile, int stepTotal) throws Exception;
}

Description

High-level file-oriented components use this interface to maintain a progress bar. The client may choose not to impelent it; if a progress bar is not needed, just pass null value instead of an interface pointer.

Typically, the client does not implement and the component does not use this interface directly. See helper classes Progress and ProgressCallback for more information.

Callback

boolean Callback(Object arg, String curFile, int stepFile, int stepTotal) throws Exception;

The only function of the interface is called by the component when it starts processing of a new file or when one of the progress steps has changed.

Parameters

arg
This argument is supplied by the client during component initialization; the component just passes it to the callback. It usually represents the execution context, or null is the operation is context-independent.
curFile
Contains the name of the file being processed.
stepFile
File step from 0 to PROGRESS_STEPS.
stepTotal
Total step from 0 to PROGRESS_STEPS. May contain NO_TOTAL_PROGRESS_BAR (-1) – in this case the component performs a single file operation and the progress window should not display the Total bar.

The callback implementation must also correctly process special argument values:

stepFile == 0 && (stepTotal == 0 || stepTotal == NO_TOTAL_PROGRESS_BAR)
If there is no progress box, create it. Otherwise display the file name.
stepFile == PROGRESS_STEPS && (stepTotal == PROGRESS_STEPS || stepTotal == NO_TOTAL_PROGRESS_BAR)
If the progress box is active, destroy it; otherwise just return.