Class UriTemplateParser
- java.lang.Object
-
- org.glassfish.jersey.uri.internal.UriTemplateParser
-
- Direct Known Subclasses:
PathTemplate.PathTemplateParser
public class UriTemplateParser extends java.lang.Object
A URI template parser that parses JAX-RS specific URI templates.
-
-
Field Summary
Fields Modifier and Type Field 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 Summary
Constructors Constructor Description UriTemplateParser(java.lang.String template)
Parse a template.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 groupsjava.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()
-
-
-
Field Detail
-
EMPTY_INT_ARRAY
static final int[] EMPTY_INT_ARRAY
-
RESERVED_REGEX_CHARACTERS
private static final java.util.Set<java.lang.Character> RESERVED_REGEX_CHARACTERS
-
HEX_TO_UPPERCASE_REGEX
private static final java.lang.String[] HEX_TO_UPPERCASE_REGEX
-
TEMPLATE_VALUE_PATTERN
public static final java.util.regex.Pattern TEMPLATE_VALUE_PATTERN
Default URI template value regexp pattern.
-
template
private final java.lang.String template
-
regex
private final java.lang.StringBuffer regex
-
normalizedTemplate
private final java.lang.StringBuffer normalizedTemplate
-
literalCharactersBuffer
private final java.lang.StringBuffer literalCharactersBuffer
-
pattern
private final java.util.regex.Pattern pattern
-
names
private final java.util.List<java.lang.String> names
-
groupCounts
private final java.util.List<java.lang.Integer> groupCounts
-
nameToPattern
private final java.util.Map<java.lang.String,java.util.regex.Pattern> nameToPattern
-
numOfExplicitRegexes
private int numOfExplicitRegexes
-
skipGroup
private int skipGroup
-
literalCharacters
private int literalCharacters
-
-
Constructor Detail
-
UriTemplateParser
public UriTemplateParser(java.lang.String template) throws java.lang.IllegalArgumentException
Parse a template.- Parameters:
template
- the template.- Throws:
java.lang.IllegalArgumentException
- if the template is null, an empty string or does not conform to a JAX-RS URI template.
-
-
Method Detail
-
initReserved
private static java.util.Set<java.lang.Character> initReserved()
-
getTemplate
public final java.lang.String getTemplate()
Get the template.- Returns:
- the template.
-
getPattern
public final java.util.regex.Pattern getPattern()
Get the pattern.- Returns:
- the pattern.
-
getNormalizedTemplate
public final java.lang.String getNormalizedTemplate()
Get the normalized template.A normalized template is a template without any explicit regular expressions.
- Returns:
- the normalized template.
-
getNameToPattern
public final java.util.Map<java.lang.String,java.util.regex.Pattern> getNameToPattern()
Get the map of template names to patterns.- Returns:
- the map of template names to patterns.
-
getNames
public final java.util.List<java.lang.String> getNames()
Get the list of template names.- Returns:
- the list of template names.
-
getGroupCounts
public final java.util.List<java.lang.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.
-
encodeLiteralCharacters
protected java.lang.String encodeLiteralCharacters(java.lang.String characters)
Encode literal characters of a template.- Parameters:
characters
- the literal characters- Returns:
- the encoded literal characters.
-
parse
private void parse(CharacterIterator ci)
-
processLiteralCharacters
private void processLiteralCharacters()
-
initHexToUpperCaseRegex
private static java.lang.String[] initHexToUpperCaseRegex()
-
parseName
private int parseName(CharacterIterator ci, int skipGroup)
-
parseRegex
private java.lang.String parseRegex(CharacterIterator ci)
-
consumeWhiteSpace
private char consumeWhiteSpace(CharacterIterator ci)
-
-