public class UrlBuilder extends Object
Given a URL and a set of parameters, provide abilites to add and remove parameters (either directly, from a Map, or from a Bean), and finally reconstruct the proper URL. For example:
UrlBuilder builder = new UrlBuilder() .setUrl( strUrl )) .addParameters( p_request.getParameterMap() );
.removeParameter( "id" ) .addParameter( "session", strSession );
Note that this class currently does not support URL rewriting of cookie strings (though it should).
Constructor and Description |
---|
UrlBuilder() |
Modifier and Type | Method and Description |
---|---|
UrlBuilder |
addParameter(String name,
Number value) |
UrlBuilder |
addParameter(String name,
String value) |
UrlBuilder |
addParameters(Map<String,Object> newParams)
Add parameters from a map
|
UrlBuilder |
addPath(String contextPath) |
String |
getParameter(String name)
Returns the first item in the params list
|
UrlBuilder |
removeParameter(String name) |
UrlBuilder |
setParameter(String name,
String value)
Add a single parameter
|
UrlBuilder |
setUrl(String url) |
UrlBuilder |
setUrlBase(String base) |
UrlBuilder |
setUrlBase(URL url) |
String |
toString() |
public UrlBuilder setUrlBase(String base)
public UrlBuilder setUrlBase(URL url)
public UrlBuilder addPath(String contextPath)
public UrlBuilder setUrl(String url)
public UrlBuilder addParameters(Map<String,Object> newParams)
public UrlBuilder setParameter(String name, String value)
public UrlBuilder addParameter(String name, String value)
public UrlBuilder addParameter(String name, Number value)
public UrlBuilder removeParameter(String name)
public String getParameter(String name)
name
- Copyright © 2019 Atlassian Software Systems Pty Ltd. All rights reserved.