java.lang.Object
dev.metaschema.core.util.UriUtils
A collection of methods for manipulating uniform resource identifiers (URIs),
providing functionality for URI resolution, relativization, and path
manipulation.
This utility class supports both local file paths and remote URIs.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringprependRelativePath(String base, String target) Get the path of the provided target relative to the path of the provided base.static URIrelativize(URI base, URI other, boolean prepend) This function extends the functionality ofURI.relativize(URI)by supporting relative reference pathing (e.g., ..), when theprependparameter is set totrue.static URIProcess a string to a local file path or remote location.
-
Method Details
-
toUri
@NonNull public static URI toUri(@NonNull String location, @NonNull URI baseUri) throws URISyntaxException Process a string to a local file path or remote location. If the location is convertible to a URI, return theURI. Normalize the resulting URI with the base URI, if provided.- Parameters:
location- a string defining a remote or local file-based locationbaseUri- the base URI to use for URI normalization- Returns:
- a new URI
- Throws:
URISyntaxException- if the location string is not convertible to URI
-
relativize
@NonNull public static URI relativize(URI base, URI other, boolean prepend) throws URISyntaxException This function extends the functionality ofURI.relativize(URI)by supporting relative reference pathing (e.g., ..), when theprependparameter is set totrue.- Parameters:
base- the URI to relativize againstother- the URI to make relativeprepend- iftrue, then prepend relative pathing- Returns:
- a new relative URI
- Throws:
URISyntaxException- if any of the URIs are malformed
-
prependRelativePath
Get the path of the provided target relative to the path of the provided base.- Parameters:
base- the base path to resolve againsttarget- the URI to relativize against the base- Returns:
- the relativized URI
-