FindBugs™ 1.3.9

edu.umd.cs.findbugs.ba
Class ClassHash

java.lang.Object
  extended by edu.umd.cs.findbugs.ba.ClassHash
All Implemented Interfaces:
XMLWriteable, java.lang.Comparable<ClassHash>

public class ClassHash
extends java.lang.Object
implements XMLWriteable, java.lang.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 java.lang.String CLASS_HASH_ELEMENT_NAME
          XML element name for a ClassHash.
static java.lang.String METHOD_HASH_ELEMENT_NAME
          XML element name for a MethodHash.
 
Constructor Summary
ClassHash()
          Constructor.
ClassHash(java.lang.String className, byte[] classHash)
          Constructor.
 
Method Summary
 int compareTo(ClassHash other)
           
 ClassHash computeHash(org.apache.bcel.classfile.JavaClass javaClass)
          Compute hash for given class and all of its methods.
 boolean equals(java.lang.Object o)
           
 byte[] getClassHash()
          Get class hash.
 java.lang.String getClassName()
           
 MethodHash getMethodHash(XMethod method)
          Get method hash for given method.
 int hashCode()
           
static java.lang.String hashToString(byte[] hash)
          Convert a hash to a string of hex digits.
 boolean isSameHash(ClassHash other)
          Return whether or not this class hash has the same hash value as the one given.
 void setClassHash(byte[] classHash)
          Set class hash.
 void setMethodHash(XMethod method, byte[] methodHash)
          Set method hash for given method.
static byte[] stringToHash(java.lang.String s)
          Convert a string of hex digits to a hash.
 java.lang.String toString()
           
 void writeXML(XMLOutput xmlOutput)
          Write this object to given XMLOutput.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

CLASS_HASH_ELEMENT_NAME

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

See Also:
Constant Field Values

METHOD_HASH_ELEMENT_NAME

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

See Also:
Constant Field Values
Constructor Detail

ClassHash

public ClassHash()
Constructor.


ClassHash

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

Parameters:
classHash - pre-computed class hash
Method Detail

setMethodHash

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

Parameters:
method - the method
methodHash - the method hash

getClassName

public java.lang.String 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

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

Parameters:
method - the method
Returns:
the MethodHash

computeHash

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

Parameters:
javaClass - the class
Returns:
this object

writeXML

public void writeXML(XMLOutput xmlOutput)
              throws java.io.IOException
Description copied from interface: XMLWriteable
Write this object to given XMLOutput.

Specified by:
writeXML in interface XMLWriteable
Parameters:
xmlOutput - the XMLOutput for the document
Throws:
java.io.IOException

hashToString

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

Parameters:
hash - the hash
Returns:
a String representation of the hash

stringToHash

public static byte[] stringToHash(java.lang.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

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

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(ClassHash other)
Specified by:
compareTo in interface java.lang.Comparable<ClassHash>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

FindBugs™ 1.3.9

FindBugs™ is licenced under the LGPL. Copyright © 2006 University of Maryland.