Class ModuleKeys


  • public final class ModuleKeys
    extends java.lang.Object
    Utilities for creating and using ModuleKeys.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ModuleKey cached​(ModuleKey delegate, java.lang.String text)
      Creates a module key that behaves like delegate, except that it returns text as its loaded source.
      static ModuleKey classPath​(java.net.URI uri, java.lang.ClassLoader classLoader)
      Creates a module key for a modulepath: module to be resolved with the given class loader.
      static ModuleKey file​(java.net.URI uri, java.nio.file.Path path)
      Creates a module key for a file: module.
      static ModuleKey genericUrl​(java.net.URI url)
      Creates a module key for the module with the given URL.
      static boolean isBaseModule​(ModuleKey module)
      Tells if the given module is the standard library module with URI pkl:base.
      static boolean isStdLibModule​(ModuleKey module)
      Tells if the given module is a standard library module.
      static ModuleKey modulePath​(java.net.URI uri, ModulePathResolver resolver)
      Creates a module key for a modulepath: module to be resolved with the given resolver.
      static ModuleKey pkg​(java.net.URI uri)
      Creates a module key for the given package.
      static ModuleKey projectpackage​(java.net.URI uri)  
      static ModuleKey standardLibrary​(java.net.URI uri)
      Creates a module key for the standard library module with the given URI.
      static ModuleKey synthetic​(java.net.URI uri, java.lang.String sourceText)
      Creates a module key identified by the given URI and backed by the given source code.
      static ModuleKey synthetic​(java.net.URI uri, java.net.URI importBaseUri, java.net.URI resolvedUri, java.lang.String sourceText, boolean isCached)
      Creates a module key identified by the given URI and backed by the given source code.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • 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​(java.net.URI uri,
                                          java.lang.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​(java.net.URI uri,
                                          java.net.URI importBaseUri,
                                          java.net.URI resolvedUri,
                                          java.lang.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​(java.net.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​(java.net.URI uri,
                                     java.nio.file.Path path)
        Creates a module key for a file: module.
      • modulePath

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

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

        public static ModuleKey genericUrl​(java.net.URI url)
        Creates a module key for the module with the given URL.
      • pkg

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

        public static ModuleKey projectpackage​(java.net.URI uri)
                                        throws java.net.URISyntaxException
        Throws:
        java.net.URISyntaxException
      • cached

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