com.atlassian.plugin.servlet.util
Class DefaultPathMapper

java.lang.Object
  extended by com.atlassian.plugin.servlet.util.DefaultPathMapper
All Implemented Interfaces:
PathMapper, Serializable

public class DefaultPathMapper
extends Object
implements Serializable, PathMapper

Originally opied from Atlassian Seraph 1.0

Modified to store a list of keys for a mapping rather than a single value. This allows filters to be added that listen on the same path. The get() method will return the first value added if there are multiple keys matching the path, while the getAll() method returns the aggregate matches.

In practice, matching a servlet path should use the get() method and matching filters should use the getAll() method.

Since:
2.1.0
See Also:
Serialized Form

Constructor Summary
DefaultPathMapper()
           
 
Method Summary
 String get(String path)
          Retrieve appropriate key by matching patterns with supplied path.
 Collection<String> getAll(String path)
          Retrieve all mappings which match a supplied path.
 void put(String key, String pattern)
          Add a key and appropriate matching pattern.
protected  String removeRedundantSlashes(String path)
           Reduces sequences of more than one consecutive forward slash ("/") to a single slash (see: https://studio.atlassian.com/browse/PLUG-597).
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultPathMapper

public DefaultPathMapper()
Method Detail

put

public void put(String key,
                String pattern)
Description copied from interface: PathMapper
Add a key and appropriate matching pattern.

Specified by:
put in interface PathMapper

get

public String get(String path)
Description copied from interface: PathMapper
Retrieve appropriate key by matching patterns with supplied path.

Specified by:
get in interface PathMapper

getAll

public Collection<String> getAll(String path)
Description copied from interface: PathMapper
Retrieve all mappings which match a supplied path.

Specified by:
getAll in interface PathMapper

removeRedundantSlashes

protected String removeRedundantSlashes(String path)

Reduces sequences of more than one consecutive forward slash ("/") to a single slash (see: https://studio.atlassian.com/browse/PLUG-597).

Parameters:
path - any string, including null (e.g. "foo//bar")
Returns:
the input string, with all sequences of more than one consecutive slash removed (e.g. "foo/bar")

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011 Atlassian. All Rights Reserved.