Class DefaultResourceResolver

java.lang.Object
com.helger.io.resourceresolver.DefaultResourceResolver
All Implemented Interfaces:
com.helger.base.log.IHasConditionalLogger

@Immutable public class DefaultResourceResolver extends Object implements com.helger.base.log.IHasConditionalLogger
A simple resource resolver that can handle URLs, JAR files and file system resources.
Since:
8.6.6
Author:
Philip Helger
  • Constructor Details

    • DefaultResourceResolver

      protected DefaultResourceResolver()
  • Method Details

    • isDebugResolve

      public static boolean isDebugResolve()
      Check if debug logging for resource resolving is enabled.
      Returns:
      true if debug resolving is enabled, false otherwise.
    • setDebugResolve

      public static void setDebugResolve(boolean bDebugResolve)
      Enable or disable debug logging for resource resolving.
      Parameters:
      bDebugResolve - true to enable debug resolving, false to disable it.
    • isExplicitJarFileResource

      public static boolean isExplicitJarFileResource(@Nullable String sName)
      Check if the passed resource name is an explicit JAR file resource. This includes resources starting with "jar:file:", "wsjar:file:" or "zip:file:".
      Parameters:
      sName - The name to check. May be null.
      Returns:
      true if the passed name is an explicit JAR file resource, false otherwise.
    • getResolvedResource

      public static @NonNull IReadableResource getResolvedResource(@Nullable String sSystemId, @Nullable String sBaseURI)
      Do the standard resource resolving of sSystemId relative to sBaseURI
      Parameters:
      sSystemId - The resource to search. May be null if base URI is set.
      sBaseURI - The base URI from where the search is initiated. May be null if systemId is set.
      Returns:
      The non-null resource. May be non-existing!
      Throws:
      UncheckedIOException - In case the file resolution (to an absolute file) fails.
    • getResolvedResource

      public static @NonNull IReadableResource getResolvedResource(@Nullable String sSystemId, @Nullable String sBaseURI, @Nullable ClassLoader aClassLoader)
      Do the standard resource resolving of sSystemId relative to sBaseURI
      Parameters:
      sSystemId - The resource to search. May be relative to the base URI or absolute. May be null if base URI is set.
      sBaseURI - The base URI from where the search is initiated. May be null if sSystemId is set.
      aClassLoader - The class loader to be used for ClassPathResource objects. May be null in which case the default class loader is used.
      Returns:
      The non-null resource. May be non-existing!
      Throws:
      UncheckedIOException - In case the file resolution (to an absolute file) fails.