com.starbase.util
Class MD5

java.lang.Object
  |
  +--com.starbase.util.MD5

public class MD5
extends java.lang.Object


Constructor Summary
MD5()
           
MD5(byte[] aSourceBytes)
           
MD5(MD5 aMD5)
           
MD5(java.lang.String stringMD5)
          Construct a new MD5 with the given String value.
 
Method Summary
 void computeBufferMD5(byte[] data)
          Compute MD5 for a byte array.
 int computeFileMD5(java.io.File file)
          Deprecated. Use computeFileMD5Ex, which supports file sizes greater than 2GB.
 long computeFileMD5Ex(java.io.File file)
          Computes the MD5 of the given file.
 int computeStreamMD5(java.io.InputStream in)
          Deprecated. Use computeStreamMD5Ex, which supports file sizes greater than 2GB.
 long computeStreamMD5Ex(java.io.InputStream in)
          Computes the MD5 of the given input stream.
 boolean equals(java.lang.Object obj)
          Return true if the given byte[] is identical to this object.
 byte[] getData()
           
 int hashCode()
          Return a hashcode for this MD5 value.
 void setData(byte[] aSource)
           
 java.lang.String toHexString()
          Return the a 32-character String equal to the hex equivalent of this MD5 value.
 java.lang.String toString()
          returns a quasi-readable string representation of this MD5
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MD5

public MD5(java.lang.String stringMD5)
Construct a new MD5 with the given String value.

Parameters:
stringMD5 - A 32-character hex value of an MD5 value.
Throws:
java.lang.IllegalArgumentException - If the given value is not 32 characters.
NumberFormatExcpetion - If the given value does not contain all hexadecimal characters (a-z, A-Z, or 0-9).

MD5

public MD5()

MD5

public MD5(byte[] aSourceBytes)

MD5

public MD5(MD5 aMD5)
Method Detail

hashCode

public int hashCode()
Return a hashcode for this MD5 value. Uses the same algorithm as String.hashCode().

Overrides:
hashCode in class java.lang.Object
Returns:
A hash code that distributes nicely based on this object's content, which makes it suitable for hash tables, etc.

equals

public boolean equals(java.lang.Object obj)
Return true if the given byte[] is identical to this object.

Overrides:
equals in class java.lang.Object
Parameters:
obj - Object to be compared.
Returns:
True if the given object is an MD5 object with the same MD5 value.

computeBufferMD5

public void computeBufferMD5(byte[] data)
Compute MD5 for a byte array.


toHexString

public java.lang.String toHexString()
Return the a 32-character String equal to the hex equivalent of this MD5 value.

Returns:
A 32-character String equal to the hex equivalent of this MD5 value.

toString

public java.lang.String toString()
returns a quasi-readable string representation of this MD5

Overrides:
toString in class java.lang.Object
Returns:
String a quasi-readable string representation of this MD5

computeStreamMD5

public int computeStreamMD5(java.io.InputStream in)
                     throws java.io.IOException
Deprecated. Use computeStreamMD5Ex, which supports file sizes greater than 2GB.

Computes the MD5 of the given input stream.

Parameters:
in - The input stream.
Returns:
The file size.
java.io.IOException
See Also:
MD5.computeStreamMD5Ex(java.io.InputStream)

computeStreamMD5Ex

public long computeStreamMD5Ex(java.io.InputStream in)
                        throws java.io.IOException
Computes the MD5 of the given input stream.

Parameters:
in - The input stream.
Returns:
The file size.
java.io.IOException

computeFileMD5

public int computeFileMD5(java.io.File file)
                   throws java.io.IOException
Deprecated. Use computeFileMD5Ex, which supports file sizes greater than 2GB.

Computes the MD5 of the given file.

Parameters:
file - The input file.
Returns:
The file size.
java.io.IOException
See Also:
MD5.computeFileMD5Ex(java.io.File)

computeFileMD5Ex

public long computeFileMD5Ex(java.io.File file)
                      throws java.io.IOException
Computes the MD5 of the given file.

Parameters:
file - The input file.
Returns:
The file size.
java.io.IOException

getData

public byte[] getData()

setData

public void setData(byte[] aSource)


StarTeam SDK 10.4, Build 36
Copyright © 2003-2008 Borland Software Corporation. All rights reserved.