Top Description Inners Fields Constructors Methods
org.springframework.web.util

public Class DefaultUriBuilderFactory

extends Object
implements UriBuilderFactory
Class Inheritance
All Implemented Interfaces
org.springframework.web.util.UriBuilderFactory, org.springframework.web.util.UriTemplateHandler
Imports
java.net.URI, java.util.Collection, .Collections, .HashMap, .Map, .Optional, org.springframework.lang.Nullable, org.springframework.util.CollectionUtils, .MultiValueMap, .ObjectUtils, .StringUtils

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.

Author
Rossen Stoyanchev
Since
5.0
See Also
UriComponentsBuilder

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
public static enum
DefaultUriBuilderFactory.EncodingMode

Enum to represent multiple URI encoding strategies.

Field Summary

Modifier and TypeField and Description
private final UriComponentsBuilder
private Map<String, Object>
private DefaultUriBuilderFactory.EncodingMode
private boolean

Constructor Summary

AccessConstructor and Description
public
DefaultUriBuilderFactory()

Default constructor without a base URI.

public
DefaultUriBuilderFactory(String
the URI template to use a base URL
baseUriTemplate
)

Constructor with a base URI.

public
DefaultUriBuilderFactory(UriComponentsBuilder baseUri)

Variant of DefaultUriBuilderFactory(String) with a UriComponentsBuilder.

Method Summary

Modifier and TypeMethod and Description
public UriBuilder
builder()

Implements org.springframework.web.util.UriBuilderFactory.builder.

Create a URI builder with default settings.
public URI
expand(String
the URI template
uriTemplate
,
Map<String, ?>
variable values
uriVars
)

Implements org.springframework.web.util.UriTemplateHandler.expand.

Expand the given URI template with a map of URI variables.
public URI
expand(String
the URI template
uriTemplate
,
Object...
variable values
uriVars
)

Implements org.springframework.web.util.UriTemplateHandler.expand.

Expand the given URI template with an array of URI variables.
public Map<String, ?>
getDefaultUriVariables()

Return the configured default URI variable values.

public DefaultUriBuilderFactory.EncodingMode
getEncodingMode()

Return the configured encoding mode.

public final boolean
hasBaseUri()

Determine whether this factory has been configured with a base URI.

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.EncodingMode
the encoding mode to use
encodingMode
)

Set the encoding mode to use.

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 EncodingMode.URI_COMPONENT, which ensures that URI variables in the path are encoded according to path segment rules and for example a '/' is encoded.

public boolean
shouldParsePath()

Whether to parse the path into path segments if the encoding mode is set to EncodingMode.URI_COMPONENT.

public UriBuilder
uriString(String
the URI template to use
uriTemplate
)

Implements org.springframework.web.util.UriBuilderFactory.uriString.

Initialize a builder with the given URI template.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

baseUriback to summary
private final UriComponentsBuilder baseUri
Annotations
@Nullable
defaultUriVariablesback to summary
private Map<String, Object> defaultUriVariables
Annotations
@Nullable
encodingModeback to summary
private DefaultUriBuilderFactory.EncodingMode encodingMode
parsePathback to summary
private boolean parsePath

Constructor Detail

DefaultUriBuilderFactoryback to summary
public DefaultUriBuilderFactory()

Default constructor without a base URI.

The target address must be specified on each UriBuilder.

DefaultUriBuilderFactoryback to summary
public DefaultUriBuilderFactory(String baseUriTemplate)

Constructor with a base URI.

The given URI template is parsed via UriComponentsBuilder#fromUriString and then applied as a base URI to every UriBuilder via UriComponentsBuilder#uriComponents unless the UriBuilder itself was created with a URI template that already has a target address.

Parameters
baseUriTemplate:String

the URI template to use a base URL

DefaultUriBuilderFactoryback to summary
public DefaultUriBuilderFactory(UriComponentsBuilder baseUri)

Variant of DefaultUriBuilderFactory(String) with a UriComponentsBuilder.

Method Detail

