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 java.lang.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 Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,T>
objectMap
private java.util.Map<java.lang.String,java.util.regex.Pattern>
patternMap
-
Constructor Summary
Constructors Constructor Description UriRegexMatcher()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
lookup(java.lang.String path)
Looks up an object matching the given request path.void
register(java.lang.String regex, T obj)
Registers the given object for URIs matching the given regex.java.lang.String
toString()
void
unregister(java.lang.String regex)
Removes registered object, if exists, for the given regex.
-
-
-
Field Detail
-
objectMap
private final java.util.Map<java.lang.String,T> objectMap
-
patternMap
private final java.util.Map<java.lang.String,java.util.regex.Pattern> patternMap
-
-
Method Detail
-
register
public void register(java.lang.String regex, T obj)
Registers the given object for URIs matching the given regex.- Specified by:
register
in interfaceLookupRegistry<T>
- Parameters:
regex
- the regex to register the handler for.obj
- the object.
-
unregister
public void unregister(java.lang.String regex)
Removes registered object, if exists, for the given regex.- Specified by:
unregister
in interfaceLookupRegistry<T>
- Parameters:
regex
- the regex to unregister.
-
lookup
public T lookup(java.lang.String path)
Looks up an object matching the given request path.- Specified by:
lookup
in interfaceLookupRegistry<T>
- Parameters:
path
- the request path- Returns:
- object or
null
if no match is found.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-