Class ModuleKeys

java.lang.Object
org.pkl.core.module.ModuleKeys

public final class ModuleKeys extends Object
Utilities for creating and using ModuleKeys.
  • Method Details

    • isStdLibModule

      public static boolean isStdLibModule(ModuleKey module)
      Tells if the given module is a standard library module. Standard library modules ship with the language and have a URI of the form pkl:<simple module name>.
    • isBaseModule

      public static boolean isBaseModule(ModuleKey module)
      Tells if the given module is the standard library module with URI pkl:base.
    • synthetic

      public static ModuleKey synthetic(URI uri, String sourceText)
      Creates a module key identified by the given URI and backed by the given source code. Shorthand for synthetic(uri, uri, uri, sourceText, false.
    • synthetic

      public static ModuleKey synthetic(URI uri, URI importBaseUri, URI resolvedUri, String sourceText, boolean isCached)
      Creates a module key identified by the given URI and backed by the given source code. Module imports will be resolved against the given importBaseUri. If isCached is true, the resulting module will be cached with uri and resolvedUri used as cache keys.
    • standardLibrary

      public static ModuleKey standardLibrary(URI uri)
      Creates a module key for the standard library module with the given URI. The URI for a standard library module is pkl:<simple module name>. For example, the URI for the base library module is pkl:base.
    • file

      public static ModuleKey file(URI uri)
      Creates a module key for a file: module.
    • modulePath

      public static ModuleKey modulePath(URI uri, ModulePathResolver resolver)
      Creates a module key for a modulepath: module to be resolved with the given resolver.
    • classPath

      public static ModuleKey classPath(URI uri, ClassLoader classLoader)
      Creates a module key for a modulepath: module to be resolved with the given class loader.
    • genericUrl

      public static ModuleKey genericUrl(URI url)
      Creates a module key for the module with the given URL.
    • http

      public static ModuleKey http(URI url)
      Creates a module key for http: and https: uris.
    • pkg

      public static ModuleKey pkg(URI uri) throws URISyntaxException
      Creates a module key for the given package.
      Throws:
      URISyntaxException
    • projectpackage

      public static ModuleKey projectpackage(URI uri) throws URISyntaxException
      Throws:
      URISyntaxException
    • cached

      public static ModuleKey cached(ModuleKey delegate, String text)
      Creates a module key that behaves like delegate, except that it returns text as its loaded source.