|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.avalon.framework.logger.AbstractLogEnabled org.apache.cocoon.selection.AbstractSwitchSelector org.apache.cocoon.selection.AbstractRegexpSelector
public abstract class AbstractRegexpSelector
The AbstractRegexpSelector
abstract class defines a simple selector
operating over configured regular-expression patterns.
Configuration of an AbstractRegexpSelector
is quite simple: first of
all the patterns used for selections must be configured:
<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> </map:selector> </map:selectors> </map:components>
Then, each configured pattern can be referenced in the pipelines section of the sitemap:
<map:pipelines> ... <map:match ...> ... <map:select type="browser"> <map:when test="empty">...</map:when> <map:when test="number">...</map:when> <map:when test="string">...</map:when> <map:otherwise>...</map:otherwise> </map:select> ... </map:match> ... </map:pipelines>
Field Summary | |
---|---|
protected Map |
patterns
A Map of regular expression programs by name. |
Fields inherited from interface org.apache.cocoon.selection.SwitchSelector |
---|
ROLE |
Constructor Summary | |
---|---|
protected |
AbstractRegexpSelector()
Create a new AbstractRegexpSelector instance. |
Method Summary | |
---|---|
protected org.apache.regexp.REProgram |
compile(String pattern)
Compile the pattern in a REProgram . |
void |
configure(Configuration configuration)
Configure this instance parsing all regular expression patterns. |
boolean |
select(String patternName,
Object selectorContext)
Select a pipeline fragment based on a previously configured pattern. |
Methods inherited from class org.apache.cocoon.selection.AbstractSwitchSelector |
---|
select |
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.cocoon.selection.SwitchSelector |
---|
getSelectorContext |
Field Detail |
---|
protected Map patterns
A Map
of regular expression programs by name.
Constructor Detail |
---|
protected AbstractRegexpSelector()
Create a new AbstractRegexpSelector
instance.
Method Detail |
---|
public boolean select(String patternName, Object selectorContext)
Select a pipeline fragment based on a previously configured pattern.
select
in interface SwitchSelector
patternName
- the name of the configured pattern.selectorContext
- the string to be matched by the named pattern.
public void configure(Configuration configuration) throws ConfigurationException
Configure this instance parsing all regular expression patterns.
configure
in interface Configurable
configuration
- the Configuration
instance where configured
patterns are defined.
ConfigurationException
- if one of the regular-expression to configure
could not be compiled.protected org.apache.regexp.REProgram compile(String pattern) throws ConfigurationException
Compile the pattern in a REProgram
.
pattern
- the regular expression pattern in a textual format.
ConfigurationException
- in the pattern could not be compiled.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |