@DefaultKey(value="uriTool") public class URITool extends Object
Modifier and Type | Class and Description |
---|---|
static class |
URITool.URLRebaser
URL rebaser: based on an old and a new path, can rebase a link based on old path to a value based on the new
path.
|
Constructor and Description |
---|
URITool() |
Modifier and Type | Method and Description |
---|---|
static URITool.URLRebaser |
createURLRebaser(String parentBaseUrl,
String childBaseUrl) |
static String |
normalisedBaseUrl(String baseUrl)
remove url path separator ('/') to the end of path.
|
static String |
relativizeLink(String baseDirUri,
String link)
Resolves the link as relative to the base dir URI.
|
static URI |
toURI(String uri)
Creates a URI by parsing the given string.
|
@Nullable public static String relativizeLink(@Nullable String baseDirUri, @Nullable String link)
Relativizes only absolute links, if the link has the same scheme, host and port as the base, it is made into a relative link as viewed from the base.
This is the same method that's used to relativize project links in Maven site.
baseDirUri
- URI that will serve as the base to calculate the relative onelink
- The link to relativize (make it relative to the base URI if possible)@Nonnull public static URI toURI(@Nonnull String uri)
uri
- The string to be parsed into a URIpublic static URITool.URLRebaser createURLRebaser(@Nullable String parentBaseUrl, @Nullable String childBaseUrl)
parentBaseUrl
- The base URI. Has to be a valid absolute URI. In addition, the path of the URI should not have any
file part, ie http://maven.apache.org/
is valid,
http://maven.apache.org/index.html
is not.childBaseUrl
- the new base URI. Has to be parsable as a URI.URITool.URLRebaser
allowing to calculate/relative the link as viewed from a
different base. This returns the parentBaseUrl
link if link is absolute.URIPathDescriptor.rebaseLink(String)
,
URITool.URLRebaser.rebaseLink(String)
Copyright © 2012–2023 Friederich Christophe. All rights reserved.