- All Superinterfaces:
AutoCloseable,Closeable
- All Known Implementing Classes:
JarFileResourceLoader,PathResourceLoader,URLResourceLoader
A loader which can find resources by their path.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ResourceLoaderA resource loader containing no resources. -
Method Summary
Modifier and TypeMethodDescriptiondefault URLbaseUrl()Returns the base URL for this loader.default voidclose()Release any system resources or allocations associated with this resource loader.findResource(String path) Find a resource from this loader.default ResourceLoadergetChildLoader(String path) Get a child resource loader for the given child path.default Manifestmanifest()Get the manifest for this resource loader, if any.default voidrelease()Hint that this resource loader is unlikely to be used in the near future.
-
Field Details
-
EMPTY
A resource loader containing no resources.
-
-
Method Details
-
findResource
Find a resource from this loader.- Parameters:
path- the resource path (must not benull)- Returns:
- the loaded resource, or
nullif no resource is found at the given path - Throws:
IOException- if the resource could not be loaded
-
baseUrl
Returns the base URL for this loader.- Returns:
- the base URL for this loader
-
getChildLoader
Get a child resource loader for the given child path. This method always returns a resource loader, even if the path does not exist. Closing the child loader does not close the enclosing loader.- Parameters:
path- the relative sub-path (must not benull)- Returns:
- the resource loader (not
null, may be empty)
-
manifest
Get the manifest for this resource loader, if any. The default implementation constructs a new instance every time, so the caller should avoid repeated invocation of this method, caching as needed.- Returns:
- the manifest, or
nullif no manifest was found - Throws:
IOException- if the manifest resource could not be loaded
-
release
default void release()Hint that this resource loader is unlikely to be used in the near future. -
close
default void close()Release any system resources or allocations associated with this resource loader.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-