org.apache.cxf.jaxrs.model
Class URITemplate
java.lang.Object
org.apache.cxf.jaxrs.model.URITemplate
public final class URITemplate
- extends java.lang.Object
Constructor Summary |
URITemplate(java.lang.String theTemplate)
|
URITemplate(java.lang.String theTemplate,
boolean limited)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TEMPLATE_PARAMETERS
public static final java.lang.String TEMPLATE_PARAMETERS
- See Also:
- Constant Field Values
LIMITED_REGEX_SUFFIX
public static final java.lang.String LIMITED_REGEX_SUFFIX
- See Also:
- Constant Field Values
UNLIMITED_REGEX_SUFFIX
public static final java.lang.String UNLIMITED_REGEX_SUFFIX
- See Also:
- Constant Field Values
FINAL_MATCH_GROUP
public static final java.lang.String FINAL_MATCH_GROUP
- See Also:
- Constant Field Values
URITemplate
public URITemplate(java.lang.String theTemplate)
URITemplate
public URITemplate(java.lang.String theTemplate,
boolean limited)
getLiteralChars
public java.lang.String getLiteralChars()
getValue
public java.lang.String getValue()
getVariables
public java.util.List<java.lang.String> getVariables()
getCustomVariables
public java.util.List<java.lang.String> getCustomVariables()
match
public boolean match(java.lang.String uri,
javax.ws.rs.core.MultivaluedMap<java.lang.String,java.lang.String> templateVariableToValue)
substitute
public java.lang.String substitute(java.util.List<java.lang.String> values)
throws java.lang.IllegalArgumentException
- Substitutes template variables with listed values. List of values is counterpart for
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}".
- Parameters:
values
- values for variables
- Returns:
- template with bound variables.
- Throws:
java.lang.IllegalArgumentException
- when values is null, any value does not match pattern etc.
substitute
public java.lang.String substitute(java.util.Map<java.lang.String,? extends java.lang.Object> valuesMap)
throws java.lang.IllegalArgumentException
- Substitutes 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:
java.lang.IllegalArgumentException
- when size of list of values differs from list of variables or list
contains nulls.
encodeLiteralCharacters
public java.lang.String encodeLiteralCharacters()
- Encoded literal characters surrounding template variables,
ex. "a {id} b" will be encoded to "a%20{id}%20b"
- Returns:
- encoded value
createTemplate
public static URITemplate createTemplate(ClassResourceInfo cri,
javax.ws.rs.Path path)
compareTemplates
public static int compareTemplates(URITemplate t1,
URITemplate t2)
Apache CXF