Package com.ultikits.ultitools.utils
Class CodeSourceLocations
java.lang.Object
com.ultikits.ultitools.utils.CodeSourceLocations
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 Summary
Constructors -
Method Summary
-
Constructor Details
-
CodeSourceLocations
private CodeSourceLocations()
-
-
Method Details
-
toFile
Resolves a code-source URL as aFile, decoding percent escapes through the URL'sURI.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, sonew File(url.getPath())finds nothing there. URI decoding, unlikeURLDecoder, 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:URISyntaxException-- the URL is not a valid URI at all, for example an unescaped space in a hand-builtfile:URL;IllegalArgumentException--File(java.net.URI)rejects a URI with an authority component, a query or a fragment, or an opaque URI.
- Parameters:
location- theCodeSource.getLocation()URL, nevernull- Returns:
- the location as a
File; nevernull
-