Package io.github.classgraph
Class ClasspathElementDir
- java.lang.Object
-
- io.github.classgraph.ClasspathElement
-
- io.github.classgraph.ClasspathElementDir
-
- All Implemented Interfaces:
java.lang.Comparable<ClasspathElement>
class ClasspathElementDir extends ClasspathElement
A directory classpath element, using thePath
API.
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.file.Path
classpathEltPath
The directory at the root of the classpath element.private NestedJarHandler
nestedJarHandler
The nested jar handler.private java.util.Set<java.nio.file.Path>
scannedCanonicalPaths
Used to ensure that recursive scanning doesn't get into an infinite loop due to a link cycle.-
Fields inherited from class io.github.classgraph.ClasspathElement
acceptedClassfileResources, acceptedResources, childClasspathElements, classLoader, classpathElementIdx, classpathElementIdxWithinParent, containsSpecificallyAcceptedClasspathElementResourcePath, fileToLastModified, moduleNameFromModuleDescriptor, nestedClasspathRootPrefixes, packageRootPrefix, scanned, scanSpec, skipClasspathElement
-
-
Constructor Summary
Constructors Constructor Description ClasspathElementDir(Scanner.ClasspathEntryWorkUnit workUnit, NestedJarHandler nestedJarHandler, ScanSpec scanSpec)
A directory classpath element.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object obj)
(package private) java.util.List<java.net.URI>
getAllURIs()
Get the URI for this classpath element, and the URIs for any automatic nested package prefixes (e.g.java.io.File
getFile()
Get the directoryFile
.java.lang.String
getModuleName()
Get the module name from module descriptor.(package private) Resource
getResource(java.lang.String relativePath)
Get theResource
for a given relative path.(package private) java.net.URI
getURI()
Get the URI for this classpath element.int
hashCode()
private Resource
newResource(java.nio.file.Path resourcePath, NestedJarHandler nestedJarHandler)
Create a newResource
object for a resource or classfile discovered while scanning paths.(package private) void
open(WorkQueue<Scanner.ClasspathEntryWorkUnit> workQueue, LogNode log)
Determine if this classpath element is valid.private void
scanPathRecursively(java.nio.file.Path path, LogNode log)
Recursively scan aPath
for sub-path patterns matching the scan spec.(package private) void
scanPaths(LogNode log)
Hierarchically scan directory structure for classfiles and matching files.java.lang.String
toString()
Return the classpath element directory as a String.-
Methods inherited from class io.github.classgraph.ClasspathElement
addAcceptedResource, checkResourcePathAcceptReject, compareTo, finishScanPaths, getClassLoader, getNumClassfileMatches, log, log, maskClassfiles
-
-
-
-
Field Detail
-
classpathEltPath
private final java.nio.file.Path classpathEltPath
The directory at the root of the classpath element.
-
scannedCanonicalPaths
private final java.util.Set<java.nio.file.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 Detail
-
ClasspathElementDir
ClasspathElementDir(Scanner.ClasspathEntryWorkUnit workUnit, NestedJarHandler nestedJarHandler, ScanSpec scanSpec)
A directory classpath element.- Parameters:
workUnit
- the work unit -- workUnit.classpathEntryObj must be aPath
objectnestedJarHandler
- the nested jar handlerscanSpec
- the scan spec
-
-
Method Detail
-
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. ForClasspathElementZip
, 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 classClasspathElement
- Parameters:
workQueue
- the work queuelog
- the log
-
newResource
private Resource newResource(java.nio.file.Path resourcePath, NestedJarHandler nestedJarHandler)
Create a newResource
object for a resource or classfile discovered while scanning paths.- Parameters:
resourcePath
- thePath
for the resourcenestedJarHandler
- the nested jar handler- Returns:
- the resource
-
getResource
Resource getResource(java.lang.String relativePath)
Get theResource
for a given relative path.- Specified by:
getResource
in classClasspathElement
- Parameters:
relativePath
- The relative path of theResource
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(java.nio.file.Path path, LogNode log)
Recursively scan aPath
for sub-path patterns matching the scan spec.- Parameters:
path
- thePath
log
- the log
-
scanPaths
void scanPaths(LogNode log)
Hierarchically scan directory structure for classfiles and matching files.- Specified by:
scanPaths
in classClasspathElement
- Parameters:
log
- the log
-
getModuleName
public java.lang.String getModuleName()
Get the module name from module descriptor.- Specified by:
getModuleName
in classClasspathElement
- Returns:
- the module name
-
getFile
public java.io.File getFile()
Get the directoryFile
.- Specified by:
getFile
in classClasspathElement
- Returns:
- The classpath element directory as a
File
, or null if this classpath element is not backed by a directory (should not happen).
-
getURI
java.net.URI getURI()
Description copied from class:ClasspathElement
Get the URI for this classpath element.- Specified by:
getURI
in classClasspathElement
- Returns:
- the URI for the classpath element.
-
getAllURIs
java.util.List<java.net.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 classClasspathElement
- Returns:
- the URI for the classpath element.
-
toString
public java.lang.String toString()
Return the classpath element directory as a String.- Overrides:
toString
in classjava.lang.Object
- Returns:
- the string
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-