Package dev.enola.common.io.iri
Class URIs
java.lang.Object
dev.enola.common.io.iri.URIs
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic final record -
Method Summary
Modifier and TypeMethodDescriptionstatic Stringabsolutify(String uri) static URIabsolutify(URI uri) static URIaddCharset(URI uri, Charset charset) static URIaddFragment(URI uri, String fragment) static URIaddMediaType(URI uri, MediaType mediaType) static Stringstatic URIReturns an URI with everything except the query parameters of the uri (1st) parameter, but the query parameters of originalUriWithQuery (2nd) parameter - IFF the uri (1st) parameter has no query; otherwise just returns the uri (1st) parameter as-is.static URIstatic Stringstatic URIdropQueryAndFragment(URI uri) static StringDeprecated.static URIstatic @Nullable StringgetCharset(URI uri) static StringgetFilename(URI uri) Extracts the "file name" from an URI, or the empty string if there is none.static Stringstatic StringgetFilenameWithoutExtension(URI uri, String... extensions) static PathgetFilePath(String uri) static PathgetFilePath(URI uri) static URIs.MediaTypeAndOrCharsetstatic Stringstatic StringDeprecated.getQueryMap(String uri) getQueryMap(URI uri) static Stringstatic booleanhasExtension(URI uri, String... extensions) static booleanhasQueryParameter(URI uri, String key) static booleanstatic URIstatic URIDeprecated.
-
Method Details
-
hasQueryParameter
-
getMediaTypeAndCharset
-
getCharset
-
addMediaType
-
addCharset
-
addQuery
-
addQuery
Returns an URI with everything except the query parameters of the uri (1st) parameter, but the query parameters of originalUriWithQuery (2nd) parameter - IFF the uri (1st) parameter has no query; otherwise just returns the uri (1st) parameter as-is.For example, this method can be used to preserve query parameters when changing the URI path.
-
addQuery
-
getQueryMap
-
getQueryMap
-
getFilePath
-
getFilePath
-
getScheme
-
hasScheme
-
getPath
Deprecated.Get the "path"-like component of any URI. Similar toURI.getPath(), but also works e.g. for "non-standard" relative "file:hello.txt" URIs, and correctly chops off query arguments and fragments.TODO This does not yet decode correctly! :=((
TODO Is this really required?! Re-review which tests URI#getPath() fails, and why...
-
getPath
-
getFilename
Extracts the "file name" from an URI, or the empty string if there is none. The filename is simply the last part of the path of the URI. It COULD be a directory! Works for file: http: and other even for "weird" URIs, such as those from Classpath URLs.See also
Files.getFileExtension(String)and @Files.getNameWithoutExtension(String). -
getFilenameWithoutExtension
-
hasExtension
-
getFilenameOrLastPathSegmentOrHost
-
rel2abs
Deprecated.This converts e.g. "file:relative.txt" to "file:///tmp/.../relative.txt" (depending on the current working directory, obviously). It loses any query parameters and fragments. -
absolutify
-
absolutify
-
dropQueryAndFragment
-
dropQueryAndFragment
-
getBase
- Throws:
IOException
-
addFragment
-
encode
Deprecated. -
parse
- Throws:
URISyntaxException
-