| Method from org.apache.commons.digester.plugins.PluginRules Detail: |
public void add(String pattern,
Rule rule) {
Log log = LogUtils.getLogger(digester);
boolean debug = log.isDebugEnabled();
if (debug) {
log.debug("add entry" + ": mapping pattern [" + pattern + "]" +
" to rule of type [" + rule.getClass().getName() + "]");
}
// allow patterns with a leading slash character
if (pattern.startsWith("/"))
{
pattern = pattern.substring(1);
}
if (mountPoint != null) {
if (!pattern.equals(mountPoint)
&& !pattern.startsWith(mountPoint + "/")) {
// This can only occur if a plugin attempts to add a
// rule with a pattern that doesn't start with the
// prefix passed to the addRules method. Plugins mustn't
// add rules outside the scope of the tag they were specified
// on, so refuse this.
// alas, can't throw exception
log.warn(
"An attempt was made to add a rule with a pattern that"
+ "is not at or below the mountpoint of the current"
+ " PluginRules object."
+ " Rule pattern: " + pattern
+ ", mountpoint: " + mountPoint
+ ", rule type: " + rule.getClass().getName());
return;
}
}
decoratedRules.add(pattern, rule);
if (rule instanceof InitializableRule) {
try {
((InitializableRule)rule).postRegisterInit(pattern);
} catch (PluginConfigurationException e) {
// Currently, Digester doesn't handle exceptions well
// from the add method. The workaround is for the
// initialisable rule to remember that its initialisation
// failed, and to throw the exception when begin is
// called for the first time.
if (debug) {
log.debug("Rule initialisation failed", e);
}
// throw e; -- alas, can't do this
return;
}
}
if (debug) {
log.debug("add exit" + ": mapped pattern [" + pattern + "]" +
" to rule of type [" + rule.getClass().getName() + "]");
}
}
Register a new Rule instance matching the specified pattern. |
public void clear() {
decoratedRules.clear();
}
|
Rules getDecoratedRules() {
return decoratedRules;
}
This package-scope method is used by the PluginCreateRule class to
get direct access to the rules that were dynamically added by the
plugin. No other class should need access to this object. |
public Digester getDigester() {
return digester;
}
Return the Digester instance with which this instance is associated. |
public String getNamespaceURI() {
return decoratedRules.getNamespaceURI();
}
Return the namespace URI that will be applied to all subsequently
added Rule objects. |
public Rules getParent() {
return parent;
}
Return the parent Rules object. |
public String getPluginClassAttr() {
return pluginContext.getPluginClassAttr();
}
|
public String getPluginClassAttrNs() {
return pluginContext.getPluginClassAttrNs();
}
|
public String getPluginIdAttr() {
return pluginContext.getPluginIdAttr();
}
|
public String getPluginIdAttrNs() {
return pluginContext.getPluginIdAttrNs();
}
|
public PluginManager getPluginManager() {
return pluginManager;
}
Return the object which "knows" about all declared plugins. |
public List getRuleFinders() {
return pluginContext.getRuleFinders();
}
|
public RulesFactory getRulesFactory() {
return rulesFactory;
}
Return the rules factory object (or null if one has not been specified). |
public List match(String path) {
return (match(null, path));
} Deprecated! Call - match(namespaceURI,pattern) instead.
Return a List of all registered Rule instances that match the specified
nesting pattern, or a zero-length List if there are no matches. If more
than one Rule instance matches, they must be returned
in the order originally registered through the add()
method. |
public List match(String namespaceURI,
String path) {
Log log = LogUtils.getLogger(digester);
boolean debug = log.isDebugEnabled();
if (debug) {
log.debug(
"Matching path [" + path +
"] on rules object " + this.toString());
}
List matches;
if ((mountPoint != null) &&
(path.length() < = mountPoint.length())) {
if (debug) {
log.debug(
"Path [" + path + "] delegated to parent.");
}
matches = parent.match(namespaceURI, path);
// Note that in the case where path equals mountPoint,
// we deliberately return only the rules from the parent,
// even though this object may hold some rules matching
// this same path. See PluginCreateRule's begin, body and end
// methods for the reason.
} else {
log.debug("delegating to decorated rules.");
matches = decoratedRules.match(namespaceURI, path);
}
return matches;
}
Return a List of all registered Rule instances that match the specified
nodepath, or a zero-length List if there are no matches. If more
than one Rule instance matches, they must be returned
in the order originally registered through the add()
method.
|
public List rules() {
return decoratedRules.rules();
}
|
public void setDigester(Digester digester) {
this.digester = digester;
decoratedRules.setDigester(digester);
}
Set the Digester instance with which this Rules instance is associated. |
public void setNamespaceURI(String namespaceURI) {
decoratedRules.setNamespaceURI(namespaceURI);
}
Set the namespace URI that will be applied to all subsequently
added Rule objects. |
public void setPluginClassAttribute(String namespaceUri,
String attrName) {
pluginContext.setPluginClassAttribute(namespaceUri, attrName);
}
|
public void setPluginIdAttribute(String namespaceUri,
String attrName) {
pluginContext.setPluginIdAttribute(namespaceUri, attrName);
}
|
public void setRuleFinders(List ruleFinders) {
pluginContext.setRuleFinders(ruleFinders);
}
|
public void setRulesFactory(RulesFactory factory) {
rulesFactory = factory;
}
Set the object which is used to generate the new Rules instances created
to hold and process the rules associated with each plugged-in class. |