Class UriMatchTemplate
java.lang.Object
io.micronaut.http.uri.UriTemplate
io.micronaut.http.uri.UriMatchTemplate
- All Implemented Interfaces:
UriMatcher, Comparable<UriTemplate>
- Direct Known Subclasses:
UriTypeMatchTemplate
Extends
UriTemplate and adds the ability to match a URI to a given template using the
UriMatcher.match(java.net.URI) method.- Since:
- 1.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classThe defaultUriMatchInfoimplementation.protected static classExtended version ofUriTemplate.UriTemplateParserthat builds a regular expression to match a path.Nested classes/interfaces inherited from class UriTemplate
UriTemplate.PathSegment, UriTemplate.UriTemplateParser -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringBuilderprotected static final Stringprotected List<UriMatchVariable> Fields inherited from class UriTemplate
templateString -
Constructor Summary
ConstructorsModifierConstructorDescriptionUriMatchTemplate(CharSequence templateString) Construct a new URI template for the given template.protectedUriMatchTemplate(CharSequence templateString, Object... parserArguments) Construct a new URI template for the given template.protectedUriMatchTemplate(CharSequence templateString, List<UriTemplate.PathSegment> segments, Pattern matchPattern, List<UriMatchVariable> variables) -
Method Summary
Modifier and TypeMethodDescriptionprotected UriTemplate.UriTemplateParsercreateParser(String templateString, Object... parserArguments) Creates a parser.Match the given URI string.nest(CharSequence uriTemplate) Nests another URI template with this template.protected UriMatchTemplatenewUriMatchTemplate(CharSequence uriTemplate, List<UriTemplate.PathSegment> newSegments, Pattern newPattern, List<UriMatchVariable> variables) protected UriTemplatenewUriTemplate(CharSequence uriTemplate, List<UriTemplate.PathSegment> newSegments) static UriMatchTemplateCreate a newUriTemplatefor the given URI.Returns the path string excluding any query variables.@Nullable UriMatchInfoMatch the given URI string.Methods inherited from class UriTemplate
buildNestedSegments, compareTo, equals, expand, expand, getPathVariableSegmentCount, getRawSegmentCount, getRawSegmentLength, getTemplateString, getVariableSegmentCount, hashCode, nest, normalizeNested, toString, toStringMethods inherited from interface UriMatcher
match
-
Field Details
-
VARIABLE_MATCH_PATTERN
- See Also:
-
pattern
-
variables
-
-
Constructor Details
-
UriMatchTemplate
Construct a new URI template for the given template.- Parameters:
templateString- The template string
-
UriMatchTemplate
Construct a new URI template for the given template.- Parameters:
templateString- The template stringparserArguments- The parsed arguments
-
UriMatchTemplate
protected UriMatchTemplate(CharSequence templateString, List<UriTemplate.PathSegment> segments, Pattern matchPattern, List<UriMatchVariable> variables) - Parameters:
templateString- The templatesegments- The list of segmentsmatchPattern- The match patternvariables- The variables
-
-
Method Details
-
newUriMatchTemplate
protected UriMatchTemplate newUriMatchTemplate(CharSequence uriTemplate, List<UriTemplate.PathSegment> newSegments, Pattern newPattern, List<UriMatchVariable> variables) - Parameters:
uriTemplate- The templatenewSegments- The list of new segmentsnewPattern- The list of new pattersvariables- The variables- Returns:
- An instance of
UriMatchTemplate
-
getVariableNames
-
getVariables
- Returns:
- The variables this template expects
-
toPathString
Returns the path string excluding any query variables.- Returns:
- The path string
-
match
Match the given URI string.- Specified by:
matchin interfaceUriMatcher- Parameters:
uri- The uRI- Returns:
- an optional match
-
tryMatch
Match the given URI string.- Parameters:
uri- The uRI- Returns:
- a match or null
-
nest
Description copied from class:UriTemplateNests another URI template with this template.- Overrides:
nestin classUriTemplate- Parameters:
uriTemplate- The URI template. If it does not begin with forward slash it will automatically be appended with forward slash- Returns:
- The new URI template
-
of
Create a newUriTemplatefor the given URI.- Parameters:
uri- The URI- Returns:
- The template
-
newUriTemplate
protected UriTemplate newUriTemplate(CharSequence uriTemplate, List<UriTemplate.PathSegment> newSegments) - Overrides:
newUriTemplatein classUriTemplate- Parameters:
uriTemplate- The URI templatenewSegments- The new segments- Returns:
- The new
UriTemplate
-
createParser
protected UriTemplate.UriTemplateParser createParser(String templateString, Object... parserArguments) Description copied from class:UriTemplateCreates a parser.- Overrides:
createParserin classUriTemplate- Parameters:
templateString- The templateparserArguments- The parsed arguments- Returns:
- The created parser
-