public class PathMap
extends java.util.HashMap
implements java.io.Externalizable
/foo/bar - an exact path specification. /foo/* - a prefix path specification (must end '/*'). *.ext - a suffix path specification. / - the default path specification.Matching is performed in the following order
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.Entry |
Constructor and Description |
---|
PathMap()
Construct empty PathMap.
|
PathMap(boolean nodefault)
Construct empty PathMap.
|
PathMap(int capacity)
Construct empty PathMap.
|
PathMap(java.util.Map m)
Construct from dictionary PathMap.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
containsMatch(java.lang.String path)
Return whether the path matches any entries in the PathMap,
excluding the default entry
|
java.lang.Object |
getLazyMatches(java.lang.String path)
Get all entries matched by the path.
|
PathMap.Entry |
getMatch(java.lang.String path)
Get the entry mapped by the best specification.
|
java.util.List |
getMatches(java.lang.String path)
Get all entries matched by the path.
|
java.lang.Object |
match(java.lang.String path)
Get object matched by the path.
|
static boolean |
match(java.lang.String pathSpec,
java.lang.String path) |
static boolean |
match(java.lang.String pathSpec,
java.lang.String path,
boolean noDefault) |
static java.lang.String |
pathInfo(java.lang.String pathSpec,
java.lang.String path)
Return the portion of a path that is after a path spec.
|
static java.lang.String |
pathMatch(java.lang.String pathSpec,
java.lang.String path)
Return the portion of a path that matches a path spec.
|
java.lang.Object |
put(java.lang.Object pathSpec,
java.lang.Object object)
Add a single path match to the PathMap.
|
void |
readExternal(java.io.ObjectInput in) |
static java.lang.String |
relativePath(java.lang.String base,
java.lang.String pathSpec,
java.lang.String path)
Relative path.
|
java.lang.Object |
remove(java.lang.Object pathSpec) |
static void |
setPathSpecSeparators(java.lang.String s)
Set the path spec separator.
|
void |
writeExternal(java.io.ObjectOutput out) |
clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, putAll, size, values
public PathMap()
public PathMap(boolean nodefault)
public PathMap(int capacity)
public PathMap(java.util.Map m)
public static void setPathSpecSeparators(java.lang.String s)
s
- separatorspublic void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
writeExternal
in interface java.io.Externalizable
java.io.IOException
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException
public java.lang.Object put(java.lang.Object pathSpec, java.lang.Object object)
put
in interface java.util.Map
put
in class java.util.HashMap
pathSpec
- The path specification, or comma separated list of
path specifications.object
- The object the path maps topublic java.lang.Object match(java.lang.String path)
path
- the path.public PathMap.Entry getMatch(java.lang.String path)
path
- the path.public java.lang.Object getLazyMatches(java.lang.String path)
path
- Path to matchpublic java.util.List getMatches(java.lang.String path)
path
- Path to matchpublic boolean containsMatch(java.lang.String path)
path
- Path to matchpublic java.lang.Object remove(java.lang.Object pathSpec)
remove
in interface java.util.Map
remove
in class java.util.HashMap
public void clear()
clear
in interface java.util.Map
clear
in class java.util.HashMap
public static boolean match(java.lang.String pathSpec, java.lang.String path) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public static boolean match(java.lang.String pathSpec, java.lang.String path, boolean noDefault) throws java.lang.IllegalArgumentException
java.lang.IllegalArgumentException
public static java.lang.String pathMatch(java.lang.String pathSpec, java.lang.String path)
public static java.lang.String pathInfo(java.lang.String pathSpec, java.lang.String path)
public static java.lang.String relativePath(java.lang.String base, java.lang.String pathSpec, java.lang.String path)
base
- The base the path is relative to.pathSpec
- The spec of the path segment to ignore.path
- the additional pathCopyright © 2013. All Rights Reserved.