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 thePathAPI.
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.file.PathclasspathEltPathThe directory at the root of the classpath element.private NestedJarHandlernestedJarHandlerThe nested jar handler.private java.util.Set<java.nio.file.Path>scannedCanonicalPathsUsed 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, scanResult, 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 booleanequals(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.FilegetFile()Get the directoryFile.java.lang.StringgetModuleName()Get the module name from module descriptor.(package private) ResourcegetResource(java.lang.String relativePath)Get theResourcefor a given relative path.(package private) java.net.URIgetURI()Get the URI for this classpath element.inthashCode()private ResourcenewResource(java.nio.file.Path resourcePath, java.nio.file.attribute.BasicFileAttributes attributes)Create a newResourceobject for a resource or classfile discovered while scanning paths.(package private) voidopen(WorkQueue<Scanner.ClasspathEntryWorkUnit> workQueue, LogNode log)Determine if this classpath element is valid.private voidscanPathRecursively(java.nio.file.Path path, LogNode log)Recursively scan aPathfor sub-path patterns matching the scan spec.(package private) voidscanPaths(LogNode log)Hierarchically scan directory structure for classfiles and matching files.java.lang.StringtoString()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, setScanResult
-
-
-
-
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 aPathobjectnestedJarHandler- the nested jar handlerscanSpec- the scan spec
-
-
Method Detail
-
open
void open(WorkQueue<Scanner.ClasspathEntryWorkUnit> workQueue, LogNode log)
Description copied from class:ClasspathElementDetermine 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:
openin classClasspathElement- Parameters:
workQueue- the work queuelog- the log
-
newResource
private Resource newResource(java.nio.file.Path resourcePath, java.nio.file.attribute.BasicFileAttributes attributes)
Create a newResourceobject for a resource or classfile discovered while scanning paths.- Parameters:
resourcePath- thePathfor the resource- Returns:
- the resource
-
getResource
Resource getResource(java.lang.String relativePath)
Get theResourcefor a given relative path.- Specified by:
getResourcein classClasspathElement- Parameters:
relativePath- The relative path of theResourceto return.- Returns:
- The
Resourcefor 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 aPathfor sub-path patterns matching the scan spec.- Parameters:
path- thePathlog- the log
-
scanPaths
void scanPaths(LogNode log)
Hierarchically scan directory structure for classfiles and matching files.- Specified by:
scanPathsin classClasspathElement- Parameters:
log- the log
-
getModuleName
public java.lang.String getModuleName()
Get the module name from module descriptor.- Specified by:
getModuleNamein classClasspathElement- Returns:
- the module name
-
getFile
public java.io.File getFile()
Get the directoryFile.- Specified by:
getFilein 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:ClasspathElementGet the URI for this classpath element.- Specified by:
getURIin classClasspathElement- Returns:
- the URI for the classpath element.
-
getAllURIs
java.util.List<java.net.URI> getAllURIs()
Description copied from class:ClasspathElementGet 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:
getAllURIsin classClasspathElement- Returns:
- the URI for the classpath element.
-
toString
public java.lang.String toString()
Return the classpath element directory as a String.- Overrides:
toStringin classjava.lang.Object- Returns:
- the string
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
-