public class UriTemplateParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) static int[] |
EMPTY_INT_ARRAY |
private java.util.List<java.lang.Integer> |
groupCounts |
private static java.lang.String[] |
HEX_TO_UPPERCASE_REGEX |
private int |
literalCharacters |
private java.lang.StringBuffer |
literalCharactersBuffer |
private java.util.List<java.lang.String> |
names |
private java.util.Map<java.lang.String,java.util.regex.Pattern> |
nameToPattern |
private java.lang.StringBuffer |
normalizedTemplate |
private int |
numOfExplicitRegexes |
private java.util.regex.Pattern |
pattern |
private java.lang.StringBuffer |
regex |
private static java.util.Set<java.lang.Character> |
RESERVED_REGEX_CHARACTERS |
private int |
skipGroup |
private java.lang.String |
template |
static java.util.regex.Pattern |
TEMPLATE_VALUE_PATTERN
Default URI template value regexp pattern.
|
Constructor and Description |
---|
UriTemplateParser(java.lang.String template)
Parse a template.
|
Modifier and Type | Method and Description |
---|---|
private char |
consumeWhiteSpace(CharacterIterator ci) |
protected java.lang.String |
encodeLiteralCharacters(java.lang.String characters)
Encode literal characters of a template.
|
java.util.List<java.lang.Integer> |
getGroupCounts()
Get the capturing group counts for each template variable.
|
int[] |
getGroupIndexes()
Get the group indexes to capturing groups.
|
java.util.List<java.lang.String> |
getNames()
Get the list of template names.
|
java.util.Map<java.lang.String,java.util.regex.Pattern> |
getNameToPattern()
Get the map of template names to patterns.
|
java.lang.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 groups
|
java.util.regex.Pattern |
getPattern()
Get the pattern.
|
java.lang.String |
getTemplate()
Get the template.
|
private static java.lang.String[] |
initHexToUpperCaseRegex() |
private static java.util.Set<java.lang.Character> |
initReserved() |
private void |
parse(CharacterIterator ci) |
private int |
parseName(CharacterIterator ci,
int skipGroup) |
private java.lang.String |
parseRegex(CharacterIterator ci) |
private void |
processLiteralCharacters() |
static final int[] EMPTY_INT_ARRAY
private static final java.util.Set<java.lang.Character> RESERVED_REGEX_CHARACTERS
private static final java.lang.String[] HEX_TO_UPPERCASE_REGEX
public static final java.util.regex.Pattern TEMPLATE_VALUE_PATTERN
private final java.lang.String template
private final java.lang.StringBuffer regex
private final java.lang.StringBuffer normalizedTemplate
private final java.lang.StringBuffer literalCharactersBuffer
private final java.util.regex.Pattern pattern
private final java.util.List<java.lang.String> names
private final java.util.List<java.lang.Integer> groupCounts
private final java.util.Map<java.lang.String,java.util.regex.Pattern> nameToPattern
private int numOfExplicitRegexes
private int skipGroup
private int literalCharacters
public UriTemplateParser(java.lang.String template) throws java.lang.IllegalArgumentException
template
- the template.java.lang.IllegalArgumentException
- if the template is null, an empty string
or does not conform to a JAX-RS URI template.private static java.util.Set<java.lang.Character> initReserved()
public final java.lang.String getTemplate()
public final java.util.regex.Pattern getPattern()
public final java.lang.String getNormalizedTemplate()
A normalized template is a template without any explicit regular expressions.
public final java.util.Map<java.lang.String,java.util.regex.Pattern> getNameToPattern()
public final java.util.List<java.lang.String> getNames()
public final java.util.List<java.lang.Integer> getGroupCounts()
public final int[] getGroupIndexes()
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.
public final int getNumberOfExplicitRegexes()
public final int getNumberOfRegexGroups()
public final int getNumberOfLiteralCharacters()
protected java.lang.String encodeLiteralCharacters(java.lang.String characters)
characters
- the literal charactersprivate void parse(CharacterIterator ci)
private void processLiteralCharacters()
private static java.lang.String[] initHexToUpperCaseRegex()
private int parseName(CharacterIterator ci, int skipGroup)
private java.lang.String parseRegex(CharacterIterator ci)
private char consumeWhiteSpace(CharacterIterator ci)