Class ClassFile
- java.lang.Object
-
- org.codehaus.mojo.extraenforcer.dependencies.ClassFile
-
public class ClassFile extends java.lang.Object
This class represents a binary class file. The path to the class file should be a relative, file system path to the actual file. Examples: - CORRECT: org/apache/maven/Stuff.class - NO: /org/apache/maven/Stuff.class - NO: org.apache.maven.Stuff - NO: maven.jar!org.apache.maven.Stuff - NO: maven.jar!/org/apache/maven/Stuff.class - NO: /path/to/some/directory/org.apache.maven.Stuff - NO: /path/to/some/directory/org/apache/maven/Stuff.class The file must exist in either a directory or a jar file, but the path of the directory/jar is not included in the class file path. Rather, it's included in the Artifact. SeeArtifact.getFile()
-
-
Field Summary
Fields Modifier and Type Field Description private org.apache.maven.artifact.Artifact
artifactThisClassWasFoundIn
private java.lang.String
classFilePath
the path to the .class file.private java.lang.String
hash
-
Constructor Summary
Constructors Constructor Description ClassFile(java.lang.String classFilePath, org.apache.maven.artifact.Artifact artifactThisClassWasFoundIn, InputStreamSupplier inputStreamSupplier)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.lang.String
computeHash(InputStreamSupplier inputStreamSupplier)
org.apache.maven.artifact.Artifact
getArtifactThisClassWasFoundIn()
java.lang.String
getClassFilePath()
java.lang.String
getHash()
-
-
-
Constructor Detail
-
ClassFile
public ClassFile(java.lang.String classFilePath, org.apache.maven.artifact.Artifact artifactThisClassWasFoundIn, InputStreamSupplier inputStreamSupplier) throws java.io.IOException
Constructor.- Parameters:
classFilePath
- path to the class file. Example: org/apache/maven/Stuff.classartifactThisClassWasFoundIn
- the maven artifact the class appeared in (example: a jar file)inputStreamSupplier
- a supplier for class content input stream- Throws:
java.io.IOException
-
-
Method Detail
-
computeHash
private java.lang.String computeHash(InputStreamSupplier inputStreamSupplier) throws java.io.IOException
- Throws:
java.io.IOException
-
getClassFilePath
public java.lang.String getClassFilePath()
- Returns:
- the path to the .class file. Example: org/apache/maven/Stuff.class
-
getArtifactThisClassWasFoundIn
public org.apache.maven.artifact.Artifact getArtifactThisClassWasFoundIn()
- Returns:
- the maven artifact the class appeared in (example: a jar file)
-
getHash
public java.lang.String getHash()
- Returns:
- a hash or checksum of the binary file. If two files have the same hash then they are the same binary file.
-
-