org.apache.cocoon.matching
Class AbstractRegexpMatcher

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.matching.AbstractPreparableMatcher
          extended by org.apache.cocoon.matching.AbstractRegexpMatcher
All Implemented Interfaces:
Component, LogEnabled, ThreadSafe, Matcher, PreparableMatcher
Direct Known Subclasses:
CachingRegexpMatcher, RegexpHeaderMatcher, RegexpHostMatcher, RegexpParameterMatcher, RegexpRequestAttributeMatcher, RegexpRequestParameterMatcher, RegexpSessionAttributeMatcher, RegexpURIMatcher

public abstract class AbstractRegexpMatcher
extends AbstractPreparableMatcher
implements ThreadSafe

Base class for all matchers using a regular expression pattern.

Version:
CVS $Id: AbstractRegexpMatcher.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Giacomo Pati, Berin Loritsch, Sylvain Wallez

Field Summary
 
Fields inherited from interface org.apache.cocoon.matching.Matcher
ROLE
 
Constructor Summary
AbstractRegexpMatcher()
           
 
Method Summary
protected abstract  String getMatchString(Map objectModel, Parameters parameters)
          Get the string to test against the regular expression.
 Map preparedMatch(Object preparedPattern, Map objectModel, Parameters parameters)
          Match the prepared pattern against the value returned by getMatchString(Map, Parameters).
 Object preparePattern(String pattern)
          Compile the pattern in a org.apache.regexp.REProgram.
 
Methods inherited from class org.apache.cocoon.matching.AbstractPreparableMatcher
match
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRegexpMatcher

public AbstractRegexpMatcher()
Method Detail

preparePattern

public Object preparePattern(String pattern)
                      throws PatternException
Compile the pattern in a org.apache.regexp.REProgram.

Specified by:
preparePattern in interface PreparableMatcher
Parameters:
pattern - The pattern to prepare. Depending on the implementation the pattern can contain wildcards or regular expressions.
Returns:
an optimized representation of the pattern.
Throws:
PatternException - if the pattern couldn't be prepared.

preparedMatch

public Map preparedMatch(Object preparedPattern,
                         Map objectModel,
                         Parameters parameters)
                  throws PatternException
Match the prepared pattern against the value returned by getMatchString(Map, Parameters).

Specified by:
preparedMatch in interface PreparableMatcher
Parameters:
preparedPattern - The preparedPattern to match against, as returned by PreparableMatcher.preparePattern(String).
objectModel - The Map with objects of the calling environment which can be used to select values this matchers matches against.
Returns:
a Map object with replacements for wildcards/regular-expressions contained in the pattern. If the return value is null there was no match.
Throws:
PatternException

getMatchString

protected abstract String getMatchString(Map objectModel,
                                         Parameters parameters)
Get the string to test against the regular expression. To be defined by concrete subclasses.



Copyright © 1999-2010 The Apache Software Foundation. All Rights Reserved.