|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.jira.util.UrlBuilder
@NotThreadSafe @PublicApi public final class UrlBuilder
Builds a URL from parameters.
NOTE: This class does not HTML escape the URLs. Be very careful if using this class to output a URL on the UI.
Constructor Summary | |
---|---|
UrlBuilder(boolean querySnippet)
Creates a builder with a blank URL. |
|
UrlBuilder(String urlFragment)
Creates a builder with the specified URL fragment. |
|
UrlBuilder(String urlFragment,
boolean querySnippet)
Creates a builder with the specified URL fragment. |
|
UrlBuilder(String urlFragment,
String encoding,
boolean querySnippet)
Creates a builder with the specified URL fragment. |
|
UrlBuilder(UrlBuilder source)
Creates a copy of the passed builder. |
Method Summary | |
---|---|
UrlBuilder |
addAnchor(String value)
Add the passed anchor value to the URL while URL encoding it. |
UrlBuilder |
addParameter(String name,
Object value)
Adds the passed parameter to the URL while URL encoding them. |
UrlBuilder |
addParameter(String name,
String value)
Adds the parameter to the URL while URL encoding them. |
UrlBuilder |
addParametersFromMap(Map<?,?> params)
Add multiple parameters from a map safely. |
UrlBuilder |
addParameterUnsafe(String name,
String value)
Adds the parameter to the URL without URL encoding them. |
UrlBuilder |
addPath(String path)
URL encodes and adds the given path to the URL. |
UrlBuilder |
addPaths(String paths)
URL encodes and adds the given paths to the URL. |
UrlBuilder |
addPathUnsafe(String path)
Adds the given path to the URL. |
URI |
asURI()
Returns the URL as a URI. |
String |
asUrlString()
Returns the URL as a String. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public UrlBuilder(boolean querySnippet)
querySnippet
- whether or not this URL is complete or just a query snippet
IllegalArgumentException
- if the base url is null.public UrlBuilder(UrlBuilder source)
source
- the builder to copy, cannot be null.
IllegalArgumentException
- if source is null.public UrlBuilder(String urlFragment)
urlFragment
- the URL fragment for the builder. This parameter will not be escaped in the resulting URL.
IllegalArgumentException
- if urlFragment
is null.public UrlBuilder(String urlFragment, boolean querySnippet)
urlFragment
- the URL or query snippet for the builder. This parameter will not be escaped in the resulting URL.querySnippet
- whether or not this URL is complete or just a query snippet
IllegalArgumentException
- if the urlFragment
is nullpublic UrlBuilder(String urlFragment, @Nullable String encoding, boolean querySnippet)
urlFragment
- the URL fragment for the builder. This parameter will not be escaped in the resulting URL.querySnippet
- whether or not this URL is complete or just a query snippet.encoding
- the character encoding to use for parameter names and values. Can be left null (recommended) to indicate JIRA default encoding.
IllegalArgumentException
- if urlFragment
is nullMethod Detail |
---|
public UrlBuilder addPathUnsafe(String path)
addPath(String)
.
path
- the path to add to the URL. This parameter name is not escaped before it is added to the URL.
public UrlBuilder addPath(String path)
path
- path to be encoded and added to the URL. The path cannot be blank.
IllegalArgumentException
- if path is blankpublic UrlBuilder addPaths(String paths)
paths
- paths to be encoded and added to the URL. E.g. "/one/two/three". Cannot be blank.
IllegalArgumentException
- if paths is blankpublic UrlBuilder addParameterUnsafe(String name, String value)
name
- the name of the parameter. This parameter name is not escaped before it is added to the URL. This
value cannot be blank.value
- the value of the parameter. This value is not escaped before it is added to the URL.
IllegalArgumentException
- if name is blankpublic UrlBuilder addParameter(String name, String value)
name
- the name of the parameter. This value cannot be blank.value
- the value of the parameter.
IllegalArgumentException
- if name is blankpublic UrlBuilder addParameter(String name, Object value)
name
- the name of the parameter. This value cannot be blank.value
- the value of the parameter
IllegalArgumentException
- if name is blankpublic UrlBuilder addAnchor(String value)
#myAnchor
.
Note that to be compliant with standards, you will want to call this only after adding all your parameters.
value
- the value of the anchor
IllegalArgumentException
- if name is blankpublic UrlBuilder addParametersFromMap(Map<?,?> params)
params
- map containing parameters to add. Must not be null.
public String asUrlString()
public URI asURI()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |