org.apache.cocoon.selection
Class RegexpRequestParameterSelector

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

public class RegexpRequestParameterSelector
extends org.apache.cocoon.selection.AbstractRegexpSelector

The RegexpRequestParameterSelector class defines a selector matching specific request parameters to configured regular-expression patterns.

The configuration of an RegexpRequestParameterSelector follows exactly what has been outlined in AbstractRegexpSelector regarting regular expression patterns, and additionally it requires an extra configuration element specifying the request parameter whose value needs to be matched:

 <map:components>
   ...
   <map:selectors default="...">
     <map:selector name="..." src="org.apache.cocoon.selection....">
       <pattern name="empty">^$</pattern>
       <pattern name="number">^[0-9]+$</pattern>
       <pattern name="string">^.+$</pattern>
       <parameter-name>...</parameter-name>
     </map:selector>
  </map:selectors>
 </map:components>
 

If not configured, or if it needs to be overriddent, the parameter name can also be specified as a <map:parameter .../> inside the pipeline itself.

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

Field Summary
protected  String parameterName
          The name of the parameter to work on.
 
Fields inherited from class org.apache.cocoon.selection.AbstractRegexpSelector
patterns
 
Fields inherited from interface org.apache.cocoon.selection.SwitchSelector
ROLE
 
Constructor Summary
RegexpRequestParameterSelector()
          Create a new RegexpRequestParameterSelector instance.
 
Method Summary
 void configure(Configuration configuration)
          Configure this instance parsing all regular expression patterns and storing the parameter name upon which selection occurs.
 Object getSelectorContext(Map objectModel, Parameters parameters)
          Return the value of the parameter identified by the configured parameter name, if any.
 
Methods inherited from class org.apache.cocoon.selection.AbstractRegexpSelector
compile, select
 
Methods inherited from class org.apache.cocoon.selection.AbstractSwitchSelector
select
 
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
 

Field Detail

parameterName

protected String parameterName

The name of the parameter to work on.

Constructor Detail

RegexpRequestParameterSelector

public RegexpRequestParameterSelector()

Create a new RegexpRequestParameterSelector instance.

Method Detail

configure

public void configure(Configuration configuration)
               throws ConfigurationException

Configure this instance parsing all regular expression patterns and storing the parameter name upon which selection occurs.

Parameters:
configuration - the Configuration instance where configured patterns are defined.
Throws:
ConfigurationException - if one of the regular-expression to configure could not be compiled.

getSelectorContext

public Object getSelectorContext(Map objectModel,
                                 Parameters parameters)

Return the value of the parameter identified by the configured parameter name, if any.

Parameters:
objectModel - the Cocoon object model.
parameters - the Parameters associated with the pipeline.
Returns:
the value of the configured request parameter or null.


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