Class UriPattern
java.lang.Object
org.exoplatform.services.rest.uri.UriPattern
- Version:
- $Id: $
- Author:
- Andrey Parfonov
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Comparator<UriPattern> Sort the templates according to the string comparison of the template regular expressions. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringcreateUriWithValues(String schema, String userInfo, String host, int port, String path, String query, String fragment, Object[] values, boolean encode) Create URI from URI part.static StringcreateUriWithValues(String schema, String userInfo, String host, int port, String path, String query, String fragment, Map<String, ? extends Object> values, boolean encode) Create URI from URI part.booleanintGet the number of literal characters in the template.Get the regex pattern.getRegex()Get the regular expression.Get the URI template as a String.inthashCode()booleanCheck is URI string match to pattern.toString()
-
Field Details
-
URIPATTERN_COMPARATOR
Sort the templates according to the string comparison of the template regular expressions.JSR-311 specification: "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"
-
-
Constructor Details
-
UriPattern
Constructs UriPattern.- Parameters:
template- the source template- See Also:
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
getPattern
Get the regex pattern.- Returns:
- the regex pattern
-
getTemplate
Get the URI template as a String.- Returns:
- the URI template
-
getRegex
Get the regular expression.- Returns:
- the regular expression
-
getNumberOfLiteralCharacters
public int getNumberOfLiteralCharacters()Get the number of literal characters in the template.- Returns:
- number of literal characters in the template
-
getParameterNames
- Returns:
- list of names
-
match
Check is URI string match to pattern. If it is then fill given list by parameter value. Before coping value list is cleared. List will be 1 greater then number of keys. It can be used for check is resource is matching to requested. If resource is match the last element in list must be '/' or null.- Parameters:
uri- the URI stringparameters- target list- Returns:
- true if URI string is match to pattern, false otherwise
-
toString
-
createUriWithValues
public static String createUriWithValues(String schema, String userInfo, String host, int port, String path, String query, String fragment, Map<String, ? extends Object> values, boolean encode) Create URI from URI part. Each URI part can contains templates.- Parameters:
schema- the schema URI partuserInfo- the user info URI parthost- the host name URI partport- the port number URI partpath- the path URI partquery- the query string URI partfragment- the fragment URI partvalues- the values which must be used instead templates parametersencode- if true then encode value before add it in URI, otherwise value must be validate to legal characters- Returns:
- the URI string
-
createUriWithValues
public static String createUriWithValues(String schema, String userInfo, String host, int port, String path, String query, String fragment, Object[] values, boolean encode) Create URI from URI part. Each URI part can contains templates.- Parameters:
schema- the schema URI partuserInfo- the user info URI parthost- the host name URI partport- the port number URI partpath- the path URI partquery- the query string URI partfragment- the fragment URI partvalues- the values which must be used instead templates parametersencode- if true then encode value before add it in URI, otherwise value must be validate to legal characters- Returns:
- the URI string
-