org.apache.hc.core5.http.protocol

## 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

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `UriRegexMatcher()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `T` | `lookup(String path)` Looks up an object matching the given request path.
    `void` | `register(String regex, T obj)` Registers the given object for URIs matching the given regex.
    `String` | `toString()`
    `void` | `unregister(String regex)` Removes registered object, if exists, for the given regex.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### UriRegexMatcher

          public UriRegexMatcher()

  - ### Method Detail

    - #### 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`

Copyright © 2005–2021 The Apache Software Foundation. All rights reserved.