public final class UrlBuilder extends Object
Constructor and Description |
---|
UrlBuilder() |
Modifier and Type | Method and Description |
---|---|
UrlBuilder |
addQueryParameter(String queryParameterName,
String queryParameterEncodedValue)
Append the provided query parameter name and encoded value to query string for the final URL.
|
UrlBuilder |
clearQuery()
Clear the query that will be used to build the final URL.
|
String |
getHost()
Get the host that has been assigned to this UrlBuilder.
|
String |
getPath()
Get the path that has been assigned to this UrlBuilder.
|
Integer |
getPort()
Get the port that has been assigned to this UrlBuilder.
|
Map<String,String> |
getQuery()
Get the query that has been assigned to this UrlBuilder.
|
String |
getQueryString()
Returns the query string currently configured in this UrlBuilder instance.
|
String |
getScheme()
Get the scheme/protocol that has been assigned to this UrlBuilder.
|
static UrlBuilder |
parse(String url)
Parses the passed
url string into a UrlBuilder. |
static UrlBuilder |
parse(URL url)
Parse a UrlBuilder from the provided URL object.
|
UrlBuilder |
setHost(String host)
Set the host that will be used to build the final URL.
|
UrlBuilder |
setPath(String path)
Set the path that will be used to build the final URL.
|
UrlBuilder |
setPort(int port)
Set the port that will be used to build the final URL.
|
UrlBuilder |
setPort(String port)
Set the port that will be used to build the final URL.
|
UrlBuilder |
setQuery(String query)
Set the query that will be used to build the final URL.
|
UrlBuilder |
setQueryParameter(String queryParameterName,
String queryParameterEncodedValue)
Set the provided query parameter name and encoded value to query string for the final URL.
|
UrlBuilder |
setScheme(String scheme)
Set the scheme/protocol that will be used to build the final URL.
|
String |
toString()
Get the string representation of the URL that is being built.
|
URL |
toUrl()
Get the URL that is being built.
|
public UrlBuilder setScheme(String scheme)
scheme
- The scheme/protocol that will be used to build the final URL.public String getScheme()
public UrlBuilder setHost(String host)
host
- The host that will be used to build the final URL.public String getHost()
public UrlBuilder setPort(String port)
port
- The port that will be used to build the final URL.public UrlBuilder setPort(int port)
port
- The port that will be used to build the final URL.public Integer getPort()
public UrlBuilder setPath(String path)
path
- The path that will be used to build the final URL.public String getPath()
public UrlBuilder setQueryParameter(String queryParameterName, String queryParameterEncodedValue)
queryParameterName
- The name of the query parameter.queryParameterEncodedValue
- The encoded value of the query parameter.NullPointerException
- if queryParameterName
or queryParameterEncodedValue
are null.public UrlBuilder addQueryParameter(String queryParameterName, String queryParameterEncodedValue)
queryParameterName
- The name of the query parameter.queryParameterEncodedValue
- The encoded value of the query parameter.NullPointerException
- if queryParameterName
or queryParameterEncodedValue
are null.public UrlBuilder setQuery(String query)
query
- The query that will be used to build the final URL.public UrlBuilder clearQuery()
public Map<String,String> getQuery()
public String getQueryString()
public URL toUrl() throws MalformedURLException
MalformedURLException
- if the URL is not fully formed.public String toString()
public static UrlBuilder parse(String url)
url
string into a UrlBuilder.url
- The URL string to parse.public static UrlBuilder parse(URL url)
url
- The URL object to parse.Copyright © 2021 Microsoft Corporation. All rights reserved.