URI Templates

A Java implementation of  Draft 3 of URI Templates.

URI Templates

URI Templates can be expanded using variable substitution to produce valid URIs

For example, the URI

    http://tyenki.com/{foo}/{bar}

Given foo=test  and bar=home  will expand to become

    http://tyenki.com/test/home

The current version uses operators defined in the draft as well as shorter operators :

    http://tyenki.com/document/{+path}
    http://tyenki.com/tree/branch{;filter,author}/{leaf}
    http://tyenki.com/path{/tokens}
    http://tyenki.com/search{?term,show,page}

Given path=Cafés/Machiattofilter=recentterm=café, tokens=[123,abc] will expand as:

    http://tyenki.com/document/Cafés/Machiatto
    http://tyenki.com/tree/branch;filter=recent/leaf
    http://tyenki.com/path/123/abc
    http://tyenki.com/search?term=Caf%E2&show=20

For more details on the detail of how the operators work, see:

URI Patterns

The URI templates can be used as URI patterns as well, two operations are performed:

  1. Template matching (based on the longest static string, then on the longuest dynamic string)
  2. Variable resolution (variable are assigned values from the matching URI)

 

Code and documentation

Code (source and binaries) can be found here:

http://tyenki.com/project/uri/templates/release/

Java documentation is here:

http://tyenki.com/project/uri/templates/doc/

Released under the Artistic Licence 2.0