Class ClassPath.LocationInfo

  • Enclosing class:
    ClassPath

    static final class ClassPath.LocationInfo
    extends java.lang.Object
    Represents a single location (a directory or a jar file) in the class path and is responsible for scanning resources from this location.
    • Field Detail

      • home

        final java.io.File home
      • classloader

        private final java.lang.ClassLoader classloader
    • Constructor Detail

      • LocationInfo

        LocationInfo​(java.io.File home,
                     java.lang.ClassLoader classloader)
    • Method Detail

      • file

        public final java.io.File file()
        Returns the file this location is from.
      • scanResources

        public ImmutableSet<ClassPath.ResourceInfo> scanResources()
                                                           throws java.io.IOException
        Scans this location and returns all scanned resources.
        Throws:
        java.io.IOException
      • scanResources

        public ImmutableSet<ClassPath.ResourceInfo> scanResources​(java.util.Set<java.io.File> scannedFiles)
                                                           throws java.io.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 if scannedFiles already contains it.

        Throws:
        java.io.IOException
      • scanDirectory

        private void scanDirectory​(java.io.File directory,
                                   java.lang.String packagePrefix,
                                   java.util.Set<java.io.File> currentPath,
                                   ImmutableSet.Builder<ClassPath.ResourceInfo> builder)
                            throws java.io.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 scan
        packagePrefix - resource path prefix inside classloader for any files found under directory
        currentPath - canonical files already visited in the current directory tree path, for cycle elimination
        Throws:
        java.io.IOException
      • equals

        public boolean equals​(@CheckForNull
                              java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object