org.sitemesh.config
Class PathMapper<T>

java.lang.Object
  extended by org.sitemesh.config.PathMapper<T>

public class PathMapper<T>
extends Object

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("/mydir/*", two);
pm.put("*.xml", three);
pm.put(""/myexactfile.html", four);
pm.put("/*\/admin/*.??ml", five);

result1 = pm.get("/mydir/myfile.xml"); // returns two;
result2 = pm.get("/mydir/otherdir/admin/myfile.html"); // returns five;

Author:
Joe Walnes, Mike Cannon-Brookes, Hani Suleiman

Constructor Summary
PathMapper()
           
 
Method Summary
 T get(String path)
          Retrieve appropriate key by matching patterns with supplied path.
 void put(String pattern, T value)
          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
 

Constructor Detail

PathMapper

public PathMapper()
Method Detail

put

public void put(String pattern,
                T value)
Add a key and appropriate matching pattern.


get

public T get(String path)
Retrieve appropriate key by matching patterns with supplied path.



Copyright © 2011. All Rights Reserved.