org.apache.cocoon.selection
Class NamedPatternsSelector

java.lang.Object
  extended byorg.apache.cocoon.util.AbstractLogEnabled
      extended byorg.apache.cocoon.selection.NamedPatternsSelector
All Implemented Interfaces:
Configurable, org.apache.cocoon.selection.Selector, ThreadSafe

public abstract class NamedPatternsSelector
extends org.apache.cocoon.util.AbstractLogEnabled
implements Configurable, ThreadSafe, org.apache.cocoon.selection.Selector

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

Known implementations of this abstract class include BrowserSelector, HostSelector from cocoon-sitemap-components maven module.

Version:
$Id: NamedPatternsSelector.html 1304280 2012-03-23 11:18:01Z ilgrosso $

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 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.cocoon.util.AbstractLogEnabled
getLogger, setLogger
 
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 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


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.