org.apache.maven.shared.jar.identification.hash
Class JarBytecodeHashAnalyzer

java.lang.Object
  extended by org.codehaus.plexus.logging.AbstractLogEnabled
      extended by org.apache.maven.shared.jar.identification.hash.JarBytecodeHashAnalyzer
All Implemented Interfaces:
JarHashAnalyzer, org.codehaus.plexus.logging.LogEnabled

public class JarBytecodeHashAnalyzer
extends org.codehaus.plexus.logging.AbstractLogEnabled
implements JarHashAnalyzer

Analyzer that calculates the hash code for the entire file. Can be used to detect an exact copy of the file's class data. Useful to see thru a recompile, recompression, or timestamp change.

If you are not using Plexus, you must call setDigester(org.codehaus.plexus.digest.StreamingDigester) before use


Field Summary
private  org.codehaus.plexus.digest.StreamingDigester digester
          The streaming digester to use for computing the hash.
 
Constructor Summary
JarBytecodeHashAnalyzer()
           
 
Method Summary
private  void computeEntryBytecodeHash(java.io.InputStream is)
           
 java.lang.String computeHash(JarAnalyzer jarAnalyzer)
          Compute the hash for the JAR.
 void setDigester(org.codehaus.plexus.digest.StreamingDigester digester)
           
 
Methods inherited from class org.codehaus.plexus.logging.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

digester

private org.codehaus.plexus.digest.StreamingDigester digester
The streaming digester to use for computing the hash. Under Plexus, the default is SHA-1.

Constructor Detail

JarBytecodeHashAnalyzer

public JarBytecodeHashAnalyzer()
Method Detail

computeHash

public java.lang.String computeHash(JarAnalyzer jarAnalyzer)
Description copied from interface: JarHashAnalyzer
Compute the hash for the JAR. The hashcode will then be cached in the JAR data class for later use.

Specified by:
computeHash in interface JarHashAnalyzer
Parameters:
jarAnalyzer - the JAR analyzer to use to obtain the entries to hash
Returns:
the hash, or null if not able to be computed due to an exception.

computeEntryBytecodeHash

private void computeEntryBytecodeHash(java.io.InputStream is)
                               throws java.io.IOException,
                                      org.codehaus.plexus.digest.DigesterException
Throws:
java.io.IOException
org.codehaus.plexus.digest.DigesterException

setDigester

public void setDigester(org.codehaus.plexus.digest.StreamingDigester digester)