Class UriPatternOrderedMatcher<T>

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

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

Patterns may have three formats:

  • *
  • *<uri>
  • <uri>*

This class can be used to resolve an object matching a particular request URI.

Since:
5.0
  • Field Details

  • Constructor Details

    • UriPatternOrderedMatcher

      public UriPatternOrderedMatcher()
  • Method Details

    • entrySet

      public Set<Map.Entry<String,T>> entrySet()
      Returns a Set view of the mappings contained in this matcher.
      Returns:
      a set view of the mappings contained in this matcher.
      Since:
      4.4.9
      See Also:
    • register

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

      public void unregister(String pattern)
      Removes registered object, if exists, for the given pattern.
      Specified by:
      unregister in interface LookupRegistry<T>
      Parameters:
      pattern - the pattern 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.
    • matchUriRequestPattern

      protected boolean matchUriRequestPattern(String pattern, String path)
      Tests if the given request path matches the given pattern.
      Parameters:
      pattern - the pattern
      path - the request path
      Returns:
      true if the request URI matches the pattern, false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object