org.apache.maven.util
Class MD5Sum

java.lang.Object
  extended byorg.apache.maven.util.MD5Sum

public class MD5Sum
extends java.lang.Object

Encode an MD5 digest into a String.

The 128 bit MD5 hash is converted into a 32 character long String. Each character of the String is the hexadecimal representation of 4 bits of the digest. XXX The API here is a mess. It is combining a static utility class with a message digest API. Some methods which should be static are not, presumably so Jelly can easily access them.

Version:
$Revision: 517014 $ $Date: 2007-03-11 22:15:50 +0100 (Sun, 11 Mar 2007) $
Author:
Remy Maucherat, Jason van Zyl

Constructor Summary
MD5Sum()
           
 
Method Summary
 java.lang.String encode(byte[] binaryData)
          Encodes the 128 bit (16 bytes) MD5 into a 32 character String.
 void execute()
          Perform the MD5-Sum work.
 byte[] getBytes(java.io.File file)
          Pull in static content and store it
 java.lang.String getChecksum()
          Get the checksum
 java.io.File getFile()
          Get the file that the checksum will be perform on.
 void setChecksum(java.lang.String checksum)
          Set the checksum
 void setFile(java.io.File file)
          Set the file to perform the checksum on.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MD5Sum

public MD5Sum()
Method Detail

setFile

public void setFile(java.io.File file)
Set the file to perform the checksum on.

Parameters:
file - The file.

getFile

public java.io.File getFile()
Get the file that the checksum will be perform on.

Returns:
the file.

setChecksum

public void setChecksum(java.lang.String checksum)
Set the checksum

Parameters:
checksum - The checksum.

getChecksum

public java.lang.String getChecksum()
Get the checksum

Returns:
The calculated checksum.

encode

public java.lang.String encode(byte[] binaryData)
Encodes the 128 bit (16 bytes) MD5 into a 32 character String.

Parameters:
binaryData - Array containing the digest
Returns:
Encoded MD5, or null if encoding failed

getBytes

public byte[] getBytes(java.io.File file)
                throws java.lang.Exception
Pull in static content and store it

Parameters:
file - The file to read.
Returns:
The bytes of the file.
Throws:
java.lang.Exception - If an error occurs reading in the file's bytes.

execute

public void execute()
             throws java.lang.Exception
Perform the MD5-Sum work.

Throws:
java.lang.Exception - If an error occurs while calculating the sum.


Copyright © 2001-2008 Apache Software Foundation. All Rights Reserved.