Class PathMapper

java.lang.Object
com.opensymphony.module.sitemesh.mapper.PathMapper

public class PathMapper 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("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";
Author:
Joe Walnes, Mike Cannon-Brookes, Hani Suleiman
  • Constructor Details

    • PathMapper

      public PathMapper()
  • Method Details

    • put

      public void put(String key, String pattern)
      Add a key and appropriate matching pattern.
      Parameters:
      key - the key
      pattern - the pattern
    • get

      public String get(String path)
      Retrieve appropriate key by matching patterns with supplied path.
      Parameters:
      path - the path
      Returns:
      the string