Class AntPathRequestMatcher

java.lang.Object
com.codename1.backend.security.AntPathRequestMatcher
All Implemented Interfaces:
RequestMatcher

public final class AntPathRequestMatcher extends Object implements RequestMatcher

Matches a request's path against an Ant-style pattern, and optionally its method.

  • ? is one character and * any run of characters within one segment: /files/*.txt.
  • ** is any number of whole segments, none included: /api/** matches /api, /api/ and /api/users/7.
  • {name} is one segment, or the rest of one, bound to that name: /users/{id}.

The path compared is the one the routers compare -- the query removed and percent-escapes of unreserved characters resolved -- so a request cannot be spelled to match a rule here and a different route there. Matching is case sensitive, as routing is, and a trailing slash is part of the path.

  • Constructor Details

    • AntPathRequestMatcher

      public AntPathRequestMatcher(String pattern)
    • AntPathRequestMatcher

      public AntPathRequestMatcher(String pattern, String method)
      Parameters:
      method - the method to match exactly, or null for any
  • Method Details

    • antMatcher

      public static AntPathRequestMatcher antMatcher(String pattern)
      A matcher for pattern, any method.
    • antMatcher

      public static AntPathRequestMatcher antMatcher(String method, String pattern)
      A matcher for pattern and one method, written as HTTP writes it: POST.
    • getPattern

      public String getPattern()
    • matches

      public boolean matches(HttpServer.Request request)
      Specified by:
      matches in interface RequestMatcher
    • matcher

      Description copied from interface: RequestMatcher
      The match with the variables it bound: {id} in a path pattern.
      Specified by:
      matcher in interface RequestMatcher
    • toString

      public String toString()
      Description copied from class: Object
      Returns a string representation of the object. In general, the toString method returns a string that "textually represents" this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method. The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@', and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of: getClass().getName() + '@' + Integer.toHexString(hashCode())
      Overrides:
      toString in class Object