Package org.webjars

Class WebJarAssetLocator

java.lang.Object
org.webjars.WebJarAssetLocator

public class WebJarAssetLocator extends Object
Locate WebJar assets. The class is thread safe.
  • Field Details

  • Constructor Details

  • Method Details

    • getAllWebJars

      public Map<String,WebJarAssetLocator.WebJarInfo> getAllWebJars()
    • webJarResources

      @Nonnull protected static io.github.classgraph.ResourceList webJarResources(@Nonnull String webJarName, @Nonnull io.github.classgraph.ResourceList resources)
    • webJarVersion

      @Nullable protected static String webJarVersion(@Nullable String webJarName, @Nonnull io.github.classgraph.ResourceList resources)
    • findWebJars

      @Nonnull protected static Map<String,WebJarAssetLocator.WebJarInfo> findWebJars(@Nonnull io.github.classgraph.ScanResult scanResult)
    • getWebJar

      @Nullable public static Map.Entry<String,String> getWebJar(@Nonnull CharSequence path)
      Parameters:
      path - The full WebJar path (not null)
      Returns:
      A WebJar tuple (Entry) with key = id and value = version or null if not a legal WebJar file format
    • getFullPath

      @Nonnull public String getFullPath(@Nonnull String partialPath)
      Given a distinct path within the WebJar index passed in return the full path of the resource.
      Parameters:
      partialPath - the path to return e.g. "jquery.js" or "abc/someother.js". This must be a distinct path within the index passed in (not null or empty).
      Returns:
      a fully qualified path to the resource.
    • getFullPath

      @Nonnull public String getFullPath(@Nonnull String webjar, @Nonnull String partialPath)
      Returns the full path of an asset within a specific WebJar
      Parameters:
      webjar - The id of the WebJar to search (not null
      partialPath - The partial path to look for (not null
      Returns:
      a fully qualified path to the resource
      Throws:
      NotFoundException - if webjar or path not found
    • getFullPathExact

      @Nullable public String getFullPathExact(@Nonnull String webJarName, @Nullable String exactPath)
      Returns the full path of an asset within a specific WebJar
      Parameters:
      webJarName - The id of the WebJar to search (must not be null
      exactPath - The exact path of the file within the WebJar (may be null for legacy reasons)
      Returns:
      a fully qualified path to the resource of null if WebJar not found
    • listAssets

      @Nonnull public Set<String> listAssets()
    • listAssets

      @Nonnull public Set<String> listAssets(@Nonnull String folderPath)
      List assets within a folder.
      Parameters:
      folderPath - the root path to the folder.
      Returns:
      a set of folder paths that match.
    • getWebJars

      @Nonnull public Map<String,String> getWebJars()
      Returns:
      A map of the WebJars based on the files in the CLASSPATH where the key is the artifactId and the value is the version
    • groupId

      @Nullable public String groupId(@Nullable String fullPath)
      Gets the Group ID given a fullPath
      Parameters:
      fullPath - the fullPath to the asset in a WebJar, i.e. META-INF/resources/webjars/jquery/2.1.0/jquery.js
      Returns:
      the Group ID for the WebJar or null if it can't be determined