Interface ResourceAccessor

    • Method Detail

      • openStreams

        @Deprecated
        default InputStreamList openStreams​(String relativeTo,
                                            String streamPath)
                                     throws IOException
        Return the streams for each resource mapped by the given path. The path is often a URL but does not have to be. Should accept both / and \ chars for file paths to be platform-independent. If path points to a compressed resource, return a stream of the uncompressed contents of the file. Returns InputStreamList since multiple resources can map to the same path, such as "META-INF/MAINFEST.MF". Remember to close streams when finished with them.
        Parameters:
        relativeTo - Location that streamPath should be found relative to. If null, streamPath is an absolute path
        Returns:
        Empty list if the resource does not exist.
        Throws:
        IOException - if there is an error reading an existing path.
      • list

        @Deprecated
        default SortedSet<String> list​(String relativeTo,
                                       String path,
                                       boolean recursive,
                                       boolean includeFiles,
                                       boolean includeDirectories)
                                throws IOException
        Deprecated.
        Returns the path to all resources contained in the given path. The passed path is not included in the returned set. Returned strings should use "/" for file path separators, regardless of the OS and should accept both / and \ chars for file paths to be platform-independent. Returned set is sorted, normally alphabetically but subclasses can use different comparators. The values returned should be able to be passed into openStreams(String, String) and return the contents. Returned paths should normally be root-relative and therefore not be an absolute path, unless there is a good reason to be absolute.

        Default implementation calls search(String, boolean) and collects the paths from the resources. Because the new method no longer supports listing directories, it will silently ignore the includeDirectories argument UNLESS includeFiles is false. In that case, it will throw an exception.

        Parameters:
        relativeTo - Location that streamPath should be found relative to. If null, path is an absolute path
        path - The path to lookup resources in.
        recursive - Set to true and will return paths to contents in sub directories as well.
        includeFiles - Set to true and will return paths to files.
        includeDirectories - Set to true and will return paths to directories.
        Returns:
        empty set if nothing was found
        Throws:
        IOException - if there is an error reading an existing root.
      • search

        default List<Resource> search​(String path,
                                      ResourceAccessor.SearchOptions searchOptions)
                               throws IOException
        Returns the path to all resources contained in the given path that match the searchOptions criteria. Multiple resources may be returned with the same path, but only if they are actually unique files. Order is important to pay attention to, they should be returned in a user-expected manner based on this resource accessor.

        Should return an empty list if:
        • Path does not exist or maxDepth less or equals than zero
        Should throw an exception if:
        • Path is null
        • Path is not a "directory"
        • Path exists but cannot be read from
        Parameters:
        path - The path to lookup resources in.
        searchOptions - A set of criteria for how resources should be found/filtered
        Returns:
        empty set if nothing was found
        Throws:
        IOException - if there is an error searching the system.
      • search

        List<Resource> search​(String path,
                              boolean recursive)
                       throws IOException
        Returns the path to all resources contained in the given path. Multiple resources may be returned with the same path, but only if they are actually unique files. Order is important to pay attention to, they should be returned in a user-expected manner based on this resource accessor.

        Should return an empty list if:
        • Path does not exist
        Should throw an exception if:
        • Path is null
        • Path is not a "directory"
        • Path exists but cannot be read from
        Parameters:
        path - The path to lookup resources in.
        recursive - Set to true and will return paths to contents in subdirectories as well.
        Returns:
        empty set if nothing was found
        Throws:
        IOException - if there is an error searching the system.
      • getAll

        List<Resource> getAll​(String path)
                       throws IOException
        Returns all Resources at the given path. For many resource accessors (such as a file system), only one resource can exist at a given spot, but some accessors (such as CompositeResourceAccessor or ClassLoaderResourceAccessor) can have multiple resources for a single path.

        If the resourceAccessor returns multiple values, the returned List should be considered sorted for that resource accessor. For example, ClassLoaderResourceAccessor returns them in order based on the configured classloader. Order is important to pay attention to, because users may set GlobalConfiguration.DUPLICATE_FILE_MODE to pick the "best" file which is defined as "the first file from this function".

        Returns:
        null if no resources match the path
        Throws:
        IOException - if there is an unexpected error determining what is at the path
      • describeLocations

        List<String> describeLocations()
        Returns a description of the places this classloader will look for paths. Used in error messages and other troubleshooting cases.