Spring Hateoas

org.springframework.hateoas
Class UriTemplate

java.lang.Object
  extended by org.springframework.hateoas.UriTemplate
All Implemented Interfaces:
Serializable, Iterable<TemplateVariable>

public class UriTemplate
extends Object
implements Iterable<TemplateVariable>, Serializable

Custom URI template to support qualified URI template variables.

Since:
0.9
Author:
Oliver Gierke
See Also:
http://tools.ietf.org/html/rfc6570, Serialized Form

Constructor Summary
UriTemplate(String template)
          Creates a new UriTemplate using the given template string.
UriTemplate(String baseUri, TemplateVariables variables)
          Creates a new UriTemplate from the given base URI and TemplateVariables.
 
Method Summary
 URI expand(Map<String,? extends Object> parameters)
          Expands the UriTemplate using the given parameters.
 URI expand(Object... parameters)
          Expands the UriTemplate using the given parameters.
 List<String> getVariableNames()
          Returns the names of the variables discovered.
 List<TemplateVariable> getVariables()
          Returns the TemplateVariables discovered.
static boolean isTemplate(String candidate)
          Returns whether the given candidate is a URI template.
 Iterator<TemplateVariable> iterator()
           
 String toString()
           
 UriTemplate with(TemplateVariables variables)
          Creates a new UriTemplate with the current TemplateVariables augmented with the given ones.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UriTemplate

public UriTemplate(String template)
Creates a new UriTemplate using the given template string.

Parameters:
template - must not be null or empty.

UriTemplate

public UriTemplate(String baseUri,
                   TemplateVariables variables)
Creates a new UriTemplate from the given base URI and TemplateVariables.

Parameters:
baseUri - must not be null or empty.
variables - defaults to TemplateVariables.NONE.
Method Detail

with

public UriTemplate with(TemplateVariables variables)
Creates a new UriTemplate with the current TemplateVariables augmented with the given ones.

Parameters:
variables - can be null.
Returns:

isTemplate

public static boolean isTemplate(String candidate)
Returns whether the given candidate is a URI template.

Parameters:
candidate -
Returns:

getVariables

public List<TemplateVariable> getVariables()
Returns the TemplateVariables discovered.

Returns:

getVariableNames

public List<String> getVariableNames()
Returns the names of the variables discovered.

Returns:

expand

public URI expand(Object... parameters)
Expands the UriTemplate using the given parameters. The values will be applied in the order of the variables discovered.

Parameters:
parameters -
Returns:
See Also:
expand(Map)

expand

public URI expand(Map<String,? extends Object> parameters)
Expands the UriTemplate using the given parameters.

Parameters:
parameters - must not be null.
Returns:

iterator

public Iterator<TemplateVariable> iterator()
Specified by:
iterator in interface Iterable<TemplateVariable>

toString

public String toString()
Overrides:
toString in class Object

Spring Hateoas

Copyright © 2012-2014–2014 Pivotal, Inc.. All rights reserved.