Package org.openstreetmap.josm.tools
Class ResourceProvider
java.lang.Object
org.openstreetmap.josm.tools.ResourceProvider
Unified provider that looks up for resource in various classloaders (josm, plugins, etc.).
- Since:
- 15416
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Set<ClassLoader>set of class loaders to take resources from -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanaddAdditionalClassLoader(ClassLoader additionalClassLoader) Add an additional class loader to search image for.static booleanaddAdditionalClassLoaders(Collection<ClassLoader> additionalClassLoaders) Add a collection of additional class loaders to search image for.private static <T> TgetFirstNotNull(Function<ClassLoader, T> function) static URLgetResource(String name) Finds the resource with the given name.static InputStreamgetResourceAsStream(String name) Finds a resource with a given name, with robustness to known JDK bugs.
-
Field Details
-
classLoaders
set of class loaders to take resources from
-
-
Constructor Details
-
ResourceProvider
private ResourceProvider()
-
-
Method Details
-
addAdditionalClassLoader
Add an additional class loader to search image for.- Parameters:
additionalClassLoader- class loader to add to the internal set- Returns:
trueif the set changed as a result of the call
-
addAdditionalClassLoaders
Add a collection of additional class loaders to search image for.- Parameters:
additionalClassLoaders- class loaders to add to the internal set- Returns:
trueif the set changed as a result of the call
-
getFirstNotNull
-
getResource
Finds the resource with the given name.- Parameters:
name- The resource name- Returns:
- A
URLobject for reading the resource, ornullif the resource could not be found or the invoker doesn't have adequate privileges to get the resource. - See Also:
-
getResourceAsStream
Finds a resource with a given name, with robustness to known JDK bugs.- Parameters:
name- name of the desired resource- Returns:
- A
InputStreamobject ornullif no resource with this name is found
-