public final class URITemplate extends Object
Modifier and Type | Field and Description |
---|---|
static String |
FINAL_MATCH_GROUP |
static String |
LIMITED_REGEX_SUFFIX |
static String |
TEMPLATE_PARAMETERS |
static String |
URI_TEMPLATE |
Constructor and Description |
---|
URITemplate(String theTemplate) |
Modifier and Type | Method and Description |
---|---|
static int |
compareTemplates(URITemplate t1,
URITemplate t2) |
static URITemplate |
createExactTemplate(String pathValue) |
static URITemplate |
createTemplate(javax.ws.rs.Path path) |
static URITemplate |
createTemplate(String pathValue) |
String |
encodeLiteralCharacters(boolean isQuery)
Encoded literal characters surrounding template variables,
ex.
|
List<String> |
getCustomVariables()
List of variables with patterns (regexps).
|
String |
getLiteralChars() |
String |
getPatternValue() |
String |
getValue() |
List<String> |
getVariables()
List of all variables in order of appearance in template.
|
boolean |
match(String uri,
javax.ws.rs.core.MultivaluedMap<String,String> templateVariableToValue) |
String |
substitute(List<String> values)
Substitutes template variables with listed values.
|
String |
substitute(Map<String,? extends Object> valuesMap,
Set<String> encodePathSlashVars,
boolean allowUnresolved)
Substitutes template variables with mapped values.
|
public static final String TEMPLATE_PARAMETERS
public static final String URI_TEMPLATE
public static final String LIMITED_REGEX_SUFFIX
public static final String FINAL_MATCH_GROUP
public URITemplate(String theTemplate)
public String getLiteralChars()
public String getValue()
public String getPatternValue()
public List<String> getVariables()
public List<String> getCustomVariables()
getVariables()
.public boolean match(String uri, javax.ws.rs.core.MultivaluedMap<String,String> templateVariableToValue)
public String substitute(List<String> values) throws IllegalArgumentException
list of variables
. When list of value is shorter than variables substitution
is partial. When variable has pattern, value must fit to pattern, otherwise
IllegalArgumentException
is thrown.
Example1: for template "/{a}/{b}/{a}" getVariables()
returns "[a, b, a]"; providing here list
of value "[foo, bar, baz]" results with "/foo/bar/baz".
Example2: for template "/{a}/{b}/{a}" providing list of values "[foo]" results with "/foo/{b}/{a}".
values
- values for variablesIllegalArgumentException
- when values is null, any value does not match pattern etc.public String substitute(Map<String,? extends Object> valuesMap, Set<String> encodePathSlashVars, boolean allowUnresolved) throws IllegalArgumentException
Example: for template "/{a}/{b}/{a}" getVariables()
returns "[a, b, a]"; providing here
mapping "[a: foo, b: bar]" results with "/foo/bar/foo" (full substitution) and for mapping "[b: baz]"
result is "{a}/baz/{a}" (partial substitution).
valuesMap
- map variables to their values; on each value Object.toString() is called.IllegalArgumentException
public String encodeLiteralCharacters(boolean isQuery)
public static URITemplate createTemplate(javax.ws.rs.Path path)
public static URITemplate createTemplate(String pathValue)
public static URITemplate createExactTemplate(String pathValue)
public static int compareTemplates(URITemplate t1, URITemplate t2)
Apache CXF