public class CompiledTemplate<T> extends Object
A CompiledTemplate is a compiled URI template that can match against a path and bind variables.
Complications arise because CompiledTemplates are used in two ways. One is to match a URI path template against the path of a request URI, binding variables as necessary; this is part of the endpoint selection login. Then these is the additional possibility of the template also having query parameter which may also bind variables. The matching of the actual query parameters against the template query parameters is done separately, with variable values matching anything including / -- as opposed to anything except /, used to match path elements.
The query template matchers are rebuilt on each call rather than being compiled with the main matcher, but only because a first attempt at doing this produced a recursive loop and stack overflow.
The uri template cannot (easily) be treated as a single pattern because the order of the query parameters is irrelevant; so if A and B are submatches we'd have something like AB|BA and that's not dealing with any other -- unclaimed -- query parameters.
An ill-formed variable binding, ie an { or } not part of {NAME}, is reported by prepare as a SyntaxError exception.
| Modifier and Type | Class and Description |
|---|---|
static class |
CompiledTemplate.SyntaxError |
protected static class |
CompiledTemplate.VarGroupIndex
A VarGroupIndex associates a {} variable from a URI template
with its group index in the regular expression that matches the
template.
|
| Modifier and Type | Field and Description |
|---|---|
static Comparator<CompiledTemplate<?>> |
compare
A MatchTemplate comparator for use in sorting.
|
| Modifier | Constructor and Description |
|---|---|
protected |
CompiledTemplate(int literals,
int patterns,
String template,
Pattern compiled,
Map<String,String> uriParamBindings,
List<CompiledTemplate.VarGroupIndex> where,
T value) |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(CompiledTemplate<?> other)
Compare this MatchTemplate with another.
|
boolean |
match(Map<String,String> bindings,
String uri,
javax.ws.rs.core.MultivaluedMap<String,String> queryParams)
Match the given uri string.
|
static <T> CompiledTemplate<T> |
prepare(String template,
T value)
Answer a MatchTemplate corresponding to the template string.
|
String |
template()
Answer the URI template string from which this MatchTemplate was
constructed.
|
String |
toString() |
T |
value()
Answer the associated value for this template.
|
public static Comparator<CompiledTemplate<?>> compare
public int compareTo(CompiledTemplate<?> other)
public String template()
public T value()
public static <T> CompiledTemplate<T> prepare(String template, T value)
public boolean match(Map<String,String> bindings, String uri, javax.ws.rs.core.MultivaluedMap<String,String> queryParams)
queryParams - Copyright © 2017. All rights reserved.