Top Description Fields Constructors Methods
org.apache.hc.core5.http.protocol

public Class UriRegexMatcher<T>

extends Object
implements LookupRegistry<T>
Class Inheritance
All Implemented Interfaces
org.apache.hc.core5.http.protocol.LookupRegistry
Annotations
@Contract
threading:SAFE
Type Parameters
<T>
The type of registered objects.
Imports
java.util.LinkedHashMap, .Map, .Map.Entry, java.util.regex.Pattern, org.apache.hc.core5.annotation.Contract, .ThreadingBehavior, org.apache.hc.core5.util.Args

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

Modifier and TypeField and Description
private final Map<String, T>
private final Map<String, Pattern>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public synchronized T

Returns:

object or null if no match is found.
lookup
(final String
the request path
path
)

Implements org.apache.hc.core5.http.protocol.LookupRegistry.lookup.

Looks up an object matching the given request path.
public synchronized void
register(final String
the regex to register the handler for.
regex
,
final T
the object.
obj
)

Implements org.apache.hc.core5.http.protocol.LookupRegistry.register.

Registers the given object for URIs matching the given regex.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public synchronized void
unregister(final String
the regex to unregister.
regex
)

Implements org.apache.hc.core5.http.protocol.LookupRegistry.unregister.

Removes registered object, if exists, for the given regex.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

objectMapback to summary
private final Map<String, T> objectMap
patternMapback to summary
private final Map<String, Pattern> patternMap

Constructor Detail

UriRegexMatcherback to summary
public UriRegexMatcher()

Method Detail

lookupback to summary
public synchronized T lookup(final String path)

Implements org.apache.hc.core5.http.protocol.LookupRegistry.lookup.

Looks up an object matching the given request path.

Parameters
path:String

the request path

Returns:T

object or null if no match is found.

Annotations
@Override
registerback to summary
public synchronized void register(final String regex, final T obj)

Implements org.apache.hc.core5.http.protocol.LookupRegistry.register.

Registers the given object for URIs matching the given regex.

Parameters
regex:String

the regex to register the handler for.

obj:T

the object.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
unregisterback to summary
public synchronized void unregister(final String regex)

Implements org.apache.hc.core5.http.protocol.LookupRegistry.unregister.

Removes registered object, if exists, for the given regex.

Parameters
regex:String

the regex to unregister.

Annotations
@Override