public class PathMapper<T> extends Object
PathMapper pm = new PathMapper();
pm.put("/", one);
pm.put("/mydir/*", two);
pm.put("*.xml", three);
pm.put(""/myexactfile.html", four);
pm.put("/*\/admin/*.??ml", five);
result1 = pm.get("/mydir/myfile.xml"); // returns two;
result2 = pm.get("/mydir/otherdir/admin/myfile.html"); // returns five;
| Modifier and Type | Field and Description |
|---|---|
static Set<String> |
DEFAULT_KEYS |
| Constructor and Description |
|---|
PathMapper() |
| Modifier and Type | Method and Description |
|---|---|
T |
get(String path)
Retrieve appropriate key by matching patterns with supplied path.
|
String |
getPatternInUse(String path)
Retrieve appropriate pattern by matching patterns with supplied path.
|
static boolean |
isComplexKey(String key)
Return
true if the key contains wild cards. |
static boolean |
isDefaultKey(String key)
Return
true if the key default key matching all paths. |
static boolean |
isMoreSpecific(String exclusionPattern,
String decoratorPattern)
Wheter the first pattern is more specific than the second one.
|
void |
put(String pattern,
T value)
Add a key and appropriate matching pattern.
|
public String getPatternInUse(String path)
public static boolean isComplexKey(String key)
true if the key contains wild cards.key - key under testtrue if the key contains wild cardspublic static boolean isDefaultKey(String key)
true if the key default key matching all paths.key - key under testtrue if the key default key matching all pathspublic static boolean isMoreSpecific(String exclusionPattern, String decoratorPattern)
exclusionPattern - pattern which must be more or equally specific to return truedecoratorPattern - pattern which must be less specific to return truetrue if the first pattern is more specific than the second oneCopyright © 2015. All Rights Reserved.