org.apache.cocoon.selection
Class NamedPatternsSelector

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.cocoon.selection.NamedPatternsSelector
All Implemented Interfaces:
Component, Configurable, LogEnabled, ThreadSafe, Selector
Direct Known Subclasses:
BrowserSelector, HostSelector

public abstract class NamedPatternsSelector
extends AbstractLogEnabled
implements Configurable, ThreadSafe, Selector

Abstract class for selectors that select a value when it matches some patterns associated to the select expression.

Version:
CVS $Id: NamedPatternsSelector.html 1304258 2012-03-23 10:09:27Z ilgrosso $
Author:
Sylvain Wallez
See Also:
BrowserSelector, HostSelector

Field Summary
 
Fields inherited from interface org.apache.cocoon.selection.Selector
ROLE
 
Constructor Summary
NamedPatternsSelector()
           
 
Method Summary
protected  boolean checkPatterns(String expression, String value)
          Checks if value is a (case-sensitive) substring of one of the patterns associated to expression
protected  boolean checkPatterns(String expression, String value, boolean caseSensitive)
          Checks if value is a substring of one of the patterns associated to expression
protected  void configure(Configuration conf, String confName, String nameAttr, String valueAttr)
          Setup the association from expressions to a list of patterns.
 
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
 
Methods inherited from interface org.apache.avalon.framework.configuration.Configurable
configure
 
Methods inherited from interface org.apache.cocoon.selection.Selector
select
 

Constructor Detail

NamedPatternsSelector

public NamedPatternsSelector()
Method Detail

configure

protected void configure(Configuration conf,
                         String confName,
                         String nameAttr,
                         String valueAttr)
                  throws ConfigurationException
Setup the association from expressions to a list of patterns. The configuration should look like : <pre> <map:selector name="foo" src="..."> <confName nameAttr="expression" valueAttr="pattern"/> ... others (expression, pattern) associations ... </map:selector> </pre>

Parameters:
conf - the configuration
confName - the name of children of conf that will be used to build associations
nameAttr - the name of the attribute that holds the expression
valueAttr - the name of the attribute that holds the pattern
Throws:
ConfigurationException

checkPatterns

protected boolean checkPatterns(String expression,
                                String value)
Checks if value is a (case-sensitive) substring of one of the patterns associated to expression

Parameters:
expression - the expression that is selected
value - the value to check
Returns:
true if value matches one of the patterns

checkPatterns

protected boolean checkPatterns(String expression,
                                String value,
                                boolean caseSensitive)
Checks if value is a substring of one of the patterns associated to expression

Parameters:
expression - the expression that is selected
value - the value to check
caseSensitive - boolean switch whether comparison is done case-sensitive
Returns:
true if value matches one of the patterns


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