Class UriTemplateParser
- java.lang.Object
-
- org.glassfish.jersey.uri.internal.UriTemplateParser
-
public class UriTemplateParser extends Object
A URI template parser that parses JAX-RS specific URI templates.- Author:
- Paul Sandoz, Gerard Davison (gerard.davison at oracle.com)
-
-
Field Summary
Fields Modifier and Type Field Description static Pattern
MATCH_NUMBER_OF_MAX_LENGTH_4
static Pattern
TEMPLATE_VALUE_PATTERN
Default URI template value regexp pattern.static Pattern
TEMPLATE_VALUE_PATTERN_MULTI
-
Constructor Summary
Constructors Constructor Description UriTemplateParser(String template)
Parse a template.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected String
encodeLiteralCharacters(String characters)
Encode literal characters of a template.List<Integer>
getGroupCounts()
Get the capturing group counts for each template variable.int[]
getGroupIndexes()
Get the group indexes to capturing groups.List<UriPart>
getNames()
Get the list of template names.Map<String,Pattern>
getNameToPattern()
Get the map of template names to patterns.String
getNormalizedTemplate()
Get the normalized template.int
getNumberOfExplicitRegexes()
Get the number of explicit regular expressions.int
getNumberOfLiteralCharacters()
Get the number of literal characters.int
getNumberOfRegexGroups()
Get the number of regular expression groupsPattern
getPattern()
Get the pattern.String
getTemplate()
Get the template.List<UriPart>
getUriParts()
Get a collection of uri parts (static strings and dynamic arguments) as parsed by the parser.
-
-
-
Field Detail
-
TEMPLATE_VALUE_PATTERN
public static final Pattern TEMPLATE_VALUE_PATTERN
Default URI template value regexp pattern.
-
TEMPLATE_VALUE_PATTERN_MULTI
public static final Pattern TEMPLATE_VALUE_PATTERN_MULTI
-
MATCH_NUMBER_OF_MAX_LENGTH_4
public static final Pattern MATCH_NUMBER_OF_MAX_LENGTH_4
-
-
Constructor Detail
-
UriTemplateParser
public UriTemplateParser(String template) throws IllegalArgumentException
Parse a template.- Parameters:
template
- the template.- Throws:
IllegalArgumentException
- if the template is null, an empty string or does not conform to a JAX-RS URI template.
-
-
Method Detail
-
getTemplate
public final String getTemplate()
Get the template.- Returns:
- the template.
-
getPattern
public final Pattern getPattern()
Get the pattern.- Returns:
- the pattern.
-
getNormalizedTemplate
public final String getNormalizedTemplate()
Get the normalized template.A normalized template is a template without any explicit regular expressions.
- Returns:
- the normalized template.
-
getNameToPattern
public final Map<String,Pattern> getNameToPattern()
Get the map of template names to patterns.- Returns:
- the map of template names to patterns.
-
getNames
public final List<UriPart> getNames()
Get the list of template names.- Returns:
- the list of template names.
-
getUriParts
public List<UriPart> getUriParts()
Get a collection of uri parts (static strings and dynamic arguments) as parsed by the parser. Can be used to compose the uri. This collection is usually a superset ofnames
and other parts that do not have a template.- Returns:
- List of parts of the uri.
-
getGroupCounts
public final List<Integer> getGroupCounts()
Get the capturing group counts for each template variable.- Returns:
- the capturing group counts.
-
getGroupIndexes
public final int[] getGroupIndexes()
Get the group indexes to capturing groups.Any nested capturing groups will be ignored and the the group index will refer to the top-level capturing groups associated with the templates variables.
- Returns:
- the group indexes to capturing groups.
-
getNumberOfExplicitRegexes
public final int getNumberOfExplicitRegexes()
Get the number of explicit regular expressions.- Returns:
- the number of explicit regular expressions.
-
getNumberOfRegexGroups
public final int getNumberOfRegexGroups()
Get the number of regular expression groups- Returns:
- the number of regular expressions groups
- Since:
- 2.9
-
getNumberOfLiteralCharacters
public final int getNumberOfLiteralCharacters()
Get the number of literal characters.- Returns:
- the number of literal characters.
-
-