Class ClasspathElementDir

java.lang.Object
io.github.classgraph.ClasspathElement
io.github.classgraph.ClasspathElementDir
All Implemented Interfaces:
Comparable<ClasspathElement>

class ClasspathElementDir extends ClasspathElement
A directory classpath element, using the Path API.
  • Field Details

    • classpathEltPath

      private final Path classpathEltPath
      The directory at the root of the classpath element.
    • scannedCanonicalPaths

      private final Set<Path> scannedCanonicalPaths
      Used to ensure that recursive scanning doesn't get into an infinite loop due to a link cycle.
    • nestedJarHandler

      private final NestedJarHandler nestedJarHandler
      The nested jar handler.
  • Constructor Details

    • ClasspathElementDir

      ClasspathElementDir(Scanner.ClasspathEntryWorkUnit workUnit, NestedJarHandler nestedJarHandler, ScanSpec scanSpec)
      A directory classpath element.
      Parameters:
      workUnit - the work unit -- workUnit.classpathEntryObj must be a Path object
      nestedJarHandler - the nested jar handler
      scanSpec - the scan spec
  • Method Details

    • open

      void open(WorkQueue<Scanner.ClasspathEntryWorkUnit> workQueue, LogNode log)
      Description copied from class: ClasspathElement
      Determine if this classpath element is valid. If it is not valid, sets skipClasspathElement. For ClasspathElementZip, may also open or extract inner jars, and also causes jarfile manifests to be read to look for Class-Path entries. If nested jars or Class-Path entries are found, they are added to the work queue. This method is only run once per classpath element, from a single thread.
      Specified by:
      open in class ClasspathElement
      Parameters:
      workQueue - the work queue
      log - the log
    • newResource

      private Resource newResource(Path resourcePath, NestedJarHandler nestedJarHandler)
      Create a new Resource object for a resource or classfile discovered while scanning paths.
      Parameters:
      resourcePath - the Path for the resource
      nestedJarHandler - the nested jar handler
      Returns:
      the resource
    • getResource

      Resource getResource(String relativePath)
      Get the Resource for a given relative path.
      Specified by:
      getResource in class ClasspathElement
      Parameters:
      relativePath - The relative path of the Resource to return.
      Returns:
      The Resource for the given relative path, or null if relativePath does not exist in this classpath element.
    • scanPathRecursively

      private void scanPathRecursively(Path path, LogNode log)
      Recursively scan a Path for sub-path patterns matching the scan spec.
      Parameters:
      path - the Path
      log - the log
    • scanPaths

      void scanPaths(LogNode log)
      Hierarchically scan directory structure for classfiles and matching files.
      Specified by:
      scanPaths in class ClasspathElement
      Parameters:
      log - the log
    • getModuleName

      public String getModuleName()
      Get the module name from module descriptor.
      Specified by:
      getModuleName in class ClasspathElement
      Returns:
      the module name
    • getFile

      public File getFile()
      Get the directory File.
      Specified by:
      getFile in class ClasspathElement
      Returns:
      The classpath element directory as a File, or null if this classpath element is not backed by a directory (should not happen).
    • getURI

      URI getURI()
      Description copied from class: ClasspathElement
      Get the URI for this classpath element.
      Specified by:
      getURI in class ClasspathElement
      Returns:
      the URI for the classpath element.
    • getAllURIs

      List<URI> getAllURIs()
      Description copied from class: ClasspathElement
      Get the URI for this classpath element, and the URIs for any automatic nested package prefixes (e.g. "spring-boot.jar/BOOT-INF/classes") within this jarfile.
      Specified by:
      getAllURIs in class ClasspathElement
      Returns:
      the URI for the classpath element.
    • toString

      public String toString()
      Return the classpath element directory as a String.
      Overrides:
      toString in class Object
      Returns:
      the string
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object