|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.module.sitemesh.mapper.PathMapper
public final class 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 ?.
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";
Field Summary | |
---|---|
private Map |
mappings
|
Constructor Summary | |
---|---|
PathMapper()
|
Method Summary | |
---|---|
private static String |
findComplexKey(String path,
Map mappings)
|
private static String |
findDefaultKey(Map mappings)
Look for root pattern ( / ). |
private static String |
findExactKey(String path,
Map mappings)
Check if path matches exact pattern ( /blah/blah.jsp ). |
private static String |
findKey(String path,
Map mappings)
Find exact key in mappings. |
String |
get(String path)
Retrieve appropriate key by matching patterns with supplied path. |
private static boolean |
match(String pattern,
String str,
boolean isCaseSensitive)
|
void |
put(String key,
String pattern)
Add a key and appropriate matching pattern. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private Map mappings
Constructor Detail |
---|
public PathMapper()
Method Detail |
---|
public void put(String key, String pattern)
public String get(String path)
private static String findKey(String path, Map mappings)
private static String findExactKey(String path, Map mappings)
private static String findComplexKey(String path, Map mappings)
private static String findDefaultKey(Map mappings)
private static boolean match(String pattern, String str, boolean isCaseSensitive)
|
www.opensymphony.com/sitemesh/ | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |