Package com.google.common.reflect
Class ClassPath.LocationInfo
java.lang.Object
com.google.common.reflect.ClassPath.LocationInfo
- Enclosing class:
ClassPath
Represents a single location (a directory or a jar file) in the class path and is responsible
for scanning resources from this location.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
final File
file()
Returns the file this location is from.int
hashCode()
private void
scan
(File file, Set<File> scannedUris, ImmutableSet.Builder<ClassPath.ResourceInfo> builder) private void
scanDirectory
(File directory, ImmutableSet.Builder<ClassPath.ResourceInfo> builder) private void
scanDirectory
(File directory, String packagePrefix, Set<File> currentPath, ImmutableSet.Builder<ClassPath.ResourceInfo> builder) Recursively scan the given directory, adding resources for each file encountered.private void
scanJar
(File file, Set<File> scannedUris, ImmutableSet.Builder<ClassPath.ResourceInfo> builder) private void
scanJarFile
(JarFile file, ImmutableSet.Builder<ClassPath.ResourceInfo> builder) Scans this location and returns all scanned resources.scanResources
(Set<File> scannedFiles) Scans this location and returns all scanned resources.toString()
-
Field Details
-
home
-
classloader
-
-
Constructor Details
-
LocationInfo
LocationInfo(File home, ClassLoader classloader)
-
-
Method Details
-
file
Returns the file this location is from. -
scanResources
Scans this location and returns all scanned resources.- Throws:
IOException
-
scanResources
public ImmutableSet<ClassPath.ResourceInfo> scanResources(Set<File> scannedFiles) throws IOException Scans this location and returns all scanned resources.This file and jar files from "Class-Path" entry in the scanned manifest files will be added to
scannedFiles
.A file will be scanned at most once even if specified multiple times by one or multiple jar files' "Class-Path" manifest entries. Particularly, if a jar file from the "Class-Path" manifest entry is already in
scannedFiles
, either because it was scanned earlier, or it was intentionally added to the set by the caller, it will not be scanned again.Note that when you call
location.scanResources(scannedFiles)
, the location will always be scanned even ifscannedFiles
already contains it.- Throws:
IOException
-
scan
private void scan(File file, Set<File> scannedUris, ImmutableSet.Builder<ClassPath.ResourceInfo> builder) throws IOException - Throws:
IOException
-
scanJar
private void scanJar(File file, Set<File> scannedUris, ImmutableSet.Builder<ClassPath.ResourceInfo> builder) throws IOException - Throws:
IOException
-
scanJarFile
-
scanDirectory
private void scanDirectory(File directory, ImmutableSet.Builder<ClassPath.ResourceInfo> builder) throws IOException - Throws:
IOException
-
scanDirectory
private void scanDirectory(File directory, String packagePrefix, Set<File> currentPath, ImmutableSet.Builder<ClassPath.ResourceInfo> builder) throws IOException Recursively scan the given directory, adding resources for each file encountered. Symlinks which have already been traversed in the current tree path will be skipped to eliminate cycles; otherwise symlinks are traversed.- Parameters:
directory
- the root of the directory to scanpackagePrefix
- resource path prefix insideclassloader
for any files found underdirectory
currentPath
- canonical files already visited in the current directory tree path, for cycle elimination- Throws:
IOException
-
equals
-
hashCode
public int hashCode() -
toString
-