builderback to summary
public UriBuilder builder()

Implements org.springframework.web.util.UriBuilderFactory.builder.

Doc from org.springframework.web.util.UriBuilderFactory.builder.

Create a URI builder with default settings.

Returns:UriBuilder

the builder instance

Annotations
@Override
expandback to summary
public URI expand(String uriTemplate, Map<String, ?> uriVars)

Implements org.springframework.web.util.UriTemplateHandler.expand.

Doc from org.springframework.web.util.UriTemplateHandler.expand.

Expand the given URI template with a map of URI variables.

Parameters
uriTemplate:String

the URI template

uriVars:Map<String, ?>

variable values

Returns:URI

the created URI instance

Annotations
@Override
expandback to summary
public URI expand(String uriTemplate, Object... uriVars)

Implements org.springframework.web.util.UriTemplateHandler.expand.

Doc from org.springframework.web.util.UriTemplateHandler.expand.

Expand the given URI template with an array of URI variables.

Parameters
uriTemplate:String

the URI template

uriVars:Object[]

variable values

Returns:URI

the created URI instance

Annotations
@Override
getDefaultUriVariablesback to summary
public Map<String, ?> getDefaultUriVariables()

Return the configured default URI variable values.

getEncodingModeback to summary
public DefaultUriBuilderFactory.EncodingMode getEncodingMode()

Return the configured encoding mode.

hasBaseUriback to summary
public final boolean hasBaseUri()

Determine whether this factory has been configured with a base URI.

Since
6.1.4
See Also
DefaultUriBuilderFactory()
setDefaultUriVariablesback to summary
public void setDefaultUriVariables(Map<String, ?> defaultUriVariables)

Provide default URI variable values to use when expanding URI templates with a Map of variables.

Parameters
defaultUriVariables:Map<String, ?>

default URI variable values

setEncodingModeback to summary
public void setEncodingMode(DefaultUriBuilderFactory.EncodingMode encodingMode)

Set the encoding mode to use.

By default this is set to EncodingMode.TEMPLATE_AND_VALUES.

Note

Prior to 5.1 the default was EncodingMode.URI_COMPONENT therefore the WebClient RestTemplate have switched their default behavior.

Parameters
encodingMode:DefaultUriBuilderFactory.EncodingMode

the encoding mode to use

setParsePathback to summary
public void setParsePath(boolean parsePath)

Whether to parse the input path into path segments if the encoding mode is set to EncodingMode.URI_COMPONENT, which ensures that URI variables in the path are encoded according to path segment rules and for example a '/' is encoded.

By default this is set to true.

Parameters
parsePath:boolean

whether to parse the path into path segments

shouldParsePathback to summary
public boolean shouldParsePath()

Whether to parse the path into path segments if the encoding mode is set to EncodingMode.URI_COMPONENT.

uriStringback to summary
public UriBuilder uriString(String uriTemplate)

Implements org.springframework.web.util.UriBuilderFactory.uriString.

Doc from org.springframework.web.util.UriBuilderFactory.uriString.

Initialize a builder with the given URI template.

Parameters
uriTemplate:String

the URI template to use

Returns:UriBuilder

the builder instance

Annotations
@Override
org.springframework.web.util back to summary

private Class DefaultUriBuilderFactory.DefaultUriBuilder

extends Object
implements UriBuilder
Class Inheritance
  • java.lang.Object
  • org.springframework.web.util.DefaultUriBuilderFactory.DefaultUriBuilder
All Implemented Interfaces
org.springframework.web.util.UriBuilder

DefaultUriBuilderFactory specific implementation of UriBuilder.

Field Summary

Modifier and TypeField and Description
private final UriComponentsBuilder

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public URI
build(Map<String, ?>
the map of URI variables
uriVars
)

Implements org.springframework.web.util.UriBuilder.build.

Build a 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.springframework.web.util.UriBuilder.build.

Build a URI instance and replaces URI template variables with the values from an array.
private URI
public DefaultUriBuilderFactory.DefaultUriBuilder
fragment(String
the URI fragment
fragment
)

