org.weborganic.furi
Class URIPattern

java.lang.Object
  extended by org.weborganic.furi.URITemplate
      extended by org.weborganic.furi.URIPattern
All Implemented Interfaces:
Expandable, Matchable

public class URIPattern
extends URITemplate
implements Matchable

A URI Pattern for matching URI following the same regular structure.

Instances of this class implement the PageSeeder URL pattern as defined by the "PageSeeder URI Templates" document.

A PageSeeder URI Pattern follows the URI syntax defined for URI templates but must only contain matchable tokens.

Version:
27 October 2009
Author:
Christophe Lauret

Constructor Summary
URIPattern(String template)
          Creates a new URI Pattern instance from the specified URI template string.
URIPattern(URITemplate template)
          Creates a new URI Pattern instance from an existing URI Template.
 
Method Summary
 boolean equals(Object o)
           
 int hashCode()
           
static boolean isMatchable(URITemplate template)
          Indicates whether the given URI template can be used to construct a new URI Pattern instance.
 boolean match(String uri)
          Indicates whether this URI Pattern matches the specified URL.
 Pattern pattern()
          Returns the regular expression pattern corresponding to this URI pattern.
 
Methods inherited from class org.weborganic.furi.URITemplate
digest, digest, expand, expand, toString
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

URIPattern

public URIPattern(String template)
           throws IllegalArgumentException
Creates a new URI Pattern instance from the specified URI template string.

Parameters:
template - The string following the URI template syntax.
Throws:
URITemplateSyntaxException - If the string provided does not follow the proper syntax.
IllegalArgumentException

URIPattern

public URIPattern(URITemplate template)
           throws IllegalArgumentException
Creates a new URI Pattern instance from an existing URI Template.

Parameters:
template - The URI template to generate the pattern from.
Throws:
URITemplateSyntaxException - If the string provided does not follow the proper syntax.
IllegalArgumentException
Method Detail

isMatchable

public static boolean isMatchable(URITemplate template)
Indicates whether the given URI template can be used to construct a new URI Pattern instance.

A template is matchable only if all its components are matchable tokens, that is the token implements the Matchable interface.

Parameters:
template - The template to test.
Returns:
true if the template is matchable; false otherwise.

match

public boolean match(String uri)
Indicates whether this URI Pattern matches the specified URL.

Specified by:
match in interface Matchable
Parameters:
uri - The URI to test.
Returns:
true if this URI Pattern matches this

pattern

public Pattern pattern()
Returns the regular expression pattern corresponding to this URI pattern.

Specified by:
pattern in interface Matchable
Returns:
The regular expression pattern corresponding to this URI pattern.

equals

public boolean equals(Object o)
Overrides:
equals in class URITemplate

hashCode

public int hashCode()
Overrides:
hashCode in class URITemplate