Package org.apache.cxf.jaxrs.model
Class URITemplate
java.lang.Object
org.apache.cxf.jaxrs.model.URITemplate
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic intcompareTemplates(URITemplate t1, URITemplate t2) static URITemplatecreateExactTemplate(String pathValue) static URITemplatecreateTemplate(jakarta.ws.rs.Path path) static URITemplatecreateTemplate(String pathValue) encodeLiteralCharacters(boolean isQuery) Encoded literal characters surrounding template variables, ex.List of variables with patterns (regexps).getValue()List of all variables in order of appearance in template.booleansubstitute(List<String> values) Substitutes template variables with listed values.substitute(Map<String, ? extends Object> valuesMap, Set<String> encodePathSlashVars, boolean allowUnresolved) Substitutes template variables with mapped values.
-
Field Details
-
TEMPLATE_PARAMETERS
- See Also:
-
URI_TEMPLATE
- See Also:
-
LIMITED_REGEX_SUFFIX
- See Also:
-
FINAL_MATCH_GROUP
- See Also:
-
-
Constructor Details
-
URITemplate
-
-
Method Details
-
getLiteralChars
-
getValue
-
getPatternValue
-
getVariables
List of all variables in order of appearance in template.- Returns:
- unmodifiable list of variable names w/o patterns, e.g. for "/foo/{v1:\\d}/{v2}" returned list is ["v1","v2"].
-
getCustomVariables
List of variables with patterns (regexps). List is subset of elements fromgetVariables().- Returns:
- unmodifiable list of variables names w/o patterns.
-
match
-
substitute
Substitutes template variables with listed values. List of values is counterpart forlist of variables. When list of value is shorter than variables substitution is partial. When variable has pattern, value must fit to pattern, otherwiseIllegalArgumentExceptionis 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}".
- Parameters:
values- values for variables- Returns:
- template with bound variables.
- Throws:
IllegalArgumentException- when values is null, any value does not match pattern etc.
-
substitute
public String substitute(Map<String, ? extends Object> valuesMap, Set<String> encodePathSlashVars, boolean allowUnresolved) throws IllegalArgumentExceptionSubstitutes template variables with mapped values. Variables are mapped to values; if not all variables are bound result will still contain variables. Note that all variables with the same name are replaced by one value.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).- Parameters:
valuesMap- map variables to their values; on each value Object.toString() is called.- Returns:
- template with bound variables.
- Throws:
IllegalArgumentException
-
encodeLiteralCharacters
Encoded literal characters surrounding template variables, ex. "a {id} b" will be encoded to "a%20{id}%20b"- Returns:
- encoded value
-
createTemplate
-
createTemplate
-
createExactTemplate
-
compareTemplates
-