public final class UriUtils extends Object
Modifier and Type | Method and Description |
---|---|
static URI |
concatPath(URI base,
String relPath)
Concatenates 2
URI by taking the beginning of the first (up to the path) and the end of the other
(starting from the path). |
static URI |
createURI(String uri)
Creates an
URI after escaping some special characters in order to tolerate some incorrect URI types. |
static String |
createURI(String scheme,
String host,
int port,
String path,
String query,
String fragment)
Creates an URI as a String.
|
static String |
encodeIllegalCharacters(String uri)
Fixes common mistakes in URI by replacing all illegal characters by their encoded value.
|
static org.apache.http.HttpHost |
extractHost(String uri)
Extracts the
HttpHost from a URI. |
static org.apache.http.HttpHost |
extractHost(URI uri)
Extracts the
HttpHost from a URI. |
static String |
extractHostName(String uri)
Extracts the host name from a URI.
|
static String |
extractScheme(String uri)
Extracts the scheme of a URI.
|
static String |
getPath(String uri)
Returns the decoded path component of this URI.
|
static String |
getRawQuery(String uri)
Returns the raw query component of this URI.
|
static boolean |
isAbsolute(String uri)
Checks if a URI starts with a protocol.
|
static List<org.apache.http.NameValuePair> |
parse(String uri,
String charset)
Returns a list of
NameValuePairs as built from the URI's query portion. |
static String |
removeQuerystring(String uriString)
Removes the query and fragment at the end of a URI.
|
static URI |
removeServer(URI uri)
Removes the server information frome a
URI . |
static String |
removeSessionId(String sessionId,
String page)
Removes the jsessionid that may have been added to a URI on a java application server.
|
static URI |
resolve(String relUri,
URI base)
Interpret the url relatively to the request url (may be relative).
|
static String |
rewriteURI(String uri,
org.apache.http.HttpHost targetHost)
Replaces the scheme, host and port in a URI.
|
public static String encodeIllegalCharacters(String uri)
uri
- the URI to fixpublic static String createURI(String scheme, String host, int port, String path, String query, String fragment)
scheme
- the schemehost
- the hostport
- the portpath
- the pathquery
- the queryfragment
- the fragmentpublic static String extractHostName(String uri)
uri
- the uripublic static org.apache.http.HttpHost extractHost(String uri)
HttpHost
from a URI.uri
- the URIHttpHost
public static org.apache.http.HttpHost extractHost(URI uri)
HttpHost
from a URI.uri
- the URI
HttpHost
public static URI createURI(String uri)
URI
after escaping some special characters in order to tolerate some incorrect URI types. If
the uri contains a server name but no path, the path is set to "/" as a browser would do.public static String rewriteURI(String uri, org.apache.http.HttpHost targetHost)
uri
- the URItargetHost
- the target hostpublic static String removeSessionId(String sessionId, String page)
sessionId
- the value of the sessionId that can also be found in a JSESSIONID cookiepage
- the html code of the pagepublic static String extractScheme(String uri)
uri
- the URIpublic static String getRawQuery(String uri)
uri
- the URIpublic static String getPath(String uri)
uri
- the uri to retrieve the path frompublic static List<org.apache.http.NameValuePair> parse(String uri, String charset)
NameValuePairs
as built from the URI's query portion. For example, a URI
of http://example.org/path/to/file?a=1&b=2&c=3 would return a list of three NameValuePairs, one for a=1,
one for b=2, and one for c=3. By convention, '&'
and ';'
are accepted as parameter
separators.
This is typically useful while parsing an HTTP PUT. This API is currently only used for testing.
uri
- URI to parsecharset
- Charset name to use while parsing the queryNameValuePair
as built from the URI's query portion.public static boolean isAbsolute(String uri)
uri
- the URIpublic static URI concatPath(URI base, String relPath)
URI
by taking the beginning of the first (up to the path) and the end of the other
(starting from the path). While concatenating, checks that there is no doubled "/" character between the path
fragments.base
- the base urirelPath
- the path to concatenate with the base uriCopyright © 2008–2018. All rights reserved.