Class Digger

java.lang.Object
clazzfish.core.Digger
Direct Known Subclasses:
ClasspathDigger

public class Digger extends Object
The Class Digger was extracted from ClasspathDigger and ResourcepathDigger. It is intended to pull up common code of both classes into this class to avoid code duplicates.

For later it is planned to derive ClasspathDigger from ResourepathDigger (the other way around at now), because a class can be considered as specialized resource (resource with suffix ".class").

Originally this class was part of the PatternTesting project.

Author:
oboehm
  • Constructor Details

    • Digger

      public Digger()
    • Digger

      public Digger(ClassLoading classLoading)
  • Method Details

    • resourceToClass

      public static String resourceToClass(String name)
      Converts a resource (e.g. "/java/lang/String.class") into its classname ("java.lang.String").
      Parameters:
      name - e.g. "/java/lang/String.class"
      Returns:
      e.g. "java.lang.String"
    • getClasspath

      public String[] getClasspath()
      Gets the classpath using the ClasspathInspector.
      Returns:
      the classpath
    • getLoadedClassnames

      public String[] getLoadedClassnames()
    • getClasses

      public String[] getClasses()
      Digs into the classpath and returns the found classes.

      NOTE: This logic was formerly part of ClasspathDigger in the monitor module.

      Returns:
      classes of the classpath
    • getClassRecords

      public Set<ClazzRecord> getClassRecords()
      Digs into the classpath and returns the found classes together with the URI of the classpath where the class belongs to. Shaded classes (see getShadedRecords()) are not part of the returned set.
      Returns:
      classes of the classpath (without shadowed classes)
    • getShadedRecords

      public Set<ClazzRecord> getShadedRecords()
      Shadowed classes are classes which are more than once in the classpath and which are shadowed by another class. I.e. these are classes which are on position 2 (or higher) in the classpath which will be never loaded by the classloader.
      Returns:
      set of shadowed classes
    • readElementsFromNestedArchive

      public static Collection<String> readElementsFromNestedArchive(File archive) throws IOException
      Read elements from nested archive.
      Parameters:
      archive - a JAR, WAR or EAR archive
      Returns:
      the digged resources
      Throws:
      IOException - Signals that an I/O exception has occurred.