public class DefaultUriTemplateHandler extends Object implements UriTemplateHandler
UriTemplateHandler
that relies on
UriComponentsBuilder
internally.Constructor and Description |
---|
DefaultUriTemplateHandler() |
Modifier and Type | Method and Description |
---|---|
URI |
expand(String uriTemplate,
Map<String,?> uriVariables)
Expand the give URI template with a map of URI variables.
|
URI |
expand(String uriTemplate,
Object... uriVariableValues)
Expand the give URI template with an array of URI variable values.
|
String |
getBaseUrl()
Return the configured base URL.
|
protected UriComponentsBuilder |
initUriComponentsBuilder(String uriTemplate) |
protected URI |
insertBaseUrl(UriComponents uriComponents) |
void |
setBaseUrl(String baseUrl)
Configure a base URL to prepend URI templates with.
|
void |
setParsePath(boolean parsePath)
Whether to parse the path of a URI template string into path segments.
|
boolean |
shouldParsePath()
Whether the handler is configured to parse the path into path segments.
|
public void setBaseUrl(String baseUrl)
Note: Individual URI templates are expanded and
encoded before being appended to the base URL. Therefore the base URL is
expected to be fully expanded and encoded, which can be done with the help
of UriComponentsBuilder
.
baseUrl
- the base URL.public String getBaseUrl()
public void setParsePath(boolean parsePath)
If set to true
the path of parsed URI templates is decomposed
into path segments so that URI variables expanded into the path are
treated according to path segment encoding rules. In effect that means the
"/" character is percent encoded.
By default this is set to false
in which case the path is kept
as a full path and expanded URI variables will preserve "/" characters.
parsePath
- whether to parse the path into path segmentspublic boolean shouldParsePath()
public URI expand(String uriTemplate, Map<String,?> uriVariables)
UriTemplateHandler
expand
in interface UriTemplateHandler
uriTemplate
- the URI template stringuriVariables
- the URI variablespublic URI expand(String uriTemplate, Object... uriVariableValues)
UriTemplateHandler
expand
in interface UriTemplateHandler
uriTemplate
- the URI template stringuriVariableValues
- the URI variable valuesprotected UriComponentsBuilder initUriComponentsBuilder(String uriTemplate)
protected URI insertBaseUrl(UriComponents uriComponents)