Class UrlBuilder
- java.lang.Object
-
- com.azure.common.implementation.http.UrlBuilder
-
public final class UrlBuilder extends Object
A builder class that is used to create URLs.
-
-
Constructor Summary
Constructors Constructor Description UrlBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
host()
Get the host that has been assigned to this UrlBuilder.static UrlBuilder
parse(String url)
Parse a UrlBuilder from the provided URL string.static UrlBuilder
parse(URL url)
Parse a UrlBuilder from the provided URL object.String
path()
Get the path that has been assigned to this UrlBuilder.Integer
port()
Get the port that has been assigned to this UrlBuilder.Map<String,String>
query()
Get the query that has been assigned to this UrlBuilder.String
scheme()
Get the scheme/protocol that has been assigned to this UrlBuilder.UrlBuilder
setQueryParameter(String queryParameterName, String queryParameterEncodedValue)
Set the provided query parameter name and encoded value to query string for 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.UrlBuilder
withHost(String host)
Set the host that will be used to build the final URL.UrlBuilder
withPath(String path)
Set the path that will be used to build the final URL.UrlBuilder
withPort(int port)
Set the port that will be used to build the final URL.UrlBuilder
withPort(String port)
Set the port that will be used to build the final URL.UrlBuilder
withQuery(String query)
Set the query that will be used to build the final URL.UrlBuilder
withScheme(String scheme)
Set the scheme/protocol that will be used to build the final URL.
-
-
-
Method Detail
-
withScheme
public UrlBuilder withScheme(String scheme)
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.
-
scheme
public String scheme()
Get the scheme/protocol that has been assigned to this UrlBuilder.- Returns:
- the scheme/protocol that has been assigned to this UrlBuilder.
-
withHost
public UrlBuilder withHost(String host)
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.
-
host
public String host()
Get the host that has been assigned to this UrlBuilder.- Returns:
- the host that has been assigned to this UrlBuilder.
-
withPort
public UrlBuilder withPort(String port)
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.
-
withPort
public UrlBuilder withPort(int port)
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.
-
port
public Integer port()
Get the port that has been assigned to this UrlBuilder.- Returns:
- the port that has been assigned to this UrlBuilder.
-
withPath
public UrlBuilder withPath(String path)
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.
-
path
public String path()
Get the path that has been assigned to this UrlBuilder.- Returns:
- the path that has been assigned to this UrlBuilder.
-
setQueryParameter
public UrlBuilder setQueryParameter(String queryParameterName, String queryParameterEncodedValue)
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.
-
withQuery
public UrlBuilder withQuery(String query)
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.
-
query
public Map<String,String> query()
Get the query that has been assigned to this UrlBuilder.- Returns:
- the query that has been assigned to this UrlBuilder.
-
toURL
public URL toURL() throws MalformedURLException
Get the URL that is being built.- Returns:
- The URL that is being built.
- Throws:
MalformedURLException
- if the URL is not fully formed.
-
toString
public String toString()
Get the string representation of the URL that is being built.
-
parse
public static UrlBuilder parse(String url)
Parse a UrlBuilder from the provided URL string.- Parameters:
url
- The string to parse.- Returns:
- The UrlBuilder that was parsed from the string.
-
parse
public static UrlBuilder parse(URL url)
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.
-
-