Class CodeSourceLocations

java.lang.Object
com.ultikits.ultitools.utils.CodeSourceLocations

@Internal public final class CodeSourceLocations extends Object
Turns a module's CodeSource.getLocation() URL into the File it names -- the one resolver the language subsystem uses, so language discovery (Localized.supported()), the dictionary reader and resource extraction in UltiToolsPlugin can never disagree about where a module's JAR (or exploded class directory) is (#676 case 26).

Internal to the framework; not an API for module authors.

Since:
6.3.0
  • Constructor Details

    • CodeSourceLocations

      private CodeSourceLocations()
  • Method Details

    • toFile

      public static File toFile(URL location)
      Resolves a code-source URL as a File, decoding percent escapes through the URL's URI. URL.getPath() does not decode: a server installed under a path with a space or a non-ASCII character yields %20/%E6... escapes that name no file, so new File(url.getPath()) finds nothing there. URI decoding, unlike URLDecoder, also leaves a literal '+' in a folder name as a plus sign.

      Falls back to the raw-path rule the framework used before (the URL's undecoded path, with a leading character dropped when the path is not empty and does not start with '/') in two cases, so resolving a location never adds a failure path where reading the raw path never failed:

      Parameters:
      location - the CodeSource.getLocation() URL, never null
      Returns:
      the location as a File; never null