Implements org.springframework.web.util.UriBuilder.fragment.

Set the URI fragment.
public DefaultUriBuilderFactory.DefaultUriBuilder
host(String
the URI host
host
)

Implements org.springframework.web.util.UriBuilder.host.

Set the URI host which may contain URI template variables, and may also be null to clear the host of this builder.
private UriComponentsBuilder
private void
public DefaultUriBuilderFactory.DefaultUriBuilder
path(String
the URI path
path
)

Implements org.springframework.web.util.UriBuilder.path.

Append to the path of this builder.
public DefaultUriBuilderFactory.DefaultUriBuilder
pathSegment(String...
the URI path segments
pathSegments
)

Implements org.springframework.web.util.UriBuilder.pathSegment.

Append to the path using path segments.
public DefaultUriBuilderFactory.DefaultUriBuilder
port(int
the URI port
port
)

Implements org.springframework.web.util.UriBuilder.port.

Set the URI port.
public DefaultUriBuilderFactory.DefaultUriBuilder
port(String
the URI port
port
)

Implements org.springframework.web.util.UriBuilder.port.

Set the URI port.
public DefaultUriBuilderFactory.DefaultUriBuilder
query(String
the query string
query
)

Implements org.springframework.web.util.UriBuilder.query.

Parse the given query string into query parameters where parameters are separated with '&' and their values, if any, with '='.
public DefaultUriBuilderFactory.DefaultUriBuilder
queryParam(String
the query parameter name
name
,
Object...
the query parameter values
values
)

Implements org.springframework.web.util.UriBuilder.queryParam.

Append the given query parameter.
public DefaultUriBuilderFactory.DefaultUriBuilder
queryParam(String
the query parameter name
name
,
Collection<?>
the query parameter values
values
)

Implements org.springframework.web.util.UriBuilder.queryParam.

Variant of queryParam(String, Object...) with a Collection.
public DefaultUriBuilderFactory.DefaultUriBuilder
queryParamIfPresent(String
the query parameter name
name
,
Optional<?>
an Optional, either empty or holding the query parameter value.
value
)

Implements org.springframework.web.util.UriBuilder.queryParamIfPresent.

Delegates to either 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.DefaultUriBuilder
queryParams(MultiValueMap<String, String>
the params
params
)

Implements org.springframework.web.util.UriBuilder.queryParams.

Add multiple query parameters and values.
public DefaultUriBuilderFactory.DefaultUriBuilder
replacePath(String
the URI path, or null for an empty path
path
)

Implements org.springframework.web.util.UriBuilder.replacePath.

Override the current path.
public DefaultUriBuilderFactory.DefaultUriBuilder
replaceQuery(String
the query string; a null value removes all query parameters.
query
)

Implements org.springframework.web.util.UriBuilder.replaceQuery.

Clear existing query parameters and then delegate to query(String).
public DefaultUriBuilderFactory.DefaultUriBuilder
replaceQueryParam(String
the query parameter name
name
,
Object...
the query parameter values
values
)

Implements org.springframework.web.util.UriBuilder.replaceQueryParam.

Set the query parameter values replacing existing values, or if no values are given, the query parameter is removed.
public DefaultUriBuilderFactory.DefaultUriBuilder
replaceQueryParam(String
the query parameter name
name
,
Collection<?>
the query parameter values
values
)

Implements org.springframework.web.util.UriBuilder.replaceQueryParam.

Variant of replaceQueryParam(String, Object...) with a Collection.
public DefaultUriBuilderFactory.DefaultUriBuilder
replaceQueryParams(MultiValueMap<String, String>
the query parameter name
params
)

Implements org.springframework.web.util.UriBuilder.replaceQueryParams.

Set the query parameter values after removing all existing ones.
public DefaultUriBuilderFactory.DefaultUriBuilder
scheme(String
the URI scheme
scheme
)

Implements org.springframework.web.util.UriBuilder.scheme.

Set the URI scheme which may contain URI template variables, and may also be null to clear the scheme of this builder.
public String
toUriString()

