Package com.azure.core.util
Class UrlBuilder
java.lang.Object
com.azure.core.util.UrlBuilder
A builder class that is used to create URLs.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionaddQueryParameter
(String queryParameterName, String queryParameterEncodedValue) Append the provided query parameter name and encoded value to query string for the final URL.Clear the query that will be used to build the final URL.getHost()
Get the host that has been assigned to this UrlBuilder.getPath()
Get the path that has been assigned to this UrlBuilder.getPort()
Get the port that has been assigned to this UrlBuilder.getQuery()
Get the query that has been assigned to this UrlBuilder.Returns the query string currently configured in this UrlBuilder instance.Get the scheme/protocol that has been assigned to this UrlBuilder.static UrlBuilder
Parses the passedurl
string into a UrlBuilder.static UrlBuilder
Parse a UrlBuilder from the provided URL object.Set the host that will be used to build the final URL.Set the path that will be used to build the final URL.setPort
(int port) Set the port that will be used to build the final URL.Set the port that will be used to build the final URL.Set the query that will be used to build the final URL.setQueryParameter
(String queryParameterName, String queryParameterEncodedValue) Set the provided query parameter name and encoded value to query string for the final URL.Set the scheme/protocol that will be used to build the final URL.toString()
Get the string representation of the URL that is being built.toUrl()
Get the URL that is being built.
-
Constructor Details
-
UrlBuilder
public UrlBuilder()
-
-
Method Details
-
setScheme
Set the scheme/protocol that will be used to build the final URL.- Parameters:
scheme
- The scheme/protocol that will be used to build the final URL.- Returns:
- This UrlBuilder so that multiple setters can be chained together.
-
getScheme
Get the scheme/protocol that has been assigned to this UrlBuilder.- Returns:
- the scheme/protocol that has been assigned to this UrlBuilder.
-
setHost
Set the host that will be used to build the final URL.- Parameters:
host
- The host that will be used to build the final URL.- Returns:
- This UrlBuilder so that multiple setters can be chained together.
-
getHost
Get the host that has been assigned to this UrlBuilder.- Returns:
- the host that has been assigned to this UrlBuilder.
-
setPort
Set the port that will be used to build the final URL.- Parameters:
port
- The port that will be used to build the final URL.- Returns:
- This UrlBuilder so that multiple setters can be chained together.
-
setPort
Set the port that will be used to build the final URL.- Parameters:
port
- The port that will be used to build the final URL.- Returns:
- This UrlBuilder so that multiple setters can be chained together.
-
getPort
Get the port that has been assigned to this UrlBuilder.- Returns:
- the port that has been assigned to this UrlBuilder.
-
setPath
Set the path that will be used to build the final URL.- Parameters:
path
- The path that will be used to build the final URL.- Returns:
- This UrlBuilder so that multiple setters can be chained together.
-
getPath
Get the path that has been assigned to this UrlBuilder.- Returns:
- the path that has been assigned to this UrlBuilder.
-
setQueryParameter
Set the provided query parameter name and encoded value to query string for the final URL.- Parameters:
queryParameterName
- The name of the query parameter.queryParameterEncodedValue
- The encoded value of the query parameter.- Returns:
- The provided query parameter name and encoded value to query string for the final URL.
- Throws:
NullPointerException
- ifqueryParameterName
orqueryParameterEncodedValue
are null.
-
addQueryParameter
Append the provided query parameter name and encoded value to query string for the final URL.- Parameters:
queryParameterName
- The name of the query parameter.queryParameterEncodedValue
- The encoded value of the query parameter.- Returns:
- The provided query parameter name and encoded value to query string for the final URL.
- Throws:
NullPointerException
- ifqueryParameterName
orqueryParameterEncodedValue
are null.
-
setQuery
Set the query that will be used to build the final URL.- Parameters:
query
- The query that will be used to build the final URL.- Returns:
- This UrlBuilder so that multiple setters can be chained together.
-
clearQuery
Clear the query that will be used to build the final URL.- Returns:
- This UrlBuilder so that multiple setters can be chained together.
-
getQuery
Get the query that has been assigned to this UrlBuilder.- Returns:
- the query that has been assigned to this UrlBuilder.
-
getQueryString
Returns the query string currently configured in this UrlBuilder instance.- Returns:
- A String containing the currently configured query string.
-
toUrl
Get the URL that is being built.- Returns:
- The URL that is being built.
- Throws:
MalformedURLException
- if the URL is not fully formed.
-
toString
Get the string representation of the URL that is being built. -
parse
Parses the passedurl
string into a UrlBuilder.- Parameters:
url
- The URL string to parse.- Returns:
- The UrlBuilder that was created from parsing the passed URL string.
-
parse
Parse a UrlBuilder from the provided URL object.- Parameters:
url
- The URL object to parse.- Returns:
- The UrlBuilder that was parsed from the URL object.
-