public class WithDefaultsRulesWrapper extends Object implements Rules
Rules
Decorator that returns default rules
when no matches are returned by the wrapped implementation.
This allows default Rule
instances to be added to any
existing Rules
implementation. These default Rule
instances will be returned for any match for which the wrapped
implementation does not return any matches.
For example,
Rule alpha; ... WithDefaultsRulesWrapper rules = new WithDefaultsRulesWrapper(new BaseRules()); rules.addDefault(alpha); ... digester.setRules(rules); ...
when a pattern does not match any other rule, then rule alpha will be called.
WithDefaultsRulesWrapper
follows the Decorator pattern.
Constructor and Description |
---|
WithDefaultsRulesWrapper(Rules wrappedRules)
Base constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
add(String pattern,
Rule rule)
Adds a Rule to be fired on given pattern.
|
void |
addDefault(Rule rule)
Adds a rule to be fired when wrapped implementation returns no matches
|
void |
clear()
Clears all Rule's
|
List<Rule> |
getDefaults()
Gets Rule's which will be fired when the wrapped implementation returns no matches
|
Digester |
getDigester()
Gets digester using these Rules
|
String |
getNamespaceURI()
Gets namespace to apply to Rule's added
|
List<Rule> |
match(String namespaceURI,
String pattern)
Return list of rules matching given pattern.
|
List<Rule> |
rules()
Gets all rules
|
void |
setDigester(Digester digester)
Sets digester using these Rules
|
void |
setNamespaceURI(String namespaceURI)
Sets namespace to apply to Rule's added subsequently
|
public WithDefaultsRulesWrapper(Rules wrappedRules)
wrappedRules
- the wrapped Rules
implementation, not nullIllegalArgumentException
- when wrappedRules
is nullpublic Digester getDigester()
getDigester
in interface Rules
public void setDigester(Digester digester)
setDigester
in interface Rules
digester
- The newly associated Digester instancepublic String getNamespaceURI()
getNamespaceURI
in interface Rules
public void setNamespaceURI(String namespaceURI)
setNamespaceURI
in interface Rules
namespaceURI
- Namespace URI that must match on all
subsequently added rules, or null
for matching
regardless of the current namespace URIpublic List<Rule> getDefaults()
public List<Rule> match(String namespaceURI, String pattern)
public void addDefault(Rule rule)
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.