public final class UrlBuilder extends Object
| Modifier and Type | Field and Description |
|---|---|
String |
fragment |
String |
hostName |
String |
path |
Integer |
port |
Map<String,List<String>> |
queryParameters |
String |
scheme |
String |
userInfo |
| Modifier and Type | Method and Description |
|---|---|
UrlBuilder |
addParameter(String key,
String value)
Adds a query parameter.
|
static UrlBuilder |
empty()
Construct an empty builder instance.
|
UrlBuilder |
encodeAs(Charset charset)
When percent-escaping the StringBuilder's output, use this character set.
|
UrlBuilder |
encodeAs(String charsetName)
When percent-escaping the StringBuilder's output, use this character set.
|
static UrlBuilder |
fromString(String url)
Construct a UrlBuilder from a full or partial URL string.
|
static UrlBuilder |
fromString(String url,
Charset inputEncoding)
Construct a UrlBuilder from a full or partial URL string.
|
static UrlBuilder |
fromString(String url,
Decoder decoder)
Construct a UrlBuilder from a full or partial URL string.
|
static UrlBuilder |
fromString(String url,
String inputEncoding)
Construct a UrlBuilder from a full or partial URL string.
|
static UrlBuilder |
fromUri(URI uri)
Construct a UrlBuilder from a
URI. |
static UrlBuilder |
fromUrl(URL url)
Construct a UrlBuilder from a
URL. |
protected static UrlBuilder |
of(Decoder decoder,
Encoder encoder,
String scheme,
String userInfo,
String hostName,
Integer port,
String path,
UrlParameterMultimap queryParameters,
String fragment) |
UrlBuilder |
removeParameter(String key,
String value)
Removes a query parameter for a key and value.
|
UrlBuilder |
removeParameters(String key)
Removes all query parameters with this key.
|
UrlBuilder |
setParameter(String key,
String value)
Replaces a query parameter.
|
String |
toString() |
void |
toString(Appendable out) |
URI |
toUri() |
URI |
toUriWithException() |
URL |
toUrl() |
URL |
toUrlWithException() |
UrlBuilder |
withDecoder(Decoder decoder) |
UrlBuilder |
withEncoder(Encoder encoder) |
UrlBuilder |
withFragment(String fragment)
Sets the fragment/anchor.
|
UrlBuilder |
withHost(String name)
Set the host name.
|
UrlBuilder |
withParameters(UrlParameterMultimap parameters)
Sets the parameters.
|
UrlBuilder |
withPath(String path)
Set the decoded, non-url-encoded path.
|
UrlBuilder |
withPath(String path,
Charset encoding)
Decodes and sets the path from a url-encoded string.
|
UrlBuilder |
withPath(String path,
String encoding)
Decodes and sets the path from a url-encoded string.
|
UrlBuilder |
withPort(Integer port)
Set the port.
|
UrlBuilder |
withQuery(String query)
Decodes the input string, and sets the query string.
|
UrlBuilder |
withQuery(String query,
Charset encoding)
Decodes the input string, and sets the query string.
|
UrlBuilder |
withQuery(UrlParameterMultimap query)
Sets the query parameters to a deep copy of the input parameter.
|
UrlBuilder |
withScheme(String scheme)
Set the protocol (or scheme), such as "http" or "https".
|
UrlBuilder |
withUserInfo(String userInfo)
Set the userInfo.
|
public final String scheme
public final String userInfo
public final String hostName
public final Integer port
public final String path
public final String fragment
public static UrlBuilder empty()
protected static UrlBuilder of(Decoder decoder, Encoder encoder, String scheme, String userInfo, String hostName, Integer port, String path, UrlParameterMultimap queryParameters, String fragment)
public static UrlBuilder fromString(String url)
public static UrlBuilder fromString(String url, String inputEncoding)
NumberFormatException - if the input contains a invalid percent-encoding sequence (%ax) or a non-numeric portpublic static UrlBuilder fromString(String url, Charset inputEncoding)
NumberFormatException - if the input contains a invalid percent-encoding sequence (%ax) or a non-numeric portpublic static UrlBuilder fromString(String url, Decoder decoder)
NumberFormatException - if the input contains a invalid percent-encoding sequence (%ax) or a non-numeric portpublic static UrlBuilder fromUri(URI uri)
URI.public static UrlBuilder fromUrl(URL url)
URL.NumberFormatException - if the input contains a invalid percent-encoding sequence (%ax) or a non-numeric portpublic void toString(Appendable out) throws IOException
IOExceptionpublic URI toUriWithException() throws URISyntaxException
URISyntaxExceptionpublic URI toUri() throws RuntimeURISyntaxException
RuntimeURISyntaxExceptionpublic URL toUrlWithException() throws MalformedURLException
MalformedURLExceptionpublic URL toUrl() throws RuntimeMalformedURLException
RuntimeMalformedURLExceptionpublic UrlBuilder withDecoder(Decoder decoder)
public UrlBuilder withEncoder(Encoder encoder)
public UrlBuilder encodeAs(Charset charset)
public UrlBuilder encodeAs(String charsetName)
public UrlBuilder withScheme(String scheme)
public UrlBuilder withUserInfo(String userInfo)
public UrlBuilder withHost(String name)
public UrlBuilder withPort(Integer port)
public UrlBuilder withPath(String path)
public UrlBuilder withPath(String path, Charset encoding)
public UrlBuilder withPath(String path, String encoding)
public UrlBuilder withQuery(UrlParameterMultimap query)
public UrlBuilder withQuery(String query)
public UrlBuilder withQuery(String query, Charset encoding)
public UrlBuilder withParameters(UrlParameterMultimap parameters)
public UrlBuilder addParameter(String key, String value)
public UrlBuilder setParameter(String key, String value)
public UrlBuilder removeParameter(String key, String value)
public UrlBuilder removeParameters(String key)
public UrlBuilder withFragment(String fragment)
Copyright © 2016. All rights reserved.