Top Description Fields Constructors Methods
org.glassfish.tyrus.core.uri.internal

public Class UriTemplateParser

extends Object
Class Inheritance
Known Direct Subclasses
org.glassfish.tyrus.core.uri.internal.PathTemplate.PathTemplateParser
Imports
java.util.ArrayList, .HashMap, .HashSet, .List, .Map, .NoSuchElementException, .Set, java.util.regex.Matcher, .Pattern, .PatternSyntaxException

A URI template parser that parses JAX-RS specific URI templates.
Authors
Paul Sandoz, Gerard Davison (gerard.davison at oracle.com)

Field Summary

Modifier and TypeField and Description
pack-priv static final int[]
private final List<Integer>
private static final String[]
private int
private final StringBuffer
private final List<String>
private final Map<String, Pattern>
private final StringBuffer
private int
private final Pattern
private final StringBuffer
private static final Set<Character>
private int
private final String
private static final Pattern

Constructor Summary

AccessConstructor and Description
public
UriTemplateParser(final String
the template.
template
)

Parse a template.

Method Summary

Modifier and TypeMethod and Description
private char
protected String

Returns:

the encoded literal characters.
encodeLiteralCharacters
(final String
the literal characters
characters
)

Encode literal characters of a template.

public final List<Integer>

Returns:

the capturing group counts.
getGroupCounts
()

Get the capturing group counts for each template variable.

public final int[]

Returns:

the group indexes to capturing groups.
getGroupIndexes
()

Get the group indexes to capturing groups.

public final List<String>

Returns:

the list of template names.
getNames
()

Get the list of template names.

public final Map<String, Pattern>

Returns:

the map of template names to patterns.
getNameToPattern
()

Get the map of template names to patterns.

public final String

Returns:

the normalized template.
getNormalizedTemplate
()

Get the normalized template.

public final int

Returns:

the number of explicit regular expressions.
getNumberOfExplicitRegexes
()

Get the number of explicit regular expressions.

public final int

Returns:

the number of literal characters.
getNumberOfLiteralCharacters
()

Get the number of literal characters.

public final int

Returns:

the number of regular expressions groups
getNumberOfRegexGroups
()

Get the number of regular expression groups

public final Pattern

Returns:

the pattern.
getPattern
()

Get the pattern.

public final String

Returns:

the template.
getTemplate
()

Get the template.

private static String[]
private static Set<Character>
private void
private int
parseName(final CharacterIterator ci, int skipGroup)

private String
private void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EMPTY_INT_ARRAYback to summary
pack-priv static final int[] EMPTY_INT_ARRAY
groupCountsback to summary
private final List<Integer> groupCounts
HEX_TO_UPPERCASE_REGEXback to summary
private static final String[] HEX_TO_UPPERCASE_REGEX
literalCharactersback to summary
private int literalCharacters
literalCharactersBufferback to summary
private final StringBuffer literalCharactersBuffer
namesback to summary
private final List<String> names
nameToPatternback to summary
private final Map<String, Pattern> nameToPattern
normalizedTemplateback to summary
private final StringBuffer normalizedTemplate
numOfExplicitRegexesback to summary
private int numOfExplicitRegexes
patternback to summary
private final Pattern pattern
regexback to summary
private final StringBuffer regex
RESERVED_REGEX_CHARACTERSback to summary
private static final Set<Character> RESERVED_REGEX_CHARACTERS
skipGroupback to summary
private int skipGroup
templateback to summary
private final String template
TEMPLATE_VALUE_PATTERNback to summary
private static final Pattern TEMPLATE_VALUE_PATTERN

Constructor Detail

UriTemplateParserback to summary
public UriTemplateParser(final String template) throws IllegalArgumentException

Parse a template.

Parameters
template:String

the template.

Exceptions
IllegalArgumentException:
if the template is null, an empty string or does not conform to a JAX-RS URI template.

Method Detail

consumeWhiteSpaceback to summary
private char consumeWhiteSpace(final CharacterIterator ci)
encodeLiteralCharactersback to summary
protected String encodeLiteralCharacters(final String characters)

Encode literal characters of a template.

Parameters
characters:String

the literal characters

Returns:String

the encoded literal characters.

getGroupCountsback to summary
public final List<Integer> getGroupCounts()

Get the capturing group counts for each template variable.

Returns:List<Integer>

the capturing group counts.

getGroupIndexesback to summary
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:int[]

the group indexes to capturing groups.

getNamesback to summary
public final List<String> getNames()

Get the list of template names.

Returns:List<String>

the list of template names.

getNameToPatternback to summary
public final Map<String, Pattern> getNameToPattern()

Get the map of template names to patterns.

Returns:Map<String, Pattern>

the map of template names to patterns.

getNormalizedTemplateback to summary
public final String getNormalizedTemplate()

Get the normalized template.

A normalized template is a template without any explicit regular expressions.

Returns:String

the normalized template.

getNumberOfExplicitRegexesback to summary
public final int getNumberOfExplicitRegexes()

Get the number of explicit regular expressions.

Returns:int

the number of explicit regular expressions.

getNumberOfLiteralCharactersback to summary
public final int getNumberOfLiteralCharacters()

Get the number of literal characters.

Returns:int

the number of literal characters.

getNumberOfRegexGroupsback to summary
public final int getNumberOfRegexGroups()

Get the number of regular expression groups

Returns:int

the number of regular expressions groups

Since
2.9
getPatternback to summary
public final Pattern getPattern()

Get the pattern.

Returns:Pattern

the pattern.

getTemplateback to summary
public final String getTemplate()

Get the template.

Returns:String

the template.

initHexToUpperCaseRegexback to summary
private static String[] initHexToUpperCaseRegex()
initReservedback to summary
private static Set<Character> initReserved()
parseback to summary
private void parse(final CharacterIterator ci)
parseNameback to summary
private int parseName(final CharacterIterator ci, int skipGroup)
parseRegexback to summary
private String parseRegex(final CharacterIterator ci)
processLiteralCharactersback to summary
private void processLiteralCharacters()