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
ExtendsUriTemplateand 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 classUriMatchTemplate.DefaultUriMatchInfoThe defaultUriMatchInfoimplementation.protected static classUriMatchTemplate.UriMatchTemplateParserExtended version ofUriTemplate.UriTemplateParserthat 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.StringBuilderpatternprotected static java.lang.StringVARIABLE_MATCH_PATTERNprotected 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.protectedUriMatchTemplate(java.lang.CharSequence templateString, java.lang.Object... parserArguments)Construct a new URI template for the given template.protectedUriMatchTemplate(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.UriTemplateParsercreateParser(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.UriMatchTemplatenest(java.lang.CharSequence uriTemplate)Nests another URI template with this template.protected UriMatchTemplatenewUriMatchTemplate(java.lang.CharSequence uriTemplate, java.util.List<UriTemplate.PathSegment> newSegments, java.util.regex.Pattern newPattern, java.util.List<UriMatchVariable> variables)protected UriTemplatenewUriTemplate(java.lang.CharSequence uriTemplate, java.util.List<UriTemplate.PathSegment> newSegments)static UriMatchTemplateof(java.lang.String uri)Create a newUriTemplatefor the given URI.java.lang.StringtoPathString()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:
matchin interfaceUriMatcher- Parameters:
uri- The uRI- Returns:
- True if it matches
-
nest
public UriMatchTemplate nest(java.lang.CharSequence uriTemplate)
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
public static UriMatchTemplate of(java.lang.String uri)
Create a newUriTemplatefor 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:
newUriTemplatein 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:UriTemplateCreates a parser.- Overrides:
createParserin classUriTemplate- Parameters:
templateString- The templateparserArguments- The parsed arguments- Returns:
- The created parser
-
-