Implements org.springframework.web.util.UriBuilder.toUriString.

Return a String representation of the URI by concatenating all URI component values into the fully formed URI String.
public DefaultUriBuilderFactory.DefaultUriBuilder
userInfo(String
the URI user info
userInfo
)

Implements org.springframework.web.util.UriBuilder.userInfo.

Set the URI user info which may contain URI template variables, and may also be null to clear the user info of this builder.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

uriComponentsBuilderback to summary
private final UriComponentsBuilder uriComponentsBuilder

Constructor Detail

DefaultUriBuilderback to summary
public DefaultUriBuilder(String uriTemplate)

Method Detail

buildback to summary
public URI build(Map<String, ?> uriVars)

Implements org.springframework.web.util.UriBuilder.build.

Doc from org.springframework.web.util.UriBuilder.build.

Build a URI instance and replaces URI template variables with the values from a map.

Parameters
uriVars:Map<String, ?>

the map of URI variables

Returns:URI

the URI

Annotations
@Override
buildback to summary
public URI build(Object... uriVars)

Implements org.springframework.web.util.UriBuilder.build.

Doc from org.springframework.web.util.UriBuilder.build.

Build a URI instance and replaces URI template variables with the values from an array.

Parameters
uriVars:Object[]

the map of URI variables

Returns:URI

the URI

Annotations
@Override
createUriback to summary
private URI createUri(UriComponents uric)
fragmentback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder fragment(String fragment)

Implements org.springframework.web.util.UriBuilder.fragment.

Doc from org.springframework.web.util.UriBuilder.fragment.

Set the URI fragment. The given fragment may contain URI template variables, and may also be null to clear the fragment of this builder.

Parameters
fragment:String

the URI fragment

Annotations
@Override
hostback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder host(String host)

Implements org.springframework.web.util.UriBuilder.host.

Doc from org.springframework.web.util.UriBuilder.host.

Set the URI host which may contain URI template variables, and may also be null to clear the host of this builder.

Parameters
host:String

the URI host

Annotations
@Override
initUriComponentsBuilderback to summary
private UriComponentsBuilder initUriComponentsBuilder(String uriTemplate)
parsePathIfNecessaryback to summary
private void parsePathIfNecessary(UriComponentsBuilder result)
pathback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder path(String path)

Implements org.springframework.web.util.UriBuilder.path.

Doc from org.springframework.web.util.UriBuilder.path.

Append to the path of this builder.

The given value is appended as-is to previous path values without inserting any additional slashes. For example:


builder.path("/first-").path("value/").path("/{id}").build("123")

// Results is "/first-value/123"

By contrast pathSegment does insert slashes between individual path segments. For example:


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 path, whether those are encoded depends on the configured encoding mode. For more details, see UriComponentsBuilder#encode(), or otherwise if building URIs indirectly via WebClient or RestTemplate, see its encodingMode. Also see the URI Encoding section of the reference docs.

Parameters
path:String

the URI path

Annotations
@Override
pathSegmentback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder pathSegment(String... pathSegments)

Implements org.springframework.web.util.UriBuilder.pathSegment.

Doc from org.springframework.web.util.UriBuilder.pathSegment.

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.

Parameters
pathSegments:String[]

the URI path segments

Annotations
@Override
portback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder port(int port)

Implements org.springframework.web.util.UriBuilder.port.

Doc from org.springframework.web.util.UriBuilder.port.

Set the URI port. Passing -1 will clear the port of this builder.

Parameters
port:int

the URI port

Annotations
@Override
portback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder port(String port)

Implements org.springframework.web.util.UriBuilder.port.

Doc from org.springframework.web.util.UriBuilder.port.

Set the URI port. Use this method only when the port needs to be parameterized with a URI variable. Otherwise use port(int). Passing null will clear the port of this builder.

Parameters
port:String

the URI port

Annotations
@Override
queryback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder query(String query)

Implements org.springframework.web.util.UriBuilder.query.

