public class ConversionUtils
extends java.lang.Object
| Constructor and Description |
|---|
ConversionUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
escapeIllegalURLCharacters(java.lang.String url) |
static java.lang.String |
getEncodingFromContentType(java.lang.String contentType)
Extract the encoding (charset) from the Content-Type, e.g.
|
static java.net.URL |
makeRelativeURL(java.net.URL baseURL,
java.lang.String location)
Generate an absolute URL from a possibly relative location,
allowing for extraneous leading "../" segments.
|
static java.lang.String |
removeSlashDotDot(java.lang.String url)
collapses absolute or relative URLs containing '/..' converting
http://host/path1/.. |
static java.net.URI |
sanitizeUrl(java.net.URL url)
Checks a URL and encodes it if necessary,
i.e. if it is not currently correctly encoded.
|
public static java.lang.String getEncodingFromContentType(java.lang.String contentType)
contentType - string from which the encoding should be extractednull, if none was found or
the charset is not supportedjava.nio.charset.IllegalCharsetNameException - if the found charset is not supportedpublic static java.net.URL makeRelativeURL(java.net.URL baseURL,
java.lang.String location)
throws java.net.MalformedURLException
URL.URL(URL, String) constructor does not remove these.baseURL - the base URL which is used to resolve missing protocol/host in the locationlocation - the location, possibly with extraneous leading "../"java.net.MalformedURLException - when the given URL is malformedpublic static java.lang.String escapeIllegalURLCharacters(java.lang.String url)
throws java.lang.Exception
url - String Url to escapejava.lang.Exception - when given url leads to a malformed URL or URIpublic static java.net.URI sanitizeUrl(java.net.URL url)
throws java.net.URISyntaxException
url - non-encoded URLjava.net.URISyntaxException - if parts of the url form a non valid URIpublic static java.lang.String removeSlashDotDot(java.lang.String url)
http://host/path1/../path2 to http://host/path2
or /one/two/../three to
/one/threeurl - in which the '/..'s should be removedCopyright © 1998-2018 Apache Software Foundation. All Rights Reserved.