Package org.springframework.web.util
Class DefaultUriBuilderFactory
java.lang.Object
org.springframework.web.util.DefaultUriBuilderFactory
- All Implemented Interfaces:
- UriBuilderFactory,- UriTemplateHandler
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.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic enumEnum to represent multiple URI encoding strategies.
- 
Constructor SummaryConstructorsConstructorDescriptionDefault constructor without a base URI.DefaultUriBuilderFactory(String baseUriTemplate) Constructor with a base URI.Variant ofDefaultUriBuilderFactory(String)with aUriComponentsBuilder.
- 
Method SummaryModifier and TypeMethodDescriptionbuilder()Create a URI builder with default settings.Expand the given URI template with an array of URI variables.Expand the given URI template with a map of URI variables.Return the configured default URI variable values.Return the configured encoding mode.final booleanDetermine whether this factory has been configured with a base URI.voidsetDefaultUriVariables(Map<String, ?> defaultUriVariables) Provide default URI variable values to use when expanding URI templates with a Map of variables.voidsetEncodingMode(DefaultUriBuilderFactory.EncodingMode encodingMode) Set theencoding modeto use.voidsetParsePath(boolean parsePath) Whether to parse the input path into path segments if the encoding mode is set toEncodingMode.URI_COMPONENT, which ensures that URI variables in the path are encoded according to path segment rules and for example a '/' is encoded.booleanWhether to parse the path into path segments if the encoding mode is set toEncodingMode.URI_COMPONENT.Initialize a builder with the given URI template.
- 
Constructor Details- 
DefaultUriBuilderFactorypublic DefaultUriBuilderFactory()Default constructor without a base URI.The target address must be specified on each UriBuilder. 
- 
DefaultUriBuilderFactoryConstructor with a base URI.The given URI template is parsed via UriComponentsBuilder.fromUriString(java.lang.String)and then applied as a base URI to every UriBuilder viaUriComponentsBuilder.uriComponents(org.springframework.web.util.UriComponents)unless the UriBuilder itself was created with a URI template that already has a target address.- Parameters:
- baseUriTemplate- the URI template to use a base URL
 
- 
DefaultUriBuilderFactoryVariant ofDefaultUriBuilderFactory(String)with aUriComponentsBuilder.
 
- 
- 
Method Details- 
hasBaseUripublic final boolean hasBaseUri()Determine whether this factory has been configured with a base URI.- Since:
- 6.1.4
- See Also:
 
- 
setEncodingModeSet theencoding modeto use.By default this is set to EncodingMode.TEMPLATE_AND_VALUES.Note: Prior to 5.1 the default was EncodingMode.URI_COMPONENTtherefore theWebClientRestTemplatehave switched their default behavior.- Parameters:
- encodingMode- the encoding mode to use
 
- 
getEncodingModeReturn the configured encoding mode.
- 
setDefaultUriVariablesProvide default URI variable values to use when expanding URI templates with a Map of variables.- Parameters:
- defaultUriVariables- default URI variable values
 
- 
getDefaultUriVariablesReturn the configured default URI variable values.
- 
setParsePathpublic void setParsePath(boolean parsePath) Whether to parse the input path into path segments if the encoding mode is set toEncodingMode.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- whether to parse the path into path segments
 
- 
shouldParsePathpublic boolean shouldParsePath()Whether to parse the path into path segments if the encoding mode is set toEncodingMode.URI_COMPONENT.
- 
expandDescription copied from interface:UriTemplateHandlerExpand the given URI template with a map of URI variables.- Specified by:
- expandin interface- UriTemplateHandler
- Parameters:
- uriTemplate- the URI template
- uriVars- variable values
- Returns:
- the created URI instance
 
- 
expandDescription copied from interface:UriTemplateHandlerExpand the given URI template with an array of URI variables.- Specified by:
- expandin interface- UriTemplateHandler
- Parameters:
- uriTemplate- the URI template
- uriVars- variable values
- Returns:
- the created URI instance
 
- 
uriStringDescription copied from interface:UriBuilderFactoryInitialize a builder with the given URI template.- Specified by:
- uriStringin interface- UriBuilderFactory
- Parameters:
- uriTemplate- the URI template to use
- Returns:
- the builder instance
 
- 
builderDescription copied from interface:UriBuilderFactoryCreate a URI builder with default settings.- Specified by:
- builderin interface- UriBuilderFactory
- Returns:
- the builder instance
 
 
-