public class URLUtils extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
CHARSET
The default UTF-8 character set.
|
Modifier and Type | Method and Description |
---|---|
static java.net.URL |
getBaseURL(java.net.URL url)
Gets the base part (protocol, host, port and path) of the specified
URL.
|
static java.util.Map<java.lang.String,java.lang.String> |
parseParameters(java.lang.String query)
Parses the specified URL query string into a parameter map.
|
static java.lang.String |
serializeParameters(java.util.Map<java.lang.String,java.lang.String> params)
Serialises the specified map of parameters into a URL query string.
|
public static final java.lang.String CHARSET
public static java.net.URL getBaseURL(java.net.URL url)
url
- The URL. May be null
.null
if the original URL
is null
or doesn't specify a protocol.public static java.lang.String serializeParameters(java.util.Map<java.lang.String,java.lang.String> params)
application/x-www-form-urlencoded
encoded.
Note that the '?' character preceding the query string in GET requests is not included in the returned string.
Example query string:
response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
The opposite method is parseParameters(java.lang.String)
.
params
- A map of the URL query parameters. May be empty or
null
.public static java.util.Map<java.lang.String,java.lang.String> parseParameters(java.lang.String query)
application/x-www-form-urlencoded
decoded.
Note that the '?' character preceding the query string in GET requests must not be included.
Example query string:
response_type=code &client_id=s6BhdRkqt3 &state=xyz &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
The opposite method serializeParameters(java.util.Map<java.lang.String, java.lang.String>)
.
query
- The URL query string to parse. May be null
.Copyright © 2014 Connect2id Ltd.. All Rights Reserved.