org.apache.tapestry.util
Class RegexpMatcher

java.lang.Object
  extended by org.apache.tapestry.util.RegexpMatcher

public class RegexpMatcher
extends java.lang.Object

Streamlines the interface to ORO by implicitly constructing the necessary compilers and matchers, and by caching compiled patterns.

Since:
3.0
Author:
Howard Lewis Ship

Constructor Summary
RegexpMatcher()
           
 
Method Summary
 void clear()
          Clears any previously compiled patterns.
protected  org.apache.oro.text.regex.Pattern compilePattern(java.lang.String pattern)
           
 boolean contains(java.lang.String pattern, java.lang.String input)
           
protected  org.apache.oro.text.regex.Pattern getCompiledPattern(java.lang.String pattern)
           
 java.lang.String getEscapedPatternString(java.lang.String pattern)
           
 RegexpMatch[] getMatches(java.lang.String pattern, java.lang.String input)
          Given an input string, finds all matches in an input string for the pattern.
 java.lang.String[] getMatches(java.lang.String pattern, java.lang.String input, int subgroup)
          Given an input string, finds all matches in an input string for the pattern.
protected  org.apache.oro.text.regex.PatternMatcher getPatternMatcher()
           
 boolean matches(java.lang.String pattern, java.lang.String input)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RegexpMatcher

public RegexpMatcher()
Method Detail

compilePattern

protected org.apache.oro.text.regex.Pattern compilePattern(java.lang.String pattern)

getCompiledPattern

protected org.apache.oro.text.regex.Pattern getCompiledPattern(java.lang.String pattern)

clear

public void clear()
Clears any previously compiled patterns.


getPatternMatcher

protected org.apache.oro.text.regex.PatternMatcher getPatternMatcher()

matches

public boolean matches(java.lang.String pattern,
                       java.lang.String input)

contains

public boolean contains(java.lang.String pattern,
                        java.lang.String input)

getEscapedPatternString

public java.lang.String getEscapedPatternString(java.lang.String pattern)

getMatches

public RegexpMatch[] getMatches(java.lang.String pattern,
                                java.lang.String input)
Given an input string, finds all matches in an input string for the pattern.

Parameters:
pattern - the regexp pattern for matching
input - the string to search for matches within
Returns:
array (possibly empty) of matches
Since:
4.0

getMatches

public java.lang.String[] getMatches(java.lang.String pattern,
                                     java.lang.String input,
                                     int subgroup)
Given an input string, finds all matches in an input string for the pattern.

Parameters:
pattern - the regexp pattern for matching
input - the string to search for matches within
subgroup - the group (sub-expression) within the pattern to return as a match
Returns:
array (possibly empty) of matching strings