org.weborganic.furi
Class URIResolver

java.lang.Object
  extended by org.weborganic.furi.URIResolver

public class URIResolver
extends Object

A URI pattern resolver identifies the URI pattern and variables values given a specific URI. This class is typically used as follows:

   // Create a resolver instance 
   URIResolver resolver = new URIResolver("http://www.acme.com/test/home");
 
   // Find the matching pattern amongst a list of precompiled URI patterns
   URIPattern pattern = resolver.find(patterns);
   
   // Resolve the URI for the specified pattern, the result holds all the matching info
   URIResolveResult result = resolver.resolve(p);
 

Version:
11 June 2009
Author:
Christophe Lauret

Nested Class Summary
static class URIResolver.MatchRule
          Defines the priority rule for matching patterns.
 
Constructor Summary
URIResolver(String uri)
          Creates a new resolver for the specified URI.
 
Method Summary
 URIPattern find(List<URIPattern> patterns)
          Returns the first URI pattern in the list which matches the underlying URI.
 URIPattern find(List<URIPattern> patterns, URIResolver.MatchRule rule)
          Returns the first URI pattern in the list which matches the underlying URI.
 Collection<URIPattern> findAll(List<URIPattern> patterns)
          Returns all the URI patterns in the list which match the underlying URI.
 URIResolveResult resolve(URIPattern pattern)
          Resolves the given URI pattern.
 URIResolveResult resolve(URIPattern pattern, VariableBinder binder)
          Resolves the given URI pattern using the specified variable binder.
 String uri()
          Returns the URI handled by this resolver.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URIResolver

public URIResolver(String uri)
Creates a new resolver for the specified URI.

Parameters:
uri - The URI to resolve.
Method Detail

uri

public String uri()
Returns the URI handled by this resolver.

Returns:
The URI handled by this resolver.

find

public URIPattern find(List<URIPattern> patterns)
Returns the first URI pattern in the list which matches the underlying URI.

Parameters:
patterns - The URI patterns available.
Returns:
The first URI pattern that matches or null.

find

public URIPattern find(List<URIPattern> patterns,
                       URIResolver.MatchRule rule)
Returns the first URI pattern in the list which matches the underlying URI.

Parameters:
patterns - The URI patterns available.
rule - The rule used to select the matching patterns in case of multiple matches.
Returns:
The first URI pattern that matches or null.

findAll

public Collection<URIPattern> findAll(List<URIPattern> patterns)
Returns all the URI patterns in the list which match the underlying URI. This methods returns an empty list if there are no matching patterns.

Parameters:
patterns - The URI patterns available.
Returns:
A collection of matching URI patterns.

resolve

public URIResolveResult resolve(URIPattern pattern)
Resolves the given URI pattern.

Parameters:
pattern - The pattern to resolve.
Returns:
The URI pattern that best matches the given URI.

resolve

public URIResolveResult resolve(URIPattern pattern,
                                VariableBinder binder)
Resolves the given URI pattern using the specified variable binder.

Parameters:
pattern - The pattern to resolve.
binder - The variable binder.
Returns:
The URI pattern that best matches the given URI.