org.apache.http.protocol
Class UriPatternMatcher<T>

java.lang.Object
  extended by org.apache.http.protocol.UriPatternMatcher<T>

@ThreadSafe
public class UriPatternMatcher<T>
extends Object

Maintains a map of objects keyed by a request URI pattern.
Patterns may have three formats:


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

Since:
4.0

Constructor Summary
UriPatternMatcher()
           
 
Method Summary
 Map<String,T> getObjects()
          Returns the objects map.
 T lookup(String requestURI)
          Looks up an object matching the given request URI.
protected  boolean matchUriRequestPattern(String pattern, String requestUri)
          Tests if the given request URI matches the given pattern.
 void register(String pattern, T obj)
          Registers the given object for URIs matching the given pattern.
 void setHandlers(Map<String,T> map)
          Deprecated. (4.1) use setObjects(Map)
 void setObjects(Map<String,T> map)
          Sets objects from the given map.
 void unregister(String pattern)
          Removes registered object, if exists, for the given pattern.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UriPatternMatcher

public UriPatternMatcher()
Method Detail

register

public void register(String pattern,
                     T obj)
Registers the given object for URIs matching the given pattern.

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.

Parameters:
pattern - the pattern to unregister.

setHandlers

@Deprecated
public void setHandlers(Map<String,T> map)
Deprecated. (4.1) use setObjects(Map)


setObjects

public void setObjects(Map<String,T> map)
Sets objects from the given map.

Parameters:
map - the map containing objects keyed by their URI patterns.

getObjects

public Map<String,T> getObjects()
Returns the objects map.

Returns:
The map of objects.
Since:
4.2

lookup

public T lookup(String requestURI)
Looks up an object matching the given request URI.

Parameters:
requestURI - the request URI
Returns:
object or null if no match is found.

matchUriRequestPattern

protected boolean matchUriRequestPattern(String pattern,
                                         String requestUri)
Tests if the given request URI matches the given pattern.

Parameters:
pattern - the pattern
requestUri - the request URI
Returns:
true if the request URI matches the pattern, false otherwise.


Copyright © 2005-2013 The Apache Software Foundation. All Rights Reserved.