| java.lang.Object | |
| ↳ | org.springframework.web.util.UriTemplate |
Represents a URI template. A URI template is a URI-like String that contains variables enclosed
by braces ({, }), which can be expanded to produce an actual URI.
See expand(Map), expand(Object[]), and match(String) for example usages.
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Construct a new
UriTemplate with the given URI String. | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Given an array of variables, expand this template into a full URI.
| |||||||||||
Given the Map of variables, expands this template into a URI.
| |||||||||||
Return the names of the variables in the template, in order.
| |||||||||||
Match the given URI to a map of variable values.
| |||||||||||
Indicate whether the given URI matches this template.
| |||||||||||
| Protected Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Encodes the given String as URL.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
Construct a new UriTemplate with the given URI String.
| uriTemplate | the URI template string |
|---|
Given an array of variables, expand this template into a full URI. The array represent variable values. The order of variables is significant.
Example:
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
System.out.println(template.expand("1", "42));
will print: http://example.com/hotels/1/bookings/42| uriVariableValues | the array of URI variables |
|---|
| IllegalArgumentException | if uriVariables is null
or if it does not contain sufficient variables
|
|---|
Given the Map of variables, expands this template into a URI. The Map keys represent variable names, the Map values variable values. The order of variables is not significant.
Example:
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
Map<String, String> uriVariables = new HashMap<String, String>();
uriVariables.put("booking", "42");
uriVariables.put("hotel", "1");
System.out.println(template.expand(uriVariables));
will print: http://example.com/hotels/1/bookings/42| uriVariables | the map of URI variables |
|---|
| IllegalArgumentException | if uriVariables is null;
or if it does not contain values for all the variable names
|
|---|
Return the names of the variables in the template, in order.
Match the given URI to a map of variable values. Keys in the returned map are variable names, values are variable values, as occurred in the given URI.
Example:
UriTemplate template = new UriTemplate("http://example.com/hotels/{hotel}/bookings/{booking}");
System.out.println(template.match("http://example.com/hotels/1/bookings/42"));
will print: {hotel=1, booking=42}| uri | the URI to match to |
|---|
Indicate whether the given URI matches this template.
| uri | the URI to match to |
|---|
true if it matches; false otherwise
Encodes the given String as URL.
Defaults to encodeUri(String, String).
| uri | the URI to encode |
|---|