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.ObjectAbstract class that scans through the class path represented by aClassLoaderand 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 private static ImmutableList<java.net.URL>getClassLoaderUrls(java.lang.ClassLoader classloader)(package private) static ImmutableMap<java.io.File,java.lang.ClassLoader>getClassPathEntries(java.lang.ClassLoader classloader)(package private) static java.net.URLgetClassPathEntry(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-Pathmanifest attribute, according to JAR File Specification.(package private) static ImmutableList<java.net.URL>parseJavaClassPath()Returns the URLs in the class path specified by thejava.class.pathsystem property.(package private) voidscan(java.io.File file, java.lang.ClassLoader classloader)voidscan(java.lang.ClassLoader classloader)protected abstract voidscanDirectory(java.lang.ClassLoader loader, java.io.File directory)Called when a directory is scanned for resource files.private voidscanFrom(java.io.File file, java.lang.ClassLoader classloader)private voidscanJar(java.io.File file, java.lang.ClassLoader classloader)protected abstract voidscanJarFile(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
-
scan
final void scan(java.io.File file, 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.IOExceptionCalled 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.IOExceptionCalled when a jar file is scanned for resource entries.- 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, java.util.jar.Manifest manifest)
Returns the class path URIs specified by theClass-Pathmanifest attribute, according to JAR File Specification. Ifmanifestis 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)
-
getClassLoaderUrls
private static ImmutableList<java.net.URL> getClassLoaderUrls(java.lang.ClassLoader classloader)
-
parseJavaClassPath
static ImmutableList<java.net.URL> parseJavaClassPath()
Returns the URLs in the class path specified by thejava.class.pathsystem property.
-
getClassPathEntry
static java.net.URL getClassPathEntry(java.io.File jarFile, java.lang.String path) throws java.net.MalformedURLExceptionReturns 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
-
-