View Javadoc

1   package com.atlassian.plugin.descriptors.servlet.util;
2   
3   import java.util.Collection;
4   
5   /**
6    * 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
7    * defined in the Servlet 2.3 API on the whole. Wildcard patterns are also supported, using any combination of * and ?.
8    * <h3>Example</h3>
9    * <blockquote><code>
10   * PathMapper pm = new PathMapper();<br>
11   * <br>
12   * pm.put("one","/");<br>
13   * pm.put("two","/mydir/*");<br>
14   * pm.put("three","*.xml");<br>
15   * pm.put("four","/myexactfile.html");<br>
16   * pm.put("five","/*\/admin/*.??ml");<br>
17   * <br>
18   * String result1 = pm.get("/mydir/myfile.xml"); // returns "two";<br>
19   * String result2 = pm.get("/mydir/otherdir/admin/myfile.html"); // returns "five";<br>
20   * </code></blockquote>
21   * <p>
22   * This was copied from Atlassian Seraph 1.0
23   */
24  public interface PathMapper
25  {
26      /**
27       * Retrieve appropriate key by matching patterns with supplied path.
28       */
29      String get(String path);
30  
31      /**
32       * Retrieve all mappings which match a supplied path.
33       */
34      Collection<String> getAll(String path);
35  
36      /**
37       * Add a key and appropriate matching pattern.
38       */
39      void put(final String key, final String pattern);
40  }