public class UrlBuilder
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
PORT_UNSPECIFIED
The port to use when no port should be specified.
|
Constructor and Description |
---|
UrlBuilder() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
buildString()
Build the URL and return it as an encoded string.
|
UrlBuilder |
removeParameter(java.lang.String name)
Remove a query parameter from the map.
|
UrlBuilder |
setHash(java.lang.String hash)
Set the hash portion of the location (ex.
|
UrlBuilder |
setHost(java.lang.String host)
Set the host portion of the location (ex.
|
UrlBuilder |
setParameter(java.lang.String key,
java.lang.String... values)
Set a query parameter to a list of values.
|
UrlBuilder |
setPath(java.lang.String path)
Set the path portion of the location (ex.
|
UrlBuilder |
setPort(int port)
Set the port to connect to.
|
UrlBuilder |
setProtocol(java.lang.String protocol)
Set the protocol portion of the location (ex.
|
public static final int PORT_UNSPECIFIED
public java.lang.String buildString()
public UrlBuilder removeParameter(java.lang.String name)
name
- the parameter namepublic UrlBuilder setHash(java.lang.String hash)
hash
- the hashpublic UrlBuilder setHost(java.lang.String host)
host
- the hostpublic UrlBuilder setParameter(java.lang.String key, java.lang.String... values)
Set a query parameter to a list of values. Each value in the list will be added as its own key/value pair.
?mykey=value0&mykey=value1&mykey=value2
key
- the keyvalues
- the list of valuespublic UrlBuilder setPath(java.lang.String path)
path
- the pathpublic UrlBuilder setPort(int port)
port
- the port, or PORT_UNSPECIFIED
public UrlBuilder setProtocol(java.lang.String protocol)
protocol
- the protocol