Loading…

Kryptel/Java

IReplaceCallback interface

Declaration

package com.kryptel;

public interface IReplaceCallback {
    enum REPLACE_ACTION { REPLACE, SKIP, RENAME, VERSION, ABORT };
    static final REPLACE_ACTION DEFAULT_REPLACE_ACTION = REPLACE_ACTION.REPLACE;

    REPLACE_ACTION Callback(Object arg,
                StringBuilder newFileName, long newSize, long newDate,
                String oldFilePath, long oldSize, long oldDate) throws Exception;
}

Description

The client application provides an implementation of this interface for high-level file-processing components. The components call the provided function when file name conflict occurs. If the client passed null instead of an interface pointer, the component performs DEFAULT_REPLACE_ACTION, i.e. unconditionally replaces the existing file.

Typically an implementing class displays a message box, prompting the user to select the appropriate action.

Callback

REPLACE_ACTION Callback(Object arg,
                        StringBuilder newFileName, long newSize, long newDate,
                        String oldFilePath, long oldSize, long oldDate) throws Exception;

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.
newFileName
Output-only argument. If the callback returns REPLACE_ACTION.RENAME, newFileName must contain a new file name, otherwise it is ignored.
newSize
The size of the new file in bytes.
newDate
The creation date and time of the new file (UTC in milliseconds).
oldFilePath
The full path of the existing file.
oldSize
The size of the existing file in bytes.
oldDate
The creation date and time of the existing file (UTC in milliseconds).

Return Values

REPLACE
The existing file should be replaced with the new one.
SKIP
Skip this file, don't replace it.
RENAME
Leave the existing file intact and save the new file under another name. The name is returned in newFileName parameter.
VERSION
Leave the existing file intact and save the new file under a versioned name name (n).ext.
ABORT
Abort processing, perform cleanup, and throw UserAbortException.