Return a List of Rule instances for the specified pattern that also match the specified namespace URI (if any). If there are no such rules, return null . @param namespaceURI Namespace URI to match, or null to select matching rules regardless of namespace
(String namespaceURI, String pattern)
| 183 | * @return a rules list |
| 184 | */ |
| 185 | protected List<Rule> lookup(String namespaceURI, String pattern) { |
| 186 | // Optimize when no namespace URI is specified |
| 187 | List<Rule> list = this.cache.get(pattern); |
| 188 | if (list == null) { |
| 189 | return null; |
| 190 | } |
| 191 | if (namespaceURI == null || namespaceURI.isEmpty()) { |
| 192 | return list; |
| 193 | } |
| 194 | |
| 195 | // Select only Rules that match on the specified namespace URI |
| 196 | List<Rule> results = new ArrayList<>(); |
| 197 | for (Rule item : list) { |
| 198 | if ((namespaceURI.equals(item.getNamespaceURI())) || (item.getNamespaceURI() == null)) { |
| 199 | results.add(item); |
| 200 | } |
| 201 | } |
| 202 | return results; |
| 203 | } |
| 204 | } |