public final class UrlSupport extends Object
UrlSupport is a helper class to deal with urls.| Modifier and Type | Field and Description |
|---|---|
static String |
DEFAULT_BASE_URL |
| Modifier and Type | Method and Description |
|---|---|
static String |
concat(List<String> parts)
Concatenates the urls with respect to leading and trailing slashes.
|
static String |
concat(String... parts)
Concatenates the urls with respect to leading and trailing slashes.
|
static String |
concat(String prefix,
String suffix)
Concatenates the two urls with respect to leading and trailing slashes.
|
static String |
concat(String prefix,
String suffix,
boolean close)
Concatenates the two urls with respect to leading and trailing slashes.
|
static String |
getExtension(String url)
Returns the extension that is encoded into the url.
|
static String |
getExtension(String prefix,
String url)
Returns the url extension that
url defines over prefix. |
static Character |
getInvalidCharacter(String url)
Returns
null if the url is valid, that is, if it contains only allowed characters. |
static boolean |
isExtendedPrefix(String a,
String b)
Returns
true if url a is a prefix of url b. |
static boolean |
isPrefix(String a,
String b)
Returns
true if url a is a direct prefix of url b. |
static boolean |
isValid(String url)
Returns
true if the url is valid, that is, if it contains only allowed characters. |
static String |
removeDoubleSeparator(String path)
Removes any occurrence of double separators ("//") and replaces it with "/".
|
static String[] |
sort(String[] urls)
Sorts the given urls by path.
|
static String |
stripExtension(String url)
Strips off the extension and returns the pure url.
|
static String |
trim(String url)
Returns the trimmed url.
|
static URI |
uri(Object... parts)
Create a URI from the given parts.
|
static URI |
uri(String uri)
URI constructor function without checked exceptions.
|
static URL |
url(String url)
URL constructor function without checked exceptions.
|
static URL |
url(String protocol,
String host,
int port)
URL constructor function without checked exceptions.
|
static URL |
url(URL context,
String spec)
URL constructor function without checked exceptions.
|
public static final String DEFAULT_BASE_URL
public static URL url(String protocol, String host, int port)
public static URL url(URL context, String spec)
URLpublic static String[] sort(String[] urls)
urls - the urls to sortpublic static String concat(String prefix, String suffix)
Note that returned path will only end with a slash if suffix does. If you need a trailing slash, see
concat(String, String, boolean).
public static String concat(String prefix, String suffix, boolean close)
public static String concat(String... parts)
parts - the parts to concatpublic static String concat(List<String> parts)
parts - the parts to concatpublic static String trim(String url)
/news/ is closed by a slash (/).url - the url to trimpublic static String removeDoubleSeparator(String path)
path - the path to checkpublic static boolean isPrefix(String a, String b)
true if url a is a direct prefix of url b. For example,
/news is the parent of /news/today.
Note that a is also an extended prefix of b if a and b are
equal.
a - the first urlb - the second urltrue if a is the direct prefix of bpublic static boolean isExtendedPrefix(String a, String b)
true if url a is a prefix of url b. For example, /news
is an ancestor of /news/today/morning.
Note that a is also an extended prefix of b if a and b are
equal.
a - the first urlb - the second urltrue if a is a prefix of bpublic static String getExtension(String prefix, String url)
url defines over prefix. For example, the extension of url
/news/today and prefix /news is today.
If prefix is not a prefix of url, this method returns null, if
url and prefix match, the empty string is returned.
prefix - the url prefixurl - the urlpublic static String getExtension(String url)
nullurl - the url with extensionnull if no extension can be foundpublic static String stripExtension(String url)
url - the url with extensionpublic static boolean isValid(String url)
true if the url is valid, that is, if it contains only allowed characters.true or the invalid characterCopyright © 2009–2021 Opencast Project. All rights reserved.