Package io.micronaut.http.uri
Class UriMatchTemplate
- java.lang.Object
-
- io.micronaut.http.uri.UriTemplate
-
- io.micronaut.http.uri.UriMatchTemplate
-
- All Implemented Interfaces:
UriMatcher
,java.lang.Comparable<UriTemplate>
- Direct Known Subclasses:
UriTypeMatchTemplate
public class UriMatchTemplate extends UriTemplate implements UriMatcher
ExtendsUriTemplate
and adds the ability to match a URI to a given template using theUriMatcher.match(java.net.URI)
method.- Since:
- 1.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
UriMatchTemplate.DefaultUriMatchInfo
The defaultUriMatchInfo
implementation.protected static class
UriMatchTemplate.UriMatchTemplateParser
Extended version ofUriTemplate.UriTemplateParser
that builds a regular expression to match a path.-
Nested classes/interfaces inherited from class io.micronaut.http.uri.UriTemplate
UriTemplate.PathSegment, UriTemplate.UriTemplateParser
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringBuilder
pattern
protected static java.lang.String
VARIABLE_MATCH_PATTERN
protected java.util.List<UriMatchVariable>
variables
-
Fields inherited from class io.micronaut.http.uri.UriTemplate
templateString
-
-
Constructor Summary
Constructors Modifier Constructor Description UriMatchTemplate(java.lang.CharSequence templateString)
Construct a new URI template for the given template.protected
UriMatchTemplate(java.lang.CharSequence templateString, java.lang.Object... parserArguments)
Construct a new URI template for the given template.protected
UriMatchTemplate(java.lang.CharSequence templateString, java.util.List<UriTemplate.PathSegment> segments, java.util.regex.Pattern matchPattern, java.util.List<UriMatchVariable> variables)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected UriTemplate.UriTemplateParser
createParser(java.lang.String templateString, java.lang.Object... parserArguments)
Creates a parser.java.util.List<java.lang.String>
getVariableNames()
java.util.List<UriMatchVariable>
getVariables()
java.util.Optional<UriMatchInfo>
match(java.lang.String uri)
Match the given URI string.UriMatchTemplate
nest(java.lang.CharSequence uriTemplate)
Nests another URI template with this template.protected UriMatchTemplate
newUriMatchTemplate(java.lang.CharSequence uriTemplate, java.util.List<UriTemplate.PathSegment> newSegments, java.util.regex.Pattern newPattern, java.util.List<UriMatchVariable> variables)
protected UriTemplate
newUriTemplate(java.lang.CharSequence uriTemplate, java.util.List<UriTemplate.PathSegment> newSegments)
static UriMatchTemplate
of(java.lang.String uri)
Create a newUriTemplate
for the given URI.java.lang.String
toPathString()
Returns the path string excluding any query variables.-
Methods inherited from class io.micronaut.http.uri.UriTemplate
buildNestedSegments, compareTo, equals, expand, expand, getPathVariableSegmentCount, getRawSegmentCount, getRawSegmentLength, getVariableSegmentCount, hashCode, nest, normalizeNested, toString, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.micronaut.http.uri.UriMatcher
match
-
-
-
-
Field Detail
-
VARIABLE_MATCH_PATTERN
protected static final java.lang.String VARIABLE_MATCH_PATTERN
- See Also:
- Constant Field Values
-
pattern
protected java.lang.StringBuilder pattern
-
variables
protected java.util.List<UriMatchVariable> variables
-
-
Constructor Detail
-
UriMatchTemplate
public UriMatchTemplate(java.lang.CharSequence templateString)
Construct a new URI template for the given template.- Parameters:
templateString
- The template string
-
UriMatchTemplate
protected UriMatchTemplate(java.lang.CharSequence templateString, java.lang.Object... parserArguments)
Construct a new URI template for the given template.- Parameters:
templateString
- The template stringparserArguments
- The parsed arguments
-
UriMatchTemplate
protected UriMatchTemplate(java.lang.CharSequence templateString, java.util.List<UriTemplate.PathSegment> segments, java.util.regex.Pattern matchPattern, java.util.List<UriMatchVariable> variables)
- Parameters:
templateString
- The templatesegments
- The list of segmentsmatchPattern
- The match patternvariables
- The variables
-
-
Method Detail
-
newUriMatchTemplate
protected UriMatchTemplate newUriMatchTemplate(java.lang.CharSequence uriTemplate, java.util.List<UriTemplate.PathSegment> newSegments, java.util.regex.Pattern newPattern, java.util.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
public java.util.List<java.lang.String> getVariableNames()
- Returns:
- The variables this template expects
-
getVariables
public java.util.List<UriMatchVariable> getVariables()
- Returns:
- The variables this template expects
-
toPathString
public java.lang.String toPathString()
Returns the path string excluding any query variables.- Returns:
- The path string
-
match
public java.util.Optional<UriMatchInfo> match(java.lang.String uri)
Match the given URI string.- Specified by:
match
in interfaceUriMatcher
- Parameters:
uri
- The uRI- Returns:
- True if it matches
-
nest
public UriMatchTemplate nest(java.lang.CharSequence uriTemplate)
Description copied from class:UriTemplate
Nests another URI template with this template.- Overrides:
nest
in 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
public static UriMatchTemplate of(java.lang.String uri)
Create a newUriTemplate
for the given URI.- Parameters:
uri
- The URI- Returns:
- The template
-
newUriTemplate
protected UriTemplate newUriTemplate(java.lang.CharSequence uriTemplate, java.util.List<UriTemplate.PathSegment> newSegments)
- Overrides:
newUriTemplate
in classUriTemplate
- Parameters:
uriTemplate
- The URI templatenewSegments
- The new segments- Returns:
- The new
UriTemplate
-
createParser
protected UriTemplate.UriTemplateParser createParser(java.lang.String templateString, java.lang.Object... parserArguments)
Description copied from class:UriTemplate
Creates a parser.- Overrides:
createParser
in classUriTemplate
- Parameters:
templateString
- The templateparserArguments
- The parsed arguments- Returns:
- The created parser
-
-