org.springframework.extensions.surf.uri
Class UriTemplateMappingIndex

java.lang.Object
  extended by org.springframework.extensions.surf.uri.UriTemplateMappingIndex

public class UriTemplateMappingIndex
extends Object

Index of application URI template mappings. One or more URI templates can map to a single entry url. Each template uses a simple form of the JAX-RS JSR-311 URI Template format - only basic variables are specified in the URI template for matching. Example config:

    
    
       /site/{site}/dashboard
       /page/sites/{site}/dashboard
    
    
    
       /user/{user}
       /user/{user}/mydashboard
       /page/users/{user}/dashboard
    
    
    
       /user/{user}/wiki/{path}
       /page/users/tools/wiki?user={user}&article={path}
    
 

Author:
Kevin Roast

Constructor Summary
UriTemplateMappingIndex(ConfigElement config)
          Constructor
 
Method Summary
 Map<String,String> findMatch(String uri)
          Search the URI index to locale a match for the specified URI.
 String findMatchAndReplace(String uri)
          Search the URI index to locate a match for the specified URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UriTemplateMappingIndex

public UriTemplateMappingIndex(ConfigElement config)
Constructor

Parameters:
config - ConfigElement pointing to the sections (see above)
Method Detail

findMatchAndReplace

public String findMatchAndReplace(String uri)
Search the URI index to locate a match for the specified URI. If found, return the matched URL with the tokens replaced as per the pattern and supplied URI value.

Parameters:
uri - URI to match against the URI Templates in the index
Returns:
URI match with tokens replaced as per the URI Template pattern or null if no match was found.

findMatch

public Map<String,String> findMatch(String uri)
Search the URI index to locale a match for the specified URI. If found, return the args that represent the matched URI pattern tokens and the values as per the supplied URI value.

Parameters:
uri - URI to match against the URI Templates in the index
Returns:
Map of token args to values or null if no match was found.


Copyright © 2009 SpringSource, Inc. All Rights Reserved.