1 package com.atlassian.plugin.servlet.util;
2
3 import java.util.Collection;
4
5 /**
6 * The PathMapper is used to map file patterns to keys, and find an appropriate 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 * @since 2.1.0
25 */
26 public interface PathMapper {
27 /**
28 * Retrieve appropriate key by matching patterns with supplied path.
29 */
30 String get(String path);
31
32 /**
33 * Retrieve all mappings which match a supplied path.
34 */
35 Collection<String> getAll(String path);
36
37 /**
38 * Add a key and appropriate matching pattern.
39 */
40 void put(final String key, final String pattern);
41 }