// --------------------------------------------------------- Public Methods
/** *RegisteranewRuleinstancematchingthespecifiedpattern. * *@parampatternNestingpatterntobematchedforthisRule *@paramruleRuleinstancetoberegistered
*/
@Override publicvoid add(String pattern, Rule rule) { // to help users who accidentally add '/' to the end of their patterns int patternLength = pattern.length(); if (patternLength>1 && pattern.endsWith("/")) {
pattern = pattern.substring(0, patternLength-1);
}
cache.computeIfAbsent(pattern, k -> new ArrayList<>()).add(rule);
rules.add(rule); if (this.digester != null) {
rule.setDigester(this.digester);
}
}
/** *ReturnaListofRuleinstancesforthespecifiedpatternthatalso *matchthespecifiednamespaceURI(ifany).Iftherearenosuch *rules,return<code>null</code>. * *@paramnamespaceURINamespaceURItomatch,or<code>null</code>to *selectmatchingrulesregardlessofnamespaceURI *@parampatternPatterntobematched *@returnaruleslist
*/ protected List<Rule> lookup(String namespaceURI, String pattern) { // Optimize when no namespace URI is specified
List<Rule> list = this.cache.get(pattern); if (list == null) { returnnull;
} if (namespaceURI == null || namespaceURI.length() == 0) { return list;
}
// Select only Rules that match on the specified namespace URI
List<Rule> results = new ArrayList<>(); for (Rule item : list) { if ((namespaceURI.equals(item.getNamespaceURI())) ||
(item.getNamespaceURI() == null)) {
results.add(item);
}
} return results;
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.