edu.umd.cs.findbugs.ba

Class ClassHash

public class ClassHash extends Object implements XMLWriteable, Comparable<ClassHash>

Compute a hash of method names and signatures. This allows us to find out when a class has been renamed, but not changed in any other obvious way.

Author: David Hovemeyer

Field Summary
static StringCLASS_HASH_ELEMENT_NAME
XML element name for a ClassHash.
static StringMETHOD_HASH_ELEMENT_NAME
XML element name for a MethodHash.
Constructor Summary
ClassHash()
Constructor.
ClassHash(String className, byte[] classHash)
Constructor.
Method Summary
intcompareTo(ClassHash other)
ClassHashcomputeHash(JavaClass javaClass)
Compute hash for given class and all of its methods.
byte[]getClassHash()
Get class hash.
StringgetClassName()
MethodHashgetMethodHash(XMethod method)
Get method hash for given method.
static StringhashToString(byte[] hash)
Convert a hash to a string of hex digits.
booleanisSameHash(ClassHash other)
Return whether or not this class hash has the same hash value as the one given.
voidsetClassHash(byte[] classHash)
Set class hash.
voidsetMethodHash(XMethod method, byte[] methodHash)
Set method hash for given method.
static byte[]stringToHash(String s)
Convert a string of hex digits to a hash.
voidwriteXML(XMLOutput xmlOutput)

Field Detail

CLASS_HASH_ELEMENT_NAME

public static final String CLASS_HASH_ELEMENT_NAME
XML element name for a ClassHash.

METHOD_HASH_ELEMENT_NAME

public static final String METHOD_HASH_ELEMENT_NAME
XML element name for a MethodHash.

Constructor Detail

ClassHash

public ClassHash()
Constructor.

ClassHash

public ClassHash(String className, byte[] classHash)
Constructor.

Parameters: classHash pre-computed class hash

Method Detail

compareTo

public int compareTo(ClassHash other)

computeHash

public ClassHash computeHash(JavaClass javaClass)
Compute hash for given class and all of its methods.

Parameters: javaClass the class

Returns: this object

getClassHash

public byte[] getClassHash()
Get class hash.

Returns: the class hash

getClassName

public String getClassName()

Returns: Returns the className.

getMethodHash

public MethodHash getMethodHash(XMethod method)
Get method hash for given method.

Parameters: method the method

Returns: the MethodHash

hashToString

public static String hashToString(byte[] hash)
Convert a hash to a string of hex digits.

Parameters: hash the hash

Returns: a String representation of the hash

isSameHash

public boolean isSameHash(ClassHash other)
Return whether or not this class hash has the same hash value as the one given.

Parameters: other another ClassHash

Returns: true if the hash values are the same, false if not

setClassHash

public void setClassHash(byte[] classHash)
Set class hash.

Parameters: classHash the class hash value to set

setMethodHash

public void setMethodHash(XMethod method, byte[] methodHash)
Set method hash for given method.

Parameters: method the method methodHash the method hash

stringToHash

public static byte[] stringToHash(String s)
Convert a string of hex digits to a hash.

Parameters: s string of hex digits

Returns: the hash value represented by the string

writeXML

public void writeXML(XMLOutput xmlOutput)
FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.