Package com.google.common.reflect
Class ClassPath.Scanner
- java.lang.Object
-
- com.google.common.reflect.ClassPath.Scanner
-
- Direct Known Subclasses:
ClassPath.DefaultScanner
- Enclosing class:
- ClassPath
abstract static class ClassPath.Scanner extends java.lang.Object
Abstract class that scans through the class path represented by aClassLoader
and callsscanDirectory(java.lang.ClassLoader, java.io.File)
andscanJarFile(java.lang.ClassLoader, java.util.jar.JarFile)
for directories and jar files on the class path respectively.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<java.io.File>
scannedUris
-
Constructor Summary
Constructors Constructor Description Scanner()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) static ImmutableMap<java.io.File,java.lang.ClassLoader>
getClassPathEntries(java.lang.ClassLoader classloader)
(package private) static java.net.URL
getClassPathEntry(java.io.File jarFile, java.lang.String path)
Returns the absolute uri of the Class-Path entry value as specified in JAR File Specification.(package private) static ImmutableSet<java.io.File>
getClassPathFromManifest(java.io.File jarFile, java.util.jar.Manifest manifest)
Returns the class path URIs specified by theClass-Path
manifest attribute, according to JAR File Specification.(package private) void
scan(java.io.File file, java.lang.ClassLoader classloader)
void
scan(java.lang.ClassLoader classloader)
protected abstract void
scanDirectory(java.lang.ClassLoader loader, java.io.File directory)
Called when a directory is scanned for resource files.private void
scanFrom(java.io.File file, java.lang.ClassLoader classloader)
private void
scanJar(java.io.File file, java.lang.ClassLoader classloader)
protected abstract void
scanJarFile(java.lang.ClassLoader loader, java.util.jar.JarFile file)
Called when a jar file is scanned for resource entries.
-
-
-
Method Detail
-
scan
public final void scan(java.lang.ClassLoader classloader) throws java.io.IOException
- Throws:
java.io.IOException
-
scanDirectory
protected abstract void scanDirectory(java.lang.ClassLoader loader, java.io.File directory) throws java.io.IOException
Called when a directory is scanned for resource files.- Throws:
java.io.IOException
-
scanJarFile
protected abstract void scanJarFile(java.lang.ClassLoader loader, java.util.jar.JarFile file) throws java.io.IOException
Called when a jar file is scanned for resource entries.- Throws:
java.io.IOException
-
scan
final void scan(java.io.File file, java.lang.ClassLoader classloader) throws java.io.IOException
- Throws:
java.io.IOException
-
scanFrom
private void scanFrom(java.io.File file, java.lang.ClassLoader classloader) throws java.io.IOException
- Throws:
java.io.IOException
-
scanJar
private void scanJar(java.io.File file, java.lang.ClassLoader classloader) throws java.io.IOException
- Throws:
java.io.IOException
-
getClassPathFromManifest
static ImmutableSet<java.io.File> getClassPathFromManifest(java.io.File jarFile, @Nullable java.util.jar.Manifest manifest)
Returns the class path URIs specified by theClass-Path
manifest attribute, according to JAR File Specification. Ifmanifest
is null, it means the jar file has no manifest, and an empty set will be returned.
-
getClassPathEntries
static ImmutableMap<java.io.File,java.lang.ClassLoader> getClassPathEntries(java.lang.ClassLoader classloader)
-
getClassPathEntry
static java.net.URL getClassPathEntry(java.io.File jarFile, java.lang.String path) throws java.net.MalformedURLException
Returns the absolute uri of the Class-Path entry value as specified in JAR File Specification. Even though the specification only talks about relative urls, absolute urls are actually supported too (for example, in Maven surefire plugin).- Throws:
java.net.MalformedURLException
-
-