org.apache.maven.wagon.observers

Class ChecksumObserver

Implemented Interfaces:
TransferListener

public class ChecksumObserver
extends java.lang.Object
implements TransferListener

TransferListeners which computes MD5 checksum on the fly when files are transfered.
Version:
$Id: ChecksumObserver.java 312821 2005-10-11 07:21:52Z brett $
Author:
Michal Maczka

Constructor Summary

ChecksumObserver()
ChecksumObserver(String algorithm)

Method Summary

void
debug(String message)
protected String
encode(byte[] binaryData)
Encodes a 128 bit or 160-bit byte array into a String.
String
getActualChecksum()
Returns md5 checksum which was computed during transfer
void
transferCompleted(TransferEvent transferEvent)
void
transferError(TransferEvent transferEvent)
void
transferInitiated(TransferEvent transferEvent)
void
transferProgress(TransferEvent transferEvent, byte[] buffer, int length)
void
transferStarted(TransferEvent transferEvent)

Constructor Details

ChecksumObserver

public ChecksumObserver()
            throws NoSuchAlgorithmException

ChecksumObserver

public ChecksumObserver(String algorithm)
            throws NoSuchAlgorithmException
Parameters:
algorithm - One of the algorithms supported by JDK: MD5, MD2 or SHA-1

Method Details

debug

public void debug(String message)
Specified by:
debug in interface TransferListener
Parameters:
message -

encode

protected String encode(byte[] binaryData)
Encodes a 128 bit or 160-bit byte array into a String.
Parameters:
binaryData - Array containing the digest
Returns:
Encoded hex string, or null if encoding failed

getActualChecksum

public String getActualChecksum()
Returns md5 checksum which was computed during transfer
Returns:

transferCompleted

public void transferCompleted(TransferEvent transferEvent)
Specified by:
transferCompleted in interface TransferListener
Parameters:
transferEvent -

transferError

public void transferError(TransferEvent transferEvent)
Specified by:
transferError in interface TransferListener
Parameters:
transferEvent -

transferInitiated

public void transferInitiated(TransferEvent transferEvent)
Specified by:
transferInitiated in interface TransferListener
Parameters:
transferEvent -

transferProgress

public void transferProgress(TransferEvent transferEvent,
                             byte[] buffer,
                             int length)
Specified by:
transferProgress in interface TransferListener

transferStarted

public void transferStarted(TransferEvent transferEvent)
Specified by:
transferStarted in interface TransferListener