Class UriRegexMatcher<T>

java.lang.Object
org.apache.hc.core5.http.protocol.UriRegexMatcher<T>
Type Parameters:
T - The type of registered objects.
All Implemented Interfaces:
LookupRegistry<T>

@Contract(threading=SAFE) public class UriRegexMatcher<T> extends Object implements LookupRegistry<T>
Maintains a map of objects keyed by a request URI regular expression.

The insertion order is in maintained in that map such that the lookup tests each regex until there is a match. This class can be used to resolve an object matching a particular request URI.

Since:
5.0
  • Field Details

  • Constructor Details

    • UriRegexMatcher

      public UriRegexMatcher()
  • Method Details

    • register

      public void register(String regex, T obj)
      Registers the given object for URIs matching the given regex.
      Specified by:
      register in interface LookupRegistry<T>
      Parameters:
      regex - the regex to register the handler for.
      obj - the object.
    • unregister

      public void unregister(String regex)
      Removes registered object, if exists, for the given regex.
      Specified by:
      unregister in interface LookupRegistry<T>
      Parameters:
      regex - the regex to unregister.
    • lookup

      public T lookup(String path)
      Looks up an object matching the given request path.
      Specified by:
      lookup in interface LookupRegistry<T>
      Parameters:
      path - the request path
      Returns:
      object or null if no match is found.
    • toString

      public String toString()
      Overrides:
      toString in class Object