@ParametersAreNonnullByDefault public final class UrlBuilder extends Object
Constructor and Description |
---|
UrlBuilder(String baseUrl)
Constructs a UTF-8 URL builder with the given base URL.
|
UrlBuilder(String baseUrl,
Charset encoding)
Constructs a builder with the given base URL, which should already be URL-encoded.
|
UrlBuilder(String baseUrl,
String encoding)
Constructs a builder with the given base URL, which should already be URL-encoded.
|
Modifier and Type | Method and Description |
---|---|
UrlBuilder |
add(String name,
boolean value)
Adds a parameter to the URL.
|
UrlBuilder |
add(String name,
int value)
Adds a parameter to the URL.
|
UrlBuilder |
add(String name,
long value)
Adds a parameter to the URL.
|
UrlBuilder |
add(String name,
String value)
Adds a parameter to the URL.
|
UrlBuilder |
add(String name,
String[] values)
Retrieving parameters from a ServletRequest will provide you with
String array values.
|
UrlBuilder |
addAll(Map<String,Object> params)
Add multiple parameters to the URL from a map.
|
UrlBuilder |
addAnchor(String anchor)
Sets an anchor for the URL.
|
static URL |
createURL(String urlString)
Creates a URL from the given string.
|
String |
toString() |
String |
toUrl() |
String |
toUrl(boolean encodeAnchor) |
public UrlBuilder(String baseUrl)
UrlBuilder(String, String)
baseUrl
- The base URLpublic UrlBuilder(String baseUrl, String encoding)
baseUrl
- Base URL to which a query string is appendedencoding
- Encoding to use, e.g. UTF-8@Nonnull public static URL createURL(String urlString)
urlString
- the string to be turned into a URLIllegalArgumentException
- if the given string is malformedURL.URL(String)
public UrlBuilder add(String name, String value) throws IllegalArgumentException
name
- the name of the parametervalue
- the value of the parameterIllegalArgumentException
- if either the name or value is nullpublic UrlBuilder add(String name, String[] values)
name
- the name of the parametervalues
- one or more values for the parameterIllegalArgumentException
- if the name or values are null nullpublic UrlBuilder add(String name, long value) throws IllegalArgumentException
name
- Parameter name (part before =)value
- Parameter value (part after =)IllegalArgumentException
- When things are nulladd(String, String)
public UrlBuilder add(String name, int value) throws IllegalArgumentException
name
- Parameter name (part before =)value
- Parameter value (part after =)IllegalArgumentException
- When things are nulladd(String, String)
public UrlBuilder add(String name, boolean value) throws IllegalArgumentException
name
- Parameter name (part before =)value
- Parameter value (part after =)IllegalArgumentException
- When things are nulladd(String, String)
public UrlBuilder addAnchor(String anchor)
anchor
- Anchor name (part after #)public UrlBuilder addAll(Map<String,Object> params)
params
- A map of parameters to add to the URLpublic String toUrl()
public String toUrl(boolean encodeAnchor)
Copyright © 2003–2017 Atlassian. All rights reserved.