Class UriTemplate

  • All Implemented Interfaces:
    Serializable

    public class UriTemplate
    extends Object
    implements Serializable

    This is the primary class for creating and manipulating URI templates. This project implements RFC6570 URI Templates and produces output that is compliant with the spec. The template processor supports levels 1 through 4. In addition to supporting Map and List values as composite types, the library also supports the use of Java objects as well. Please see the VarExploder and DefaultVarExploder for more info.

    Basic Usage:

    There are many ways to use this library. The simplest way is to create a template from a URI template string:

     UriTemplate template = UriTemplate.fromTemplate("http://example.com/search{?q,lang}");
     

    Replacement values are added by calling the set(String, Object) method on the template:

     template.set("q","cat")
             .set("lang","en");
     String uri = template.expand();
     

    The expand() method will replace the variable names with the supplied values and return the following URI:

     http://example.com/search?q=cat&apm;lang=en
     
    Since:
    1.0
    Version:
    $Revision: 1.1 $
    Author:
    Ryan J. McDonough
    See Also:
    Serialized Form