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
Nested ClassesModifier and TypeClassDescriptionprotected static interfaceRepresents an expandable path segment.protected static classAn URI template parser. -
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionUriTemplate(CharSequence templateString) Construct a new URI template for the given template.protectedUriTemplate(CharSequence templateString, Object... parserArguments) Construct a new URI template for the given template.protectedUriTemplate(String templateString, List<UriTemplate.PathSegment> segments) -
Method Summary
Modifier and TypeMethodDescriptionprotected List<UriTemplate.PathSegment>buildNestedSegments(CharSequence uriTemplate, int len, Object... parserArguments) intprotected UriTemplate.UriTemplateParsercreateParser(String templateString, Object... parserArguments) Creates a parser.booleanExpand the string with the given bean.Expand the string with the given parameters.longlongintlonginthashCode()nest(CharSequence uriTemplate) Nests another URI template with this template.protected UriTemplatenest(CharSequence uriTemplate, Object... parserArguments) Nests another URI template with this template.protected UriTemplatenewUriTemplate(CharSequence uriTemplate, List<UriTemplate.PathSegment> newSegments) protected StringnormalizeNested(String uri, CharSequence nested) Normalize a nested URI.static UriTemplateCreate a newUriTemplatefor the given URI.toString()protected StringtoString(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
-
getTemplateString
- Returns:
- The template string
-
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:
compareToin interfaceComparable<UriTemplate>
-
of
Create a newUriTemplatefor 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 lengthparserArguments- 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
-