Package edu.umd.cs.findbugs.ba
Class ClassHash
java.lang.Object
edu.umd.cs.findbugs.ba.ClassHash
- All Implemented Interfaces:
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
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcomputeHash(org.apache.bcel.classfile.JavaClass javaClass) Compute hash for given class and all of its methods.booleanbyte[]Get class hash.getMethodHash(XMethod method) Get method hash for given method.inthashCode()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[]Convert a string of hex digits to a hash.toString()voidWrite this object to given XMLOutput.
-
Field Details
-
CLASS_HASH_ELEMENT_NAME
XML element name for a ClassHash.- See Also:
-
METHOD_HASH_ELEMENT_NAME
XML element name for a MethodHash.- See Also:
-
-
Constructor Details
-
ClassHash
public ClassHash()Constructor. -
ClassHash
Constructor.- Parameters:
classHash- pre-computed class hash
-
-
Method Details
-
setMethodHash
Set method hash for given method.- Parameters:
method- the methodmethodHash- the method hash
-
getClassName
- Returns:
- Returns the className.
-
getClassHash
public byte[] getClassHash()Get class hash.- Returns:
- the class hash
-
setClassHash
public void setClassHash(byte[] classHash) Set class hash.- Parameters:
classHash- the class hash value to set
-
getMethodHash
Get method hash for given method.- Parameters:
method- the method- Returns:
- the MethodHash
-
computeHash
Compute hash for given class and all of its methods.- Parameters:
javaClass- the class- Returns:
- this object
-
writeXML
Description copied from interface:XMLWriteableWrite this object to given XMLOutput.- Specified by:
writeXMLin interfaceXMLWriteable- Parameters:
xmlOutput- the XMLOutput for the document- Throws:
IOException
-
hashToString
Convert a hash to a string of hex digits.- Parameters:
hash- the hash- Returns:
- a String representation of the hash
-
stringToHash
Convert a string of hex digits to a hash.- Parameters:
s- string of hex digits- Returns:
- the hash value represented by the string
-
isSameHash
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
-
hashCode
public int hashCode() -
equals
-
compareTo
- Specified by:
compareToin interfaceComparable<ClassHash>
-
toString
-