|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.ws.rest.api.uri.UriTemplate
public class UriTemplate
A URI template.
Field Summary | |
---|---|
static java.util.Comparator<UriTemplate> |
COMPARATOR
Order the templates according to the string comparison of the template regular expressions. |
static UriTemplate |
EMPTY
The empty URI template that matches the null or empty URI path |
Constructor Summary | |
---|---|
UriTemplate(java.lang.String template)
Construct a new URI template. |
Method Summary | |
---|---|
java.lang.String |
createURI(java.util.Map<java.lang.String,java.lang.String> values)
Create a URI by substituting any template variables for corresponding template values. |
java.lang.String |
createURI(java.lang.String... values)
Create a URI by substituting any template variables for corresponding template values. |
java.lang.String |
createURI(java.lang.String[] values,
int offset,
int length)
Create a URI by substituting any template variables for corresponding template values. |
static java.lang.String |
createURI(java.lang.String scheme,
java.lang.String userInfo,
java.lang.String host,
java.lang.String port,
java.lang.String path,
java.lang.String query,
java.lang.String fragment,
java.util.Map<java.lang.String,java.lang.Object> values,
boolean encode)
Construct a URI from the component parts each of which may contain template variables. |
static java.lang.String |
createURI(java.lang.String scheme,
java.lang.String userInfo,
java.lang.String host,
java.lang.String port,
java.lang.String path,
java.lang.String query,
java.lang.String fragment,
java.lang.Object[] values,
boolean encode)
Construct a URI from the component parts each of which may contain template variables. |
static java.lang.String |
createURIWithStringValues(java.lang.String scheme,
java.lang.String userInfo,
java.lang.String host,
java.lang.String port,
java.lang.String path,
java.lang.String query,
java.lang.String fragment,
java.util.Map<java.lang.String,java.lang.String> values,
boolean encode)
Construct a URI from the component parts each of which may contain template variables. |
static java.lang.String |
createURIWithStringValues(java.lang.String scheme,
java.lang.String userInfo,
java.lang.String host,
java.lang.String port,
java.lang.String path,
java.lang.String query,
java.lang.String fragment,
java.lang.String[] values,
boolean encode)
Construct a URI from the component parts each of which may contain template variables. |
boolean |
endsWithSlash()
Returns true if the template end in a '/' |
boolean |
equals(java.lang.Object o)
Equality is calculated from the String of the regular expression generated from the templates. |
int |
getNumberOfExplicitCharacters()
Get the number of characters in the regular expression not resulting from conversion of template variables. |
int |
getNumberOfPathSegments()
Get the number of path segments in the template. |
int |
getNumberOfTemplateVariables()
Get the number of template variables. |
int |
getPathSegmentIndex(java.lang.String variable)
Get the path segment index of a path segment that contains a template variable. |
UriPattern |
getPattern()
Get the URI pattern. |
java.lang.String |
getTemplate()
Get the URI template as a String. |
java.util.List<java.lang.String> |
getTemplateVariables()
Get the list of template variables for the template. |
int |
hashCode()
Hashcode is calculated from String of the regular expression generated from the template. |
boolean |
isTemplateVariablePresent(java.lang.String name)
Ascertain if a template variable is a member of this template. |
boolean |
match(java.lang.CharSequence uri,
java.util.List<java.lang.String> groupValues)
Match a URI against the template. |
boolean |
match(java.lang.CharSequence uri,
java.util.Map<java.lang.String,java.lang.String> templateVariableToValue)
Match a URI against the template. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.util.Comparator<UriTemplate> COMPARATOR
The JSR-311 specification states: "Sort the set of matching resource classes using the number of characters in the regular expression not resulting from template variables as the primary key and the number of matching groups as a secondary key"
public static final UriTemplate EMPTY
Constructor Detail |
---|
public UriTemplate(java.lang.String template)
The template will be parsed to extract template variables.
A specific regular expression will be generated from the template to match URIs according to the template and map template variables to template values.
template
- the template.
{@link
- java.util.regex.PatternSyntaxException} if the specific
regular expression could not be generated
{@link
- IllegalArgumentException} if the template is null or
an empty string.Method Detail |
---|
public final java.lang.String getTemplate()
public final UriPattern getPattern()
public final boolean endsWithSlash()
public final java.util.List<java.lang.String> getTemplateVariables()
public final boolean isTemplateVariablePresent(java.lang.String name)
name
- name The template variable.
public final int getNumberOfExplicitCharacters()
public final int getNumberOfTemplateVariables()
public final int getNumberOfPathSegments()
public final int getPathSegmentIndex(java.lang.String variable)
variable
- the template variable
public final boolean match(java.lang.CharSequence uri, java.util.Map<java.lang.String,java.lang.String> templateVariableToValue)
If the URI matches against the pattern then the template variable to value map will be filled with template variables as keys and template values as values.
uri
- the uri to match against the template.templateVariableToValue
- the map where to put template variables (as keys)
and template values (as values). The map is cleared before any
entries are put.
{@link
- IllegalArgumentException} if the uri or
templateVariableToValue is null.public final boolean match(java.lang.CharSequence uri, java.util.List<java.lang.String> groupValues)
If the URI matches against the pattern then the template variable to value map will be filled with template variables as keys and template values as values.
uri
- the uri to match against the template.groupValues
- the list to store the values of a pattern's
capturing groups is matching is successful. The values are stored
in the same order as the pattern's capturing groups.
{@link
- IllegalArgumentException} if the uri or
templateVariableToValue is null.public final java.lang.String createURI(java.util.Map<java.lang.String,java.lang.String> values)
A URI template variable without a value will be substituted by the empty string.
values
- the map of template variables to template values.
public final java.lang.String createURI(java.lang.String... values)
A URI template varibale without a value will be substituted by the empty string.
values
- the array of template values. The values will be
substituted in order of occurence of unique template variables.
public final java.lang.String createURI(java.lang.String[] values, int offset, int length)
A URI template variable without a value will be substituted by the empty string.
values
- the array of template values. The values will be
substituted in order of occurence of unique template variables.offset
- the offset into the arraylength
- the length of the array
public final java.lang.String toString()
toString
in class java.lang.Object
public final int hashCode()
hashCode
in class java.lang.Object
public final boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public static final java.lang.String createURI(java.lang.String scheme, java.lang.String userInfo, java.lang.String host, java.lang.String port, java.lang.String path, java.lang.String query, java.lang.String fragment, java.util.Map<java.lang.String,java.lang.Object> values, boolean encode)
A template values is an Object instance MUST support the toString() method to convert the template value to a String instance.
scheme
- the URI scheme componentuserInfo
- the URI user info componenthost
- the URI host componentport
- the URI port componentpath
- the URI path componentquery
- the URI query componnetfragment
- the URI fragment componentvalues
- the template variable to value mapencode
- if true encode a template value according to the correspond
component type of the associated template variable, otherwise
validate the template value
public static final java.lang.String createURIWithStringValues(java.lang.String scheme, java.lang.String userInfo, java.lang.String host, java.lang.String port, java.lang.String path, java.lang.String query, java.lang.String fragment, java.util.Map<java.lang.String,java.lang.String> values, boolean encode)
scheme
- the URI scheme componentuserInfo
- the URI user info componenthost
- the URI host componentport
- the URI port componentpath
- the URI path componentquery
- the URI query componnetfragment
- the URI fragment componentvalues
- the template variable to value mapencode
- if true encode a template value according to the correspond
component type of the associated template variable, otherwise
validate the template value
public static final java.lang.String createURI(java.lang.String scheme, java.lang.String userInfo, java.lang.String host, java.lang.String port, java.lang.String path, java.lang.String query, java.lang.String fragment, java.lang.Object[] values, boolean encode)
The template values are an array of Object and each Object instance MUST support the toString() method to convert the template value to a String instance.
scheme
- the URI scheme componentuserInfo
- the URI user info componenthost
- the URI host componentport
- the URI port componentpath
- the URI path componentquery
- the URI query componnetfragment
- the URI fragment componentvalues
- the array of template valuesencode
- if true encode a template value according to the correspond
component type of the associated template variable, otherwise
validate the template value
public static final java.lang.String createURIWithStringValues(java.lang.String scheme, java.lang.String userInfo, java.lang.String host, java.lang.String port, java.lang.String path, java.lang.String query, java.lang.String fragment, java.lang.String[] values, boolean encode)
scheme
- the URI scheme componentuserInfo
- the URI user info componenthost
- the URI host componentport
- the URI port componentpath
- the URI path componentquery
- the URI query componnetfragment
- the URI fragment componentvalues
- the array of template valuesencode
- if true encode a template value according to the correspond
component type of the associated template variable, otherwise
validate the template value
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |