Package io.github.classgraph
Class ClasspathElementZip
- java.lang.Object
-
- io.github.classgraph.ClasspathElement
-
- io.github.classgraph.ClasspathElementZip
-
- All Implemented Interfaces:
java.lang.Comparable<ClasspathElement>
class ClasspathElementZip extends ClasspathElement
A zip/jarfile classpath element.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringderivedAutomaticModuleNameThe automatic module name, derived from the jarfile filename.(package private) LogicalZipFilelogicalZipFileThe logical zipfile for this classpath element.(package private) java.lang.StringmoduleNameFromManifestFileThe name of the module from theAutomatic-Module-Namemanifest attribute, if one is present in the root of the classpath element.private NestedJarHandlernestedJarHandlerThe nested jar handler.private java.lang.StringrawPathTheStringrepresentation of the path string,URL,URI, orPathfor this zipfile.private java.util.concurrent.ConcurrentHashMap<java.lang.String,Resource>relativePathToResourceA map from relative path toResourcefor non-rejected zip entries.private java.util.Set<java.lang.String>strippedAutomaticPackageRootPrefixesA list of all automatic package root prefixes found as prefixes of paths within this zipfile.private java.lang.StringzipFilePathThe normalized path of the jarfile, "!/"-separated if nested, excluding any package root.-
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 ClasspathElementZip(Scanner.ClasspathEntryWorkUnit workUnit, NestedJarHandler nestedJarHandler, ScanSpec scanSpec)A jarfile 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()Return URI for classpath element, plus URIs for any stripped nested automatic package root prefixes, e.g.(package private) java.io.FilegetFile()Get theFilefor the outermost zipfile of this classpath element.java.lang.StringgetModuleName()Get module name from module descriptor, or get the automatic module name from the manifest file, or derive an automatic module name from the jar name.(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.(package private) java.lang.StringgetZipFilePath()Get the zipfile path.inthashCode()private ResourcenewResource(FastZipEntry zipEntry, java.lang.String pathRelativeToPackageRoot)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.(package private) voidscanPaths(LogNode log)Scan for path matches within jarfile, and record ZipEntry objects of matching files.java.lang.StringtoString()Return the classpath element path.-
Methods inherited from class io.github.classgraph.ClasspathElement
addAcceptedResource, checkResourcePathAcceptReject, compareTo, finishScanPaths, getClassLoader, getNumClassfileMatches, log, log, maskClassfiles, setScanResult
-
-
-
-
Field Detail
-
rawPath
private final java.lang.String rawPath
TheStringrepresentation of the path string,URL,URI, orPathfor this zipfile.
-
logicalZipFile
LogicalZipFile logicalZipFile
The logical zipfile for this classpath element.
-
zipFilePath
private java.lang.String zipFilePath
The normalized path of the jarfile, "!/"-separated if nested, excluding any package root.
-
relativePathToResource
private final java.util.concurrent.ConcurrentHashMap<java.lang.String,Resource> relativePathToResource
A map from relative path toResourcefor non-rejected zip entries.
-
strippedAutomaticPackageRootPrefixes
private final java.util.Set<java.lang.String> strippedAutomaticPackageRootPrefixes
A list of all automatic package root prefixes found as prefixes of paths within this zipfile.
-
nestedJarHandler
private final NestedJarHandler nestedJarHandler
The nested jar handler.
-
moduleNameFromManifestFile
java.lang.String moduleNameFromManifestFile
The name of the module from theAutomatic-Module-Namemanifest attribute, if one is present in the root of the classpath element.
-
derivedAutomaticModuleName
private java.lang.String derivedAutomaticModuleName
The automatic module name, derived from the jarfile filename.
-
-
Constructor Detail
-
ClasspathElementZip
ClasspathElementZip(Scanner.ClasspathEntryWorkUnit workUnit, NestedJarHandler nestedJarHandler, ScanSpec scanSpec)
A jarfile classpath element.- Parameters:
workUnit- the work unitnestedJarHandler- the nested jar handlerscanSpec- the scan spec
-
-
Method Detail
-
open
void open(WorkQueue<Scanner.ClasspathEntryWorkUnit> workQueue, LogNode log) throws java.lang.InterruptedException
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- Throws:
java.lang.InterruptedException- if the thread was interrupted while trying to open the classpath element.
-
newResource
private Resource newResource(FastZipEntry zipEntry, java.lang.String pathRelativeToPackageRoot)
Create a newResourceobject for a resource or classfile discovered while scanning paths.- Parameters:
zipEntry- the zip entrypathRelativeToPackageRoot- the path relative to package root- 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.
-
scanPaths
void scanPaths(LogNode log)
Scan for path matches within jarfile, and record ZipEntry objects of matching files.- Specified by:
scanPathsin classClasspathElement- Parameters:
log- the log
-
getModuleName
public java.lang.String getModuleName()
Get module name from module descriptor, or get the automatic module name from the manifest file, or derive an automatic module name from the jar name.- Specified by:
getModuleNamein classClasspathElement- Returns:
- the module name
-
getZipFilePath
java.lang.String getZipFilePath()
Get the zipfile path.- Returns:
- the path of the zipfile, including any package root.
-
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()
Return URI for classpath element, plus URIs for any stripped nested automatic package root prefixes, e.g. "!/BOOT-INF/classes".- Specified by:
getAllURIsin classClasspathElement- Returns:
- the URI for the classpath element.
-
getFile
java.io.File getFile()
Get theFilefor the outermost zipfile of this classpath element.- Specified by:
getFilein classClasspathElement- Returns:
- The
Filefor the outermost zipfile of this classpath element, or null if this file was downloaded from a URL directly to RAM, or if the classpath element was backed by a custom filesystem that supports thePathAPI put not theFileAPI.
-
toString
public java.lang.String toString()
Return the classpath element path.- Overrides:
toStringin classjava.lang.Object- Returns:
- the string
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-