Class JarArtifactContentReader

java.lang.Object
org.bonitasoft.plugin.analyze.content.JarArtifactContentReader
All Implemented Interfaces:
ArtifactContentReader

public class JarArtifactContentReader extends Object implements ArtifactContentReader
Reads the content of a JAR file.

Java classes are loaded using the CFR library.

  • Constructor Details

    • JarArtifactContentReader

      public JarArtifactContentReader()
  • Method Details

    • getArtifactFileType

      public ArtifactContentReader.ArtifactFileType getArtifactFileType()
      Description copied from interface: ArtifactContentReader
      Get the concerned artifact file type.
      Specified by:
      getArtifactFileType in interface ArtifactContentReader
      Returns:
      the artifact file type
    • readFirstEntry

      public <T> Optional<T> readFirstEntry(org.apache.maven.artifact.Artifact artifact, Predicate<Path> predicateOnPath, Function<ArtifactContentReader.Entry,T> reader) throws IOException
      Description copied from interface: ArtifactContentReader
      Read the (compiled) content of the first artifact entry which satisfy the path predicate.

      You must close the requested input stream in the reader.

      Specified by:
      readFirstEntry in interface ArtifactContentReader
      Parameters:
      artifact - the artifact to read (with adequate file type)
      predicateOnPath - the predicate to test on the entry path
      reader - the reading job which will eventually consume the valid entry content and transform it
      Returns:
      the result of the reading job, empty when no valid entry was found
      Throws:
      IOException - exception reading artifact content
    • readEntries

      public <R, A> R readEntries(org.apache.maven.artifact.Artifact artifact, Predicate<Path> predicateOnPath, Collector<ArtifactContentReader.Entry,A,R> reader) throws IOException
      Description copied from interface: ArtifactContentReader
      Read the (compiled) content of the artifact entries which satisfy the path predicate.

      You must close the requested input stream in the reader.

      Specified by:
      readEntries in interface ArtifactContentReader
      Parameters:
      artifact - the artifact to read (with adequate file type)
      predicateOnPath - the predicate to test on the entry path
      reader - the reading job which will eventually consume each valid entry content and collect the result
      Returns:
      the result collected by the reader
      Throws:
      IOException - exception reading artifact content
    • readEntries

      public void readEntries(org.apache.maven.artifact.Artifact artifact, Predicate<Path> predicateOnPath, Consumer<ArtifactContentReader.Entry> reader) throws IOException
      Description copied from interface: ArtifactContentReader
      Read the (compiled) content of the artifact entries which satisfy the path predicate.

      You must close the requested input stream in the reader.

      Specified by:
      readEntries in interface ArtifactContentReader
      Parameters:
      artifact - the artifact to read (with adequate file type)
      predicateOnPath - the predicate to test on the entry path
      reader - the reading job which will eventually consume each valid entry content
      Throws:
      IOException - exception reading artifact content
    • detectImplementationHierarchy

      public Set<String> detectImplementationHierarchy(String className, org.apache.maven.artifact.Artifact artifact, Consumer<ClassNotFoundException> exceptionHandler) throws UnsupportedOperationException
      Description copied from interface: ArtifactContentReader
      Detect the implementation hierarchy of a java class in the artifact.

      Some implementations may not support this method for their artifact file type.

      Specified by:
      detectImplementationHierarchy in interface ArtifactContentReader
      Parameters:
      className - the name of the class to analyze
      artifact - the artifact to read (with adequate file type)
      exceptionHandler - handles any ClassNotFoundException while loading classes
      Returns:
      set of class names in the implementation's parent hierarchy
      Throws:
      UnsupportedOperationException - when the implementation does not support this method