Class AbstractMatcher<E>
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ActionConfigMatcher
,NamespaceMatcher
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.
- Since:
- 2.1
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPattern
(String name, E target, boolean looseMatch) Finds and precompiles the wildcard patterns.protected abstract E
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()
Matches the path against the compiled wildcard patterns.Replaces parameter values
-
Constructor Details
-
AbstractMatcher
-
-
Method Details
-
addPattern
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.
- Parameters:
name
- The patterntarget
- The object to associate with the patternlooseMatch
- To loosely match wildcards or not
-
freeze
public void freeze() -
match
Matches the path against the compiled wildcard patterns.
- Parameters:
potentialMatch
- The portion of the request URI for selecting a config.- Returns:
- The action config if matched, else null
-
convert
Clones the target object and its children, replacing various properties with the values of the wildcard-matched strings.
- Parameters:
path
- The requested pathorig
- The original objectvars
- A Map of wildcard-matched strings- Returns:
- A cloned object with appropriate properties replaced with wildcard-matched values
-
replaceParameters
Replaces parameter values
- Parameters:
orig
- The original parameters with placeholder valuesvars
- A Map of wildcard-matched strings- Returns:
- map with replaced parameters
-
convertParam
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.
- Parameters:
val
- The value to convertvars
- A Map of wildcard-matched strings- Returns:
- The new value
-