org.mortbay.http
Class PathMap
- Externalizable
public class PathMap
extends HashMap
implements Externalizable
URI path map to Object.
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.
Matching is performed in the following order
Exact match.
Longest prefix match.
Longest suffix match.
default.
Multiple path specifications can be mapped by providing a list of
specifications. The list is separated by the characters specified
in the "org.mortbay.http.PathMap.separators" System property, which
defaults to :
Note that this is a very different mapping to that provided by PathMap
in Jetty2.
This class is not synchronized for get's. If concurrent modifications are
possible then it should be synchronized at a higher level.
$Id: PathMap.java,v 1.25 2005/08/13 00:01:24 gregwilkins Exp $PathMap() - Construct empty PathMap.
|
PathMap(Map m) - Construct from dictionary PathMap.
|
PathMap(boolean nodefault) - Construct empty PathMap.
|
PathMap(int capacity) - Construct empty PathMap.
|
void | clear()
|
Map.Entry | getMatch(String path) - Get the entry mapped by the best specification.
|
List | getMatches(String path) - Get all entries matched by the path.
|
Object | 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.
|
Object | put(Object pathSpec, Object object) - Add a single path match to the PathMap.
|
void | readExternal(java.io.ObjectInput in)
|
static String | relativePath(String base, String pathSpec, String path) - Relative path.
|
Object | remove(Object pathSpec)
|
static void | setPathSpecSeparators(String s) - Set the path spec separator.
|
void | writeExternal(java.io.ObjectOutput out)
|
PathMap
public PathMap()
Construct empty PathMap.
PathMap
public PathMap(Map m)
Construct from dictionary PathMap.
PathMap
public PathMap(boolean nodefault)
Construct empty PathMap.
PathMap
public PathMap(int capacity)
Construct empty PathMap.
getMatch
public Map.Entry getMatch(String path)
Get the entry mapped by the best specification.
- Map.Entry of the best matched or null.
getMatches
public List getMatches(String path)
Get all entries matched by the path.
Best match first.
- List of Map.Entry instances key=pathSpec
match
public Object match(String path)
Get object matched by the path.
- Best matched object or null.
match
public static boolean match(String pathSpec,
String path)
throws IllegalArgumentException
match
public static boolean match(String pathSpec,
String path,
boolean noDefault)
throws IllegalArgumentException
pathInfo
public static String pathInfo(String pathSpec,
String path)
Return the portion of a path that is after a path spec.
pathMatch
public static String pathMatch(String pathSpec,
String path)
Return the portion of a path that matches a path spec.
put
public Object put(Object pathSpec,
Object object)
Add a single path match to the PathMap.
pathSpec
- The path specification, or comma separated list of
path specifications.object
- The object the path maps to
readExternal
public void readExternal(java.io.ObjectInput in)
throws java.io.IOException,
ClassNotFoundException
relativePath
public static String relativePath(String base,
String pathSpec,
String path)
Relative path.
base
- The base the path is relative to.pathSpec
- The spec of the path segment to ignore.path
- the additional path
- base plus path with pathspec removed
remove
public Object remove(Object pathSpec)
setPathSpecSeparators
public static void setPathSpecSeparators(String s)
Set the path spec separator.
Multiple path specification may be included in a single string
if they are separated by the characters set in this string.
The default value is ":," or whatever has been set by the
system property org.mortbay.http.PathMap.separators
writeExternal
public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException
Copyright © 2004 Mortbay Consulting Pty. Ltd. All Rights Reserved.