O
- the Map.Entry value typepublic class PathMap<O> extends HashMap<String,O>
This mapping implements the path specification recommended in the 2.2 Servlet API.
Path specifications can be of the following forms:
/foo/bar - an exact path specification. /foo/* - a prefix path specification (must end '/*'). *.ext - a suffix path specification. / - the default path specification. "" - the / path specificationMatching is performed in the following order
Multiple path specifications can be mapped by providing a list of specifications. By default this class uses characters ":," as path separators, unless configured differently by calling the static method @see PathMap#setPathSpecSeparators(String)
Special characters within paths such as '?� and ';' are not treated specially as it is assumed they would have been either encoded in the original URL or stripped from the path.
This class is not synchronized. If concurrent modifications are possible then it should be synchronized at a higher level.
Modifier and Type | Class and Description |
---|---|
static class |
PathMap.MappedEntry<O> |
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
PathMap() |
PathMap(boolean noDefault) |
PathMap(int capacity) |
PathMap(Map<String,? extends O> dictMap)
Construct from dictionary PathMap.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsMatch(String path)
Return whether the path matches any entries in the PathMap,
excluding the default entry
|
PathMap.MappedEntry<O> |
getMatch(String path)
Get the entry mapped by the best specification.
|
List<? extends Map.Entry<String,O>> |
getMatches(String path)
Get all entries matched by the path.
|
O |
match(String path)
Get object matched by the path.
|
static boolean |
match(String pathSpec,
String path) |
static boolean |
match(String pathSpec,
String path,
boolean noDefault) |
static String |
pathInfo(String pathSpec,
String path)
Return the portion of a path that is after a path spec.
|
static String |
pathMatch(String pathSpec,
String path)
Return the portion of a path that matches a path spec.
|
O |
put(String pathSpec,
O object)
Add a single path match to the PathMap.
|
static String |
relativePath(String base,
String pathSpec,
String path)
Relative path.
|
O |
remove(Object pathSpec) |
static void |
setPathSpecSeparators(String s)
Set the path spec separator.
|
clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, putAll, size, values
equals, hashCode, toString
public static final String SLASH
public PathMap()
public PathMap(boolean noDefault)
public PathMap(int capacity)
public static void setPathSpecSeparators(String s)
s
- separatorspublic O match(String path)
path
- the path.public PathMap.MappedEntry<O> getMatch(String path)
path
- the path.public List<? extends Map.Entry<String,O>> getMatches(String path)
path
- Path to matchpublic boolean containsMatch(String path)
path
- Path to matchpublic void clear()
public static boolean match(String pathSpec, String path)
pathSpec
- the path specpath
- the pathpublic static boolean match(String pathSpec, String path, boolean noDefault)
pathSpec
- the path specpath
- the pathnoDefault
- true to not handle the default path "/" special, false to allow matcher rules to runpublic static String pathMatch(String pathSpec, String path)
pathSpec
- the path specpath
- the pathpublic static String pathInfo(String pathSpec, String path)
pathSpec
- the path specpath
- the pathCopyright © 2012-2015. All Rights Reserved.