Class ResourceProvider

java.lang.Object
org.openstreetmap.josm.tools.ResourceProvider

public final class ResourceProvider extends Object
Unified provider that looks up for resource in various classloaders (josm, plugins, etc.).
Since:
15416
  • Field Details

  • Constructor Details

  • Method Details

    • addAdditionalClassLoader

      public static boolean addAdditionalClassLoader(ClassLoader additionalClassLoader)
      Add an additional class loader to search image for.
      Parameters:
      additionalClassLoader - class loader to add to the internal set
      Returns:
      true if the set changed as a result of the call
    • addAdditionalClassLoaders

      public static boolean addAdditionalClassLoaders(Collection<ClassLoader> additionalClassLoaders)
      Add a collection of additional class loaders to search image for.
      Parameters:
      additionalClassLoaders - class loaders to add to the internal set
      Returns:
      true if the set changed as a result of the call
    • getFirstNotNull

      private static <T> T getFirstNotNull(Function<ClassLoader,T> function)
    • getResource

      public static URL getResource(String name)
      Finds the resource with the given name.
      Parameters:
      name - The resource name
      Returns:
      A URL object for reading the resource, or null if the resource could not be found or the invoker doesn't have adequate privileges to get the resource.
      See Also:
    • getResourceAsStream

      public static InputStream getResourceAsStream(String name)
      Finds a resource with a given name, with robustness to known JDK bugs.
      Parameters:
      name - name of the desired resource
      Returns:
      A InputStream object or null if no resource with this name is found