Package io.muserver.rest
Class UriPattern
- java.lang.Object
-
- io.muserver.rest.UriPattern
-
public class UriPattern extends java.lang.ObjectA pattern representing a URI template, such as/fruitor/fruit/{name}etc. To create a new pattern, call the staticuriTemplateToRegex(String)method.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)inthashCode()PathMatchmatcher(java.lang.String rawPath)Matches the given raw path against this pattern.PathMatchmatcher(java.net.URI input)Matches the given URI against this pattern.java.util.List<java.lang.String>namedGroups()java.lang.Stringpattern()java.lang.StringtoString()static UriPatternuriTemplateToRegex(java.lang.String template)Converts a URI Template to a regular expression, following the JAX-RS: Java™ API for RESTful Web Services specification Version 2.0 section3.7.3
-
-
-
Method Detail
-
pattern
public java.lang.String pattern()
- Returns:
- Returns the regular expression used to do the matching
-
namedGroups
public java.util.List<java.lang.String> namedGroups()
- Returns:
- Returns the read-only set of path parameters in this pattern in the order they first appeared
-
matcher
public PathMatch matcher(java.net.URI input)
Matches the given URI against this pattern.- Parameters:
input- The URI to check against.- Returns:
- Returns a
PathMatchwherePathMatch.prefixMatches()istrueif the URI matches and otherwisefalse.
-
matcher
public PathMatch matcher(java.lang.String rawPath)
Matches the given raw path against this pattern.- Parameters:
rawPath- The URL-encoded path to match, for example/example/some%20path- Returns:
- Returns a
PathMatchwherePathMatch.prefixMatches()istrueif the URI matches and otherwisefalse.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
uriTemplateToRegex
public static UriPattern uriTemplateToRegex(java.lang.String template) throws java.lang.IllegalArgumentException
Converts a URI Template to a regular expression, following the JAX-RS: Java™ API for RESTful Web Services specification Version 2.0 section3.7.3- Parameters:
template- A string as passed to aPathannotation, such as/fruit/{name}- Returns:
- Returns a compiled regex Pattern for the given template that will match relevant URI paths, for example
/\Qfruit\E/(?<name>[ˆ/]+?)(/.*)? - Throws:
java.lang.IllegalArgumentException- If the template contains invalid regular expression, or template is null, or other errors
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-