Doc from org.springframework.web.util.UriBuilder.query.

Parse the given query string into query parameters where parameters are separated with '&' and their values, if any, with '='. The query may contain URI template variables.

Note

please, review the Javadoc of queryParam(String, Object...) for further notes on the treatment and encoding of individual query parameters.

Parameters
query:String

the query string

Annotations
@Override
queryParamback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder queryParam(String name, Object... values)

Implements org.springframework.web.util.UriBuilder.queryParam.

Doc from org.springframework.web.util.UriBuilder.queryParam.

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. "?foo" instead of "?foo=bar".

Note

encoding, if applied, will only encode characters that are illegal in a query parameter name or value such as "=" or "&". All others that are legal as per syntax rules in RFC 3986 are not encoded. This includes "+" which sometimes needs to be encoded to avoid its interpretation as an encoded space. Stricter encoding may be applied by using a URI template variable along with stricter encoding on variable values. For more details please read the "URI Encoding" section of the Spring Framework reference.

Parameters
name:String

the query parameter name

values:Object[]

the query parameter values

Annotations
@Override
queryParamback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder queryParam(String name, Collection<?> values)

Implements org.springframework.web.util.UriBuilder.queryParam.

Doc from org.springframework.web.util.UriBuilder.queryParam.

Variant of queryParam(String, Object...) with a Collection.

Note

please, review the Javadoc of queryParam(String, Object...) for further notes on the treatment and encoding of individual query parameters.

Parameters
name:String

the query parameter name

values:Collection<?>

the query parameter values

Annotations
@Override
queryParamIfPresentback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder queryParamIfPresent(String name, Optional<?> value)

Implements org.springframework.web.util.UriBuilder.queryParamIfPresent.

Doc from org.springframework.web.util.UriBuilder.queryParamIfPresent.

Delegates to either 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.

Parameters
name:String

the query parameter name

value:Optional<?>

an Optional, either empty or holding the query parameter value.

Annotations
@Override
queryParamsback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder queryParams(MultiValueMap<String, String> params)

Implements org.springframework.web.util.UriBuilder.queryParams.

Doc from org.springframework.web.util.UriBuilder.queryParams.

Add multiple query parameters and values.

Note

please, review the Javadoc of queryParam(String, Object...) for further notes on the treatment and encoding of individual query parameters.

Parameters
params:MultiValueMap<String, String>

the params

Annotations
@Override
replacePathback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder replacePath(String path)

Implements org.springframework.web.util.UriBuilder.replacePath.

Doc from org.springframework.web.util.UriBuilder.replacePath.

Override the current path.

Parameters
path:String

the URI path, or null for an empty path

Annotations
@Override
replaceQueryback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder replaceQuery(String query)

Implements org.springframework.web.util.UriBuilder.replaceQuery.

Doc from org.springframework.web.util.UriBuilder.replaceQuery.

Clear existing query parameters and then delegate to query(String).

Note

please, review the Javadoc of queryParam(String, Object...) for further notes on the treatment and encoding of individual query parameters.

Parameters
query:String

the query string; a null value removes all query parameters.

Annotations
@Override
replaceQueryParamback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder replaceQueryParam(String name, Object... values)

Implements org.springframework.web.util.UriBuilder.replaceQueryParam.

Doc from org.springframework.web.util.UriBuilder.replaceQueryParam.

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 queryParam(String, Object...) for further notes on the treatment and encoding of individual query parameters.

Parameters
name:String

the query parameter name

values:Object[]

the query parameter values

Annotations
@Override
replaceQueryParamback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder replaceQueryParam(String name, Collection<?> values)

Implements org.springframework.web.util.UriBuilder.replaceQueryParam.

Doc from org.springframework.web.util.UriBuilder.replaceQueryParam.

Variant of replaceQueryParam(String, Object...) with a Collection.

Note

please, review the Javadoc of queryParam(String, Object...) for further notes on the treatment and encoding of individual query parameters.

Parameters
name:String

the query parameter name

values:Collection<?>

the query parameter values

Annotations
@Override
replaceQueryParamsback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder replaceQueryParams(MultiValueMap<String, String> params)

Implements org.springframework.web.util.UriBuilder.replaceQueryParams.

Doc from org.springframework.web.util.UriBuilder.replaceQueryParams.

Set the query parameter values after removing all existing ones.

Note

please, review the Javadoc of queryParam(String, Object...) for further notes on the treatment and encoding of individual query parameters.

Parameters
params:MultiValueMap<String, String>

the query parameter name

Annotations
@Override
schemeback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder scheme(String scheme)

Implements org.springframework.web.util.UriBuilder.scheme.

Doc from org.springframework.web.util.UriBuilder.scheme.

Set the URI scheme which may contain URI template variables, and may also be null to clear the scheme of this builder.

Parameters
scheme:String

the URI scheme

Annotations
@Override
toUriStringback to summary
public String toUriString()

Implements org.springframework.web.util.UriBuilder.toUriString.

Doc from org.springframework.web.util.UriBuilder.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.

Annotations
@Override
userInfoback to summary
public DefaultUriBuilderFactory.DefaultUriBuilder userInfo(String userInfo)

Implements org.springframework.web.util.UriBuilder.userInfo.

Doc from org.springframework.web.util.UriBuilder.userInfo.

Set the URI user info which may contain URI template variables, and may also be null to clear the user info of this builder.

Parameters
userInfo:String

the URI user info

Annotations
@Override
org.springframework.web.util back to summary

public final Enum DefaultUriBuilderFactory.EncodingMode

extends Enum<DefaultUriBuilderFactory.EncodingMode>
Class Inheritance

Enum to represent multiple URI encoding strategies. The following are available:
See Also
setEncodingMode

Field Summary

Modifier and TypeField and Description
public static final DefaultUriBuilderFactory.EncodingMode
NONE

No encoding should be applied.

public static final DefaultUriBuilderFactory.EncodingMode
TEMPLATE_AND_VALUES

Pre-encode the URI template first, then strictly encode URI variables when expanded, with the following rules:

  • For the URI template replace only non-ASCII and illegal (within a given URI component type) characters with escaped octets.
  • For URI variables do the same and also replace characters with reserved meaning.
public static final DefaultUriBuilderFactory.EncodingMode
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.EncodingMode
VALUES_ONLY

Does not encode the URI template and instead applies strict encoding to URI variables via UriUtils#encodeUriVariables prior to expanding them into the template.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static DefaultUriBuilderFactory.EncodingMode
public static DefaultUriBuilderFactory.EncodingMode[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

NONEback to summary
public static final DefaultUriBuilderFactory.EncodingMode NONE

No encoding should be applied.

TEMPLATE_AND_VALUESback to summary
public static final DefaultUriBuilderFactory.EncodingMode TEMPLATE_AND_VALUES

Pre-encode the URI template first, then strictly encode URI variables when expanded, with the following rules:

  • For the URI template replace only non-ASCII and illegal (within a given URI component type) characters with escaped octets.
  • For URI variables do the same and also replace characters with reserved meaning.

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 by comparison is useful only if intentionally expanding URI variables with reserved characters.

Since
5.0.8
See Also
UriComponentsBuilder#encode()
URI_COMPONENTback to summary
public static final DefaultUriBuilderFactory.EncodingMode 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.

See Also
UriComponents#encode()
VALUES_ONLYback to summary
public static final DefaultUriBuilderFactory.EncodingMode VALUES_ONLY

Does not encode the URI template and instead applies strict encoding to URI variables via UriUtils#encodeUriVariables prior to expanding them into the template.

See Also
UriUtils#encodeUriVariables(Object...), UriUtils#encodeUriVariables(Map)

Constructor Detail

EncodingModeback to summary
private EncodingMode()

Method Detail

valueOfback to summary
public static DefaultUriBuilderFactory.EncodingMode valueOf(String name)
valuesback to summary
public static DefaultUriBuilderFactory.EncodingMode[] values()