UriBuilderFactory that relies on UriComponentsBuilder for
the actual building of the URI.
Provides options to create UriBuilder instances with a common
base URI, alternative encoding mode strategies, among others.
UriComponentsBuilder
| Modifier and Type | Class and Description |
|---|---|
| private class | DefaultUriBuilderFactory.DefaultUriBuilder
|
| public static enum | DefaultUriBuilderFactory.EncodingMode
Enum to represent multiple URI encoding strategies. |
| Modifier and Type | Field and Description |
|---|---|
| private final UriComponentsBuilder | |
| private Map | |
| private DefaultUriBuilderFactory. | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public | DefaultUriBuilderFactory(String
the URI template to use a base URL baseUriTemplate)Constructor with a base URI. |
| public | DefaultUriBuilderFactory(UriComponentsBuilder baseUri)
Variant of |
| Modifier and Type | Method and Description |
|---|---|
| public UriBuilder | builder()
Implements org. |
| public URI | expand(String
the URI template uriTemplate, Map<String, ?> variable values uriVars)Implements org. |
| public URI | expand(String
the URI template uriTemplate, Object... variable values uriVars)Implements org. |
| public Map | |
| public DefaultUriBuilderFactory. | |
| public final boolean | |
| public void | setDefaultUriVariables(Map<String, ?>
default URI variable values defaultUriVariables)Provide default URI variable values to use when expanding URI templates with a Map of variables. |
| public void | setEncodingMode(DefaultUriBuilderFactory.
the encoding mode to use encodingModeSet the |
| public void | setParsePath(boolean
whether to parse the path into path segments parsePath)Whether to parse the input path into path segments if the encoding mode
is set to |
| public boolean | shouldParsePath()
Whether to parse the path into path segments if the encoding mode is set
to |
| public UriBuilder | uriString(String
the URI template to use uriTemplate)Implements org. |
| baseUri | back to summary |
|---|---|
| private final UriComponentsBuilder baseUri
| |
| defaultUriVariables | back to summary |
|---|---|
| private Map<String, Object> defaultUriVariables
| |
| encodingMode | back to summary |
|---|---|
| private DefaultUriBuilderFactory. | |
| parsePath | back to summary |
|---|---|
| private boolean parsePath | |
| DefaultUriBuilderFactory | back to summary |
|---|---|
| public DefaultUriBuilderFactory() Default constructor without a base URI. The target address must be specified on each UriBuilder. | |
| DefaultUriBuilderFactory | back to summary |
|---|---|
| public DefaultUriBuilderFactory(String baseUriTemplate) Constructor with a base URI. The given URI template is parsed via
| |
| DefaultUriBuilderFactory | back to summary |
|---|---|
| public DefaultUriBuilderFactory(UriComponentsBuilder baseUri) Variant of | |
| builder | back to summary |
|---|---|
| public UriBuilder builder() Implements org. Doc from org. Create a URI builder with default settings.
| |
| expand | back to summary |
|---|---|
| public URI expand(String uriTemplate, Map<String, ?> uriVars) Implements org. Doc from org. Expand the given URI template with a map of URI variables. | |
| expand | back to summary |
|---|---|
| public URI expand(String uriTemplate, Object... uriVars) Implements org. Doc from org. Expand the given URI template with an array of URI variables. | |
| getDefaultUriVariables | back to summary |
|---|---|
| public Map Return the configured default URI variable values. | |
| getEncodingMode | back to summary |
|---|---|
| public DefaultUriBuilderFactory. Return the configured encoding mode. | |
| hasBaseUri | back to summary |
|---|---|
| public final boolean hasBaseUri() Determine whether this factory has been configured with a base URI.
| |
| setDefaultUriVariables | back to summary |
|---|---|
| public void setDefaultUriVariables(Map<String, ?> defaultUriVariables) Provide default URI variable values to use when expanding URI templates with a Map of variables. | |
| setEncodingMode | back to summary |
|---|---|
| public void setEncodingMode(DefaultUriBuilderFactory. Set the By default this is set to Note Prior to 5.1 the default was
| |
| setParsePath | back to summary |
|---|---|
| public void setParsePath(boolean parsePath) Whether to parse the input path into path segments if the encoding mode
is set to By default this is set to
| |
| shouldParsePath | back to summary |
|---|---|
| public boolean shouldParsePath() Whether to parse the path into path segments if the encoding mode is set
to | |
| uriString | back to summary |
|---|---|
| public UriBuilder uriString(String uriTemplate) Implements org. Doc from org. Initialize a builder with the given URI template.
| |
DefaultUriBuilderFactory specific implementation of UriBuilder.
| Modifier and Type | Field and Description |
|---|---|
| private final UriComponentsBuilder |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public URI | build(Map<String, ?>
the map of URI variables uriVars)Implements org. URI instance and replaces URI template variables
with the values from a map.
|
| public URI | build(Object...
the map of URI variables uriVars)Implements org. URI instance and replaces URI template variables
with the values from an array.
|
| private URI | |
| public DefaultUriBuilderFactory. | fragment(String
the URI fragment fragment)Implements org. |
| public DefaultUriBuilderFactory. | host(String
the URI host host)Implements org. null to clear the host of this builder.
|
| private UriComponentsBuilder | |
| private void | |
| public DefaultUriBuilderFactory. | path(String
the URI path path)Implements org. |
| public DefaultUriBuilderFactory. | pathSegment(String...
the URI path segments pathSegments)Implements org. |
| public DefaultUriBuilderFactory. | port(int
the URI port port)Implements org. |
| public DefaultUriBuilderFactory. | port(String
the URI port port)Implements org. |
| public DefaultUriBuilderFactory. | query(String
the query string query)Implements org. '&' and their values, if any, with '='.
|
| public DefaultUriBuilderFactory. | queryParam(String
the query parameter name name, Object... the query parameter values values)Implements org. |
| public DefaultUriBuilderFactory. | queryParam(String
the query parameter name name, Collection<?> the query parameter values values)Implements org. queryParam(String, Object. with a Collection.
|
| public DefaultUriBuilderFactory. | queryParamIfPresent(String
the query parameter name name, Optional<?> an Optional, either empty or holding the query parameter value. value)Implements org. queryParam(String, Object. or
queryParam(String, Collection) if the given Optional has
a value, or else if it is empty, no query parameter is added at all.
|
| public DefaultUriBuilderFactory. | queryParams(MultiValueMap<String, String>
the params params)Implements org. |
| public DefaultUriBuilderFactory. | replacePath(String
the URI path, or path)null for an empty pathImplements org. |
| public DefaultUriBuilderFactory. | replaceQuery(String
the query string; a query)null value removes all query parameters.Implements org. query(String).
|
| public DefaultUriBuilderFactory. | replaceQueryParam(String
the query parameter name name, Object... the query parameter values values)Implements org. |
| public DefaultUriBuilderFactory. | replaceQueryParam(String
the query parameter name name, Collection<?> the query parameter values values)Implements org. replaceQueryParam(String, Object. with a Collection.
|
| public DefaultUriBuilderFactory. | replaceQueryParams(MultiValueMap<String, String>
the query parameter name params)Implements org. |
| public DefaultUriBuilderFactory. | scheme(String
the URI scheme scheme)Implements org. null to clear the scheme of this builder.
|
| public String | toUriString()
Implements org. |
| public DefaultUriBuilderFactory. | userInfo(String
the URI user info userInfo)Implements org. null to clear the user info of this builder.
|
| uriComponentsBuilder | back to summary |
|---|---|
| private final UriComponentsBuilder uriComponentsBuilder | |
| DefaultUriBuilder | back to summary |
|---|---|
| public DefaultUriBuilder(String uriTemplate) | |
| build | back to summary |
|---|---|
| public URI build(Map<String, ?> uriVars) Implements org. Doc from org. Build a | |
| build | back to summary |
|---|---|
| public URI build(Object... uriVars) Implements org. Doc from org. Build a | |
| createUri | back to summary |
|---|---|
| private URI createUri(UriComponents uric) | |
| fragment | back to summary |
|---|---|
| public DefaultUriBuilderFactory. Implements org. Doc from org. Set the URI fragment. The given fragment may contain URI template variables,
and may also be | |
| host | back to summary |
|---|---|
| public DefaultUriBuilderFactory. Implements org. Doc from org. Set the URI host which may contain URI template variables, and may also
be | |
| initUriComponentsBuilder | back to summary |
|---|---|
| private UriComponentsBuilder initUriComponentsBuilder(String uriTemplate) | |
| parsePathIfNecessary | back to summary |
|---|---|
| private void parsePathIfNecessary(UriComponentsBuilder result) | |
| path | back to summary |
|---|---|
| public DefaultUriBuilderFactory. Implements org. Doc from org. 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 DefaultUriBuilderFactory. Implements org. Doc from org. 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 DefaultUriBuilderFactory. Implements org. Doc from org. Set the URI port. Passing
| |
| port | back to summary |
|---|---|
| public DefaultUriBuilderFactory. Implements org. Doc from org. 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 DefaultUriBuilderFactory. Implements org. Doc from org. Parse the given query string into query parameters where parameters are
separated with Note please, review the Javadoc of
| |
| queryParam | back to summary |
|---|---|
| public DefaultUriBuilderFactory. Implements org. Doc from org. 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 DefaultUriBuilderFactory. Implements org. Doc from org. Variant of Note please, review the Javadoc of
| |
| queryParamIfPresent | back to summary |
|---|---|
| public DefaultUriBuilderFactory. Implements org. Doc from org. Delegates to either | |
| queryParams | back to summary |
|---|---|
| public DefaultUriBuilderFactory. Implements org. Doc from org. Add multiple query parameters and values. Note please, review the Javadoc of
| |
| replacePath | back to summary |
|---|---|
| public DefaultUriBuilderFactory. Implements org. Doc from org. Override the current path. | |
| replaceQuery | back to summary |
|---|---|
| public DefaultUriBuilderFactory. Implements org. Doc from org. Clear existing query parameters and then delegate to Note please, review the Javadoc of
| |
| replaceQueryParam | back to summary |
|---|---|
| public DefaultUriBuilderFactory. Implements org. Doc from org. 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 DefaultUriBuilderFactory. Implements org. Doc from org. Variant of Note please, review the Javadoc of
| |
| replaceQueryParams | back to summary |
|---|---|
| public DefaultUriBuilderFactory. Implements org. Doc from org. Set the query parameter values after removing all existing ones. Note please, review the Javadoc of
| |
| scheme | back to summary |
|---|---|
| public DefaultUriBuilderFactory. Implements org. Doc from org. Set the URI scheme which may contain URI template variables,
and may also be | |
| toUriString | back to summary |
|---|---|
| public String toUriString() Implements org. Doc from org. 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 DefaultUriBuilderFactory. Implements org. Doc from org. Set the URI user info which may contain URI template variables, and
may also be | |
setEncodingMode
| Modifier and Type | Field and Description |
|---|---|
| public static final DefaultUriBuilderFactory. | NONE
No encoding should be applied. |
| public static final DefaultUriBuilderFactory. | TEMPLATE_AND_VALUES
Pre-encode the URI template first, then strictly encode URI variables when expanded, with the following rules:
|
| public static final DefaultUriBuilderFactory. | URI_COMPONENT
Expand URI variables first, and then encode the resulting URI component values, replacing only non-ASCII and illegal (within a given URI component type) characters, but not characters with reserved meaning. |
| public static final DefaultUriBuilderFactory. | VALUES_ONLY
Does not encode the URI template and instead applies strict encoding
to URI variables via |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static DefaultUriBuilderFactory. | |
| public static DefaultUriBuilderFactory. |
| NONE | back to summary |
|---|---|
| public static final DefaultUriBuilderFactory. No encoding should be applied. | |
| TEMPLATE_AND_VALUES | back to summary |
|---|---|
| public static final DefaultUriBuilderFactory. Pre-encode the URI template first, then strictly encode URI variables when expanded, with the following rules:
For most cases, this mode is most likely to give the expected
result because in treats URI variables as opaque data to be fully
encoded, while
| |
| URI_COMPONENT | back to summary |
|---|---|
| public static final DefaultUriBuilderFactory. Expand URI variables first, and then encode the resulting URI component values, replacing only non-ASCII and illegal (within a given URI component type) characters, but not characters with reserved meaning.
| |
| VALUES_ONLY | back to summary |
|---|---|
| public static final DefaultUriBuilderFactory. Does not encode the URI template and instead applies strict encoding
to URI variables via | |
| EncodingMode | back to summary |
|---|---|
| private EncodingMode() | |
| valueOf | back to summary |
|---|---|
| public static DefaultUriBuilderFactory. | |
| values | back to summary |
|---|---|
| public static DefaultUriBuilderFactory. | |