com.opensymphony.module.sitemesh.mapper
public final class: PathMapper [javadoc |
source]
java.lang.Object
com.opensymphony.module.sitemesh.mapper.PathMapper
The PathMapper is used to map file patterns to keys, and find an approriate
key for a given file path. The pattern rules are consistent with those defined
in the Servlet 2.3 API on the whole. Wildcard patterns are also supported, using
any combination of * and ?.
Example
PathMapper pm = new PathMapper();
pm.put("one","/");
pm.put("two","/mydir/*");
pm.put("three","*.xml");
pm.put("four","/myexactfile.html");
pm.put("five","/*\/admin/*.??ml");
String result1 = pm.get("/mydir/myfile.xml"); // returns "two";
String result2 = pm.get("/mydir/otherdir/admin/myfile.html"); // returns "five";
Method from com.opensymphony.module.sitemesh.mapper.PathMapper Summary: |
---|
get, put |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from com.opensymphony.module.sitemesh.mapper.PathMapper Detail: |
public String get(String path) {
if (path == null) path = "/";
String mapped = findKey(path, mappings);
if (mapped == null) return null;
return (String) mappings.get(mapped);
}
Retrieve appropriate key by matching patterns with supplied path. |
public void put(String key,
String pattern) {
if (key != null) {
mappings.put(pattern, key);
}
}
Add a key and appropriate matching pattern. |