java.lang.Object | |
↳ | com.atlassian.jira.util.UrlBuilder |
Clients of @PublicApi
can expect
that programs compiled against a given version will remain binary compatible with later versions of the
@PublicApi
as per each product's API policy as long as the client does not implement/extend
@PublicApi
interfaces or classes (refer to each product's API policy for the exact
guarantee---usually binary compatibility is guaranteed at least across minor versions).
@PublicApi
interfaces and classes are not designed to be implemented or extended by clients,
we may perform certain types of binary-incompatible changes to these classes and interfaces, but these will not
affect well-behaved clients that do not extend/implement these types (in general, only classes and interfaces
annotated with @PublicSpi
are safe to extend/implement).
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.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates a builder with a blank URL.
| |||||||||||
Creates a copy of the passed builder.
| |||||||||||
Creates a builder with the specified URL fragment.
| |||||||||||
Creates a builder with the specified URL fragment.
| |||||||||||
Creates a builder with the specified URL fragment.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add the passed anchor value to the URL while URL encoding it.
| |||||||||||
Adds the parameter to the URL while URL encoding them.
| |||||||||||
Adds the passed parameter to the URL while URL encoding them.
| |||||||||||
Adds the parameter to the URL without URL encoding them.
| |||||||||||
Add multiple parameters from a map safely.
| |||||||||||
URL encodes and adds the given path to the URL.
| |||||||||||
Adds the given path to the URL.
| |||||||||||
URL encodes and adds the given paths to the URL.
| |||||||||||
Returns the URL as a URI.
| |||||||||||
Returns the URL as a String.
| |||||||||||
Returns the same thing as
asUrlString() , to avoid confusion. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Creates a builder with a blank URL.
querySnippet | whether or not this URL is complete or just a query snippet |
---|
IllegalArgumentException | if the base url is null. |
---|
Creates a copy of the passed builder. The state of the two builders will be independent after the copy.
source | the builder to copy, cannot be null. |
---|
IllegalArgumentException | if source is null. |
---|
Creates a builder with the specified URL fragment. The URL will be used as the start of the URL generated by this builder.
urlFragment | the URL fragment for the builder. This parameter will not be escaped in the resulting URL. |
---|
IllegalArgumentException | if urlFragment is null.
|
---|
Creates a builder with the specified URL fragment. The URL will be used as the start of the URL generated by this builder.
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 null
|
---|
Creates a builder with the specified URL fragment. The URL will be used as the start of the URL generated by this builder.
urlFragment | the URL fragment for the builder. This parameter will not be escaped in the resulting URL. |
---|---|
encoding | the character encoding to use for parameter names and values. Can be left null (recommended) to indicate JIRA default encoding. |
querySnippet | whether or not this URL is complete or just a query snippet. |
IllegalArgumentException | if urlFragment is null
|
---|
Add the passed anchor value to the URL while URL encoding it. The result will be something like #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 blank |
---|
Adds the parameter to the URL while URL encoding them.
name | the name of the parameter. This value cannot be blank. |
---|---|
value | the value of the parameter. |
IllegalArgumentException | if name is blank |
---|
Adds the passed parameter to the URL while URL encoding them.
name | the name of the parameter. This value cannot be blank. |
---|---|
value | the value of the parameter |
IllegalArgumentException | if name is blank |
---|
Adds the parameter to the URL without URL encoding them. This is UNSAFE as it may allow XSS attacks. If you use this method, you must ensure that the parameters are already safe.
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 blank |
---|
Add multiple parameters from a map safely. Any keys which are null or blank will be ignored. The parameters will be added in order as given by the passed map's entrySet.
params | map containing parameters to add. Must not be null. |
---|
URL encodes and adds the given path to the URL. If needed a '/' will be added between the existing URL and the given path.
path | path to be encoded and added to the URL. The path cannot be blank. |
---|
IllegalArgumentException | if path is blank |
---|
Adds the given path to the URL. If needed, a '/' will be added between the existing URL and the given path. If
you use this method, you must ensure that the parameters are already safe. Otherwise, use addPath(String)
.
path | the path to add to the URL. This parameter name is not escaped before it is added to the URL. |
---|
URL encodes and adds the given paths to the URL. If needed a '/' will be added between the existing URL and the given paths. The paths in between the path separator ('/') will be encoded.
paths | paths to be encoded and added to the URL. E.g. "/one/two/three". Cannot be blank. |
---|
IllegalArgumentException | if paths is blank |
---|
Returns the same thing as asUrlString()
, to avoid confusion.
asUrlString()