|
Spring for Android | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.web.util.UriTemplate
public class 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.
Constructor Summary | |
---|---|
UriTemplate(java.lang.String uriTemplate)
Construct a new UriTemplate with the given URI String. |
Method Summary | |
---|---|
protected java.net.URI |
encodeUri(java.lang.String uri)
Deprecated. No longer in use, with no direct replacement |
java.net.URI |
expand(java.util.Map<java.lang.String,?> uriVariables)
Given the Map of variables, expands this template into a URI. |
java.net.URI |
expand(java.lang.Object... uriVariableValues)
Given an array of variables, expand this template into a full URI. |
java.util.List<java.lang.String> |
getVariableNames()
Return the names of the variables in the template, in order. |
java.util.Map<java.lang.String,java.lang.String> |
match(java.lang.String uri)
Match the given URI to a map of variable values. |
boolean |
matches(java.lang.String uri)
Indicate whether the given URI matches this template. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public UriTemplate(java.lang.String uriTemplate)
UriTemplate
with the given URI String.
uriTemplate
- the URI template stringMethod Detail |
---|
public java.util.List<java.lang.String> getVariableNames()
public java.net.URI expand(java.util.Map<java.lang.String,?> uriVariables)
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
java.lang.IllegalArgumentException
- if uriVariables
is null
;
or if it does not contain values for all the variable namespublic java.net.URI expand(java.lang.Object... uriVariableValues)
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
java.lang.IllegalArgumentException
- if uriVariables
is null
or if it does not contain sufficient variablespublic boolean matches(java.lang.String uri)
uri
- the URI to match to
true
if it matches; false
otherwisepublic java.util.Map<java.lang.String,java.lang.String> match(java.lang.String 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
@Deprecated protected java.net.URI encodeUri(java.lang.String uri)
Defaults to UriUtils.encodeUri(String, String)
.
uri
- the URI to encode
public java.lang.String toString()
toString
in class java.lang.Object
|
Spring for Android | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |