Package io.micronaut.http.uri
Class UriTemplate
java.lang.Object
io.micronaut.http.uri.UriTemplate
- All Implemented Interfaces:
Comparable<UriTemplate>
- Direct Known Subclasses:
UriMatchTemplate
A Fast Implementation of URI Template specification. See rfc6570 and URI.js.
Note: this class has a natural ordering that is inconsistent with equals.
- Since:
- 1.0
- Author:
- Graeme Rocher
-
Nested Class Summary
Modifier and TypeClassDescriptionprotected static interface
Represents an expandable path segment.protected static class
An URI template parser. -
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionUriTemplate
(CharSequence templateString) Construct a new URI template for the given template.protected
UriTemplate
(CharSequence templateString, Object... parserArguments) Construct a new URI template for the given template.protected
UriTemplate
(String templateString, List<UriTemplate.PathSegment> segments) -
Method Summary
Modifier and TypeMethodDescriptionprotected List<UriTemplate.PathSegment>
buildNestedSegments
(CharSequence uriTemplate, int len, Object... parserArguments) int
protected UriTemplate.UriTemplateParser
createParser
(String templateString, Object... parserArguments) Creates a parser.boolean
Expand the string with the given bean.Expand the string with the given parameters.long
long
int
long
int
hashCode()
nest
(CharSequence uriTemplate) Nests another URI template with this template.protected UriTemplate
nest
(CharSequence uriTemplate, Object... parserArguments) Nests another URI template with this template.protected UriTemplate
newUriTemplate
(CharSequence uriTemplate, List<UriTemplate.PathSegment> newSegments) protected String
normalizeNested
(String uri, CharSequence nested) Normalize a nested URI.static UriTemplate
Create a newUriTemplate
for the given URI.toString()
protected String
toString
(Predicate<UriTemplate.PathSegment> filter) Returns the template as a string filtering the segments with the provided filter.
-
Field Details
-
templateString
-
-
Constructor Details
-
UriTemplate
Construct a new URI template for the given template.- Parameters:
templateString
- The template string
-
UriTemplate
Construct a new URI template for the given template.- Parameters:
templateString
- The template stringparserArguments
- The parsed arguments
-
UriTemplate
- Parameters:
templateString
- The templatesegments
- The list of segments
-
-
Method Details
-
getVariableSegmentCount
public long getVariableSegmentCount()- Returns:
- The number of segments that are variable
-
getPathVariableSegmentCount
public long getPathVariableSegmentCount()- Returns:
- The number of path segments that are variable
-
getRawSegmentCount
public long getRawSegmentCount()- Returns:
- The number of segments that are raw
-
getRawSegmentLength
public int getRawSegmentLength()- Returns:
- The number of segments that are raw
-
nest
Nests another URI template with this template.- 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
-
expand
Expand the string with the given parameters.- Parameters:
parameters
- The parameters- Returns:
- The expanded URI
-
expand
Expand the string with the given bean.- Parameters:
bean
- The bean- Returns:
- The expanded URI
-
toString
-
equals
-
hashCode
public int hashCode() -
compareTo
- Specified by:
compareTo
in interfaceComparable<UriTemplate>
-
of
Create a newUriTemplate
for the given URI.- Parameters:
uri
- The URI- Returns:
- The template
-
nest
Nests another URI template with this template.- Parameters:
uriTemplate
- The URI template. If it does not begin with forward slash it will automatically be appended with forward slashparserArguments
- The parsed arguments- Returns:
- The new URI template
-
newUriTemplate
protected UriTemplate newUriTemplate(CharSequence uriTemplate, List<UriTemplate.PathSegment> newSegments) - Parameters:
uriTemplate
- The URI templatenewSegments
- The new segments- Returns:
- The new
UriTemplate
-
normalizeNested
Normalize a nested URI.- Parameters:
uri
- The URInested
- The nested URI- Returns:
- The new URI
-
buildNestedSegments
protected List<UriTemplate.PathSegment> buildNestedSegments(CharSequence uriTemplate, int len, Object... parserArguments) - Parameters:
uriTemplate
- The URI templatelen
- The lenghtparserArguments
- The parsed arguments- Returns:
- A list of path segments
-
createParser
protected UriTemplate.UriTemplateParser createParser(String templateString, Object... parserArguments) Creates a parser.- Parameters:
templateString
- The templateparserArguments
- The parsed arguments- Returns:
- The created parser
-
toString
Returns the template as a string filtering the segments with the provided filter.- Parameters:
filter
- The filter to test segments- Returns:
- The template as a string
-