Effectively a generalization of UriComponentsBuilder but with
shortcuts to expand directly into URI rather than
UriComponents and also leaving common concerns such as encoding
preferences, a base URI, and others as implementation concerns.
Typically obtained via UriBuilderFactory which serves as a central
component configured once and used to create many URLs.
UriBuilderFactory, UriComponentsBuilder
| Modifier and Type | Method and Description |
|---|---|
| public URI | |
| public URI | |
| public UriBuilder | |
| public UriBuilder | |
| public UriBuilder | |
| public UriBuilder | |
| public UriBuilder | |
| public UriBuilder | |
| public UriBuilder | |
| public UriBuilder | queryParam(String
the query parameter name name, Object... the query parameter values values)Append the given query parameter. |
| public UriBuilder | queryParam(String
the query parameter name name, Collection<?> the query parameter values values)Variant of |
| public UriBuilder | queryParamIfPresent(String
the query parameter name name, Optional<?> an Optional, either empty or holding the query parameter value. value)Delegates to either |
| public UriBuilder | queryParams(MultiValueMap<String, String>
the params params)Add multiple query parameters and values. |
| public UriBuilder | |
| public UriBuilder | replaceQuery(String
the query string; a query)null value removes all query parameters.Clear existing query parameters and then delegate to |
| public UriBuilder | replaceQueryParam(String
the query parameter name name, Object... the query parameter values values)Set the query parameter values replacing existing values, or if no values are given, the query parameter is removed. |
| public UriBuilder | replaceQueryParam(String
the query parameter name name, Collection<?> the query parameter values values)Variant of |
| public UriBuilder | replaceQueryParams(MultiValueMap<String, String>
the query parameter name params)Set the query parameter values after removing all existing ones. |
| public UriBuilder | |
| public String | toUriString()
Return a String representation of the URI by concatenating all URI component values into the fully formed URI String. |
| public UriBuilder |
| build | back to summary |
|---|---|
| public URI build(Object... uriVariables) Build a | |
| build | back to summary |
|---|---|
| public URI build(Map<String, ?> uriVariables) Build a | |
| fragment | back to summary |
|---|---|
| public UriBuilder fragment(String fragment) Set the URI fragment. The given fragment may contain URI template variables,
and may also be
| |
| host | back to summary |
|---|---|
| public UriBuilder host(String host) Set the URI host which may contain URI template variables, and may also
be
| |
| path | back to summary |
|---|---|
| public UriBuilder path(String path) Append to the path of this builder. The given value is appended as-is to previous
builder.path("/first-").path("value/").path("/{id}").build("123")
// Results is "/first-value/123"
By contrast
builder.pathSegment("first-value", "second-value").path("/")
// Results is "/first-value/second-value/"
The resulting full path is normalized to eliminate duplicate slashes. Note When inserting a URI variable value that
contains slashes in a
| |
| pathSegment | back to summary |
|---|---|
| public UriBuilder pathSegment(String... pathSegments) throws IllegalArgumentException Append to the path using path segments. For example:
builder.pathSegment("first-value", "second-value", "{id}").build("123")
// Results is "/first-value/second-value/123"
If slashes are present in a path segment, they are encoded:
builder.pathSegment("ba/z", "{id}").build("a/b")
// Results is "/ba%2Fz/a%2Fb"
To insert a trailing slash, use the path builder method:
builder.pathSegment("first-value", "second-value").path("/")
// Results is "/first-value/second-value/"
Empty path segments are ignored and therefore duplicate slashes do not appear in the resulting full path.
| |
| port | back to summary |
|---|---|
| public UriBuilder port(int port) Set the URI port. Passing
| |
| port | back to summary |
|---|---|
| public UriBuilder port(String port) Set the URI port. Use this method only when the port needs to be
parameterized with a URI variable. Otherwise use
| |
| query | back to summary |
|---|---|
| public UriBuilder query(String query) Parse the given query string into query parameters where parameters are
separated with Note please, review the Javadoc of
| |
| queryParam | back to summary |
|---|---|
| public UriBuilder queryParam(String name, Object... values) Append the given query parameter. Both the parameter name and values may
contain URI template variables to be expanded later from values. If no
values are given, the resulting URI will contain the query parameter name
only, e.g. Note encoding, if applied, will only encode characters
that are illegal in a query parameter name or value such as
| |
| queryParam | back to summary |
|---|---|
| public UriBuilder queryParam(String name, Collection<?> values) Variant of Note please, review the Javadoc of
| |
| queryParamIfPresent | back to summary |
|---|---|
| public UriBuilder queryParamIfPresent(String name, Optional<?> value) Delegates to either | |
| queryParams | back to summary |
|---|---|
| public UriBuilder queryParams(MultiValueMap<String, String> params) Add multiple query parameters and values. Note please, review the Javadoc of
| |
| replacePath | back to summary |
|---|---|
| public UriBuilder replacePath(String path) Override the current path.
| |
| replaceQuery | back to summary |
|---|---|
| public UriBuilder replaceQuery(String query) Clear existing query parameters and then delegate to Note please, review the Javadoc of
| |
| replaceQueryParam | back to summary |
|---|---|
| public UriBuilder replaceQueryParam(String name, Object... values) Set the query parameter values replacing existing values, or if no values are given, the query parameter is removed. Note please, review the Javadoc of
| |
| replaceQueryParam | back to summary |
|---|---|
| public UriBuilder replaceQueryParam(String name, Collection<?> values) Variant of Note please, review the Javadoc of
| |
| replaceQueryParams | back to summary |
|---|---|
| public UriBuilder replaceQueryParams(MultiValueMap<String, String> params) Set the query parameter values after removing all existing ones. Note please, review the Javadoc of
| |
| scheme | back to summary |
|---|---|
| public UriBuilder scheme(String scheme) Set the URI scheme which may contain URI template variables,
and may also be
| |
| toUriString | back to summary |
|---|---|
| public String toUriString() Return a String representation of the URI by concatenating all URI component values into the fully formed URI String. Implementing classes should perform simple String concatenation of current URI component values to preserve URI template placeholders.
| |
| userInfo | back to summary |
|---|---|
| public UriBuilder userInfo(String userInfo) Set the URI user info which may contain URI template variables, and
may also be
| |