Class UriPattern


  • public class UriPattern
    extends java.lang.Object
    A pattern representing a URI template, such as /fruit or /fruit/{name} etc. To create a new pattern, call the static uriTemplateToRegex(String) method.
    • 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 PathMatch where PathMatch.prefixMatches() is true if the URI matches and otherwise false.
      • 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 PathMatch where PathMatch.prefixMatches() is true if the URI matches and otherwise false.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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 section 3.7.3
        Parameters:
        template - A string as passed to a Path annotation, 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:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object