|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.opensymphony.xwork2.config.impl.AbstractMatcher<E>
public abstract class AbstractMatcher<E>
Matches patterns against pre-compiled wildcard expressions pulled from target objects. It uses the wildcard matcher from the Apache Cocoon project. Patterns will be matched in the order they were added. The first match wins, so more specific patterns should be defined before less specific patterns.
Nested Class Summary | |
---|---|
private static class |
AbstractMatcher.Mapping<E>
Stores a compiled wildcard pattern and the object it came from. |
Field Summary | |
---|---|
(package private) List<AbstractMatcher.Mapping<E>> |
compiledPatterns
The compiled patterns and their associated target objects |
private static Logger |
log
The logging instance |
(package private) PatternMatcher<Object> |
wildcard
Handles all wildcard pattern matching. |
Constructor Summary | |
---|---|
AbstractMatcher(PatternMatcher<?> helper)
|
Method Summary | |
---|---|
void |
addPattern(String name,
E target,
boolean looseMatch)
Finds and precompiles the wildcard patterns. |
protected abstract E |
convert(String path,
E orig,
Map vars)
Clones the target object and its children, replacing various properties with the values of the wildcard-matched strings. |
protected String |
convertParam(String val,
Map<String,String> vars)
Inserts into a value wildcard-matched strings where specified with the {x} syntax. |
void |
freeze()
|
E |
match(String potentialMatch)
Matches the path against the compiled wildcard patterns. |
protected Map<String,String> |
replaceParameters(Map<String,String> orig,
Map<String,String> vars)
Replaces parameter values |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Logger log
The logging instance
PatternMatcher<Object> wildcard
Handles all wildcard pattern matching.
List<AbstractMatcher.Mapping<E>> compiledPatterns
The compiled patterns and their associated target objects
Constructor Detail |
---|
public AbstractMatcher(PatternMatcher<?> helper)
Method Detail |
---|
public void addPattern(String name, E target, boolean looseMatch)
Finds and precompiles the wildcard patterns. Patterns will be evaluated in the order they were added. Only patterns that actually contain a wildcard will be compiled.
Patterns can optionally be matched "loosely". When the end of the pattern matches \*[^*]\*$ (wildcard, no wildcard, wildcard), if the pattern fails, it is also matched as if the last two characters didn't exist. The goal is to support the legacy "*!*" syntax, where the "!*" is optional.
name
- The patterntarget
- The object to associate with the patternlooseMatch
- To loosely match wildcards or notpublic void freeze()
public E match(String potentialMatch)
Matches the path against the compiled wildcard patterns.
potentialMatch
- The portion of the request URI for selecting a config.
protected abstract E convert(String path, E orig, Map vars)
Clones the target object and its children, replacing various properties with the values of the wildcard-matched strings.
path
- The requested pathorig
- The original objectvars
- A Map of wildcard-matched strings
protected Map<String,String> replaceParameters(Map<String,String> orig, Map<String,String> vars)
Replaces parameter values
orig
- The original parameters with placehold valuesvars
- A Map of wildcard-matched stringsprotected String convertParam(String val, Map<String,String> vars)
Inserts into a value wildcard-matched strings where specified with the {x} syntax. If a wildcard-matched value isn't found, the replacement token is turned into an empty string.
val
- The value to convertvars
- A Map of wildcard-matched strings
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |