abstract class AbstractChecksumPolicy extends java.lang.Object implements ChecksumPolicy
Modifier and Type | Field and Description |
---|---|
protected Logger |
logger |
protected TransferResource |
resource |
KIND_UNOFFICIAL
Modifier | Constructor and Description |
---|---|
protected |
AbstractChecksumPolicy(LoggerFactory loggerFactory,
TransferResource resource) |
Modifier and Type | Method and Description |
---|---|
void |
onChecksumError(java.lang.String algorithm,
int kind,
ChecksumFailureException exception)
Signals an error while computing the local checksum value or retrieving the checksum value from the remote
repository.
|
boolean |
onChecksumMatch(java.lang.String algorithm,
int kind)
Signals a match between the locally computed checksum value and the checksum value declared by the remote
repository.
|
void |
onChecksumMismatch(java.lang.String algorithm,
int kind,
ChecksumFailureException exception)
Signals a mismatch between the locally computed checksum value and the checksum value declared by the remote
repository.
|
void |
onNoMoreChecksums()
Signals that all available checksums have been processed.
|
void |
onTransferRetry()
Signals that the download is being retried after a previously thrown
ChecksumFailureException that is
retry-worthy . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onTransferChecksumFailure
protected final Logger logger
protected final TransferResource resource
protected AbstractChecksumPolicy(LoggerFactory loggerFactory, TransferResource resource)
public boolean onChecksumMatch(java.lang.String algorithm, int kind)
ChecksumPolicy
onChecksumMatch
in interface ChecksumPolicy
algorithm
- The name of the checksum algorithm being used, must not be null
.kind
- A bit field providing further details about the checksum. See the KIND_*
constants in this
interface for possible bit flags.true
to accept the download as valid and stop further validation, false
to continue
validation with the next checksum.public void onChecksumMismatch(java.lang.String algorithm, int kind, ChecksumFailureException exception) throws ChecksumFailureException
ChecksumPolicy
onChecksumMismatch
in interface ChecksumPolicy
algorithm
- The name of the checksum algorithm being used, must not be null
.kind
- A bit field providing further details about the checksum. See the KIND_*
constants in this
interface for possible bit flags.exception
- The exception describing the checksum mismatch, must not be null
.ChecksumFailureException
- If the checksum validation is to be failed. If the method returns normally,
validation continues with the next checksum.public void onChecksumError(java.lang.String algorithm, int kind, ChecksumFailureException exception) throws ChecksumFailureException
ChecksumPolicy
onChecksumError
in interface ChecksumPolicy
algorithm
- The name of the checksum algorithm being used, must not be null
.kind
- A bit field providing further details about the checksum. See the KIND_*
constants in this
interface for possible bit flags.exception
- The exception describing the checksum error, must not be null
.ChecksumFailureException
- If the checksum validation is to be failed. If the method returns normally,
validation continues with the next checksum.public void onNoMoreChecksums() throws ChecksumFailureException
ChecksumPolicy
onNoMoreChecksums
in interface ChecksumPolicy
ChecksumFailureException
- If the checksum validation is to be failed. If the method returns normally, the
download is assumed to be valid.public void onTransferRetry()
ChecksumPolicy
ChecksumFailureException
that is
retry-worthy
. Policies that maintain internal state will usually
have to reset some of this state at this point to prepare for a new round of validation.onTransferRetry
in interface ChecksumPolicy