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. @param nam
(String namespaceURI, String pattern)
| 133 | * @param pattern Nesting pattern to be matched |
| 134 | */ |
| 135 | @Override |
| 136 | public List<Rule> match(String namespaceURI, String pattern) { |
| 137 | |
| 138 | // List rulesList = (List) this.cache.get(pattern); |
| 139 | List<Rule> rulesList = lookup(namespaceURI, pattern); |
| 140 | if ((rulesList == null) || (rulesList.isEmpty())) { |
| 141 | // Find the longest key, ie more discriminant |
| 142 | String longKey = ""; |
| 143 | for (String key : this.cache.keySet()) { |
| 144 | if (key.startsWith("*/")) { |
| 145 | if (pattern.equals(key.substring(2)) || pattern.endsWith(key.substring(1))) { |
| 146 | if (key.length() > longKey.length()) { |
| 147 | // rulesList = (List) this.cache.get(key); |
| 148 | rulesList = lookup(namespaceURI, key); |
| 149 | longKey = key; |
| 150 | } |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | if (rulesList == null) { |
| 156 | rulesList = new ArrayList<>(); |
| 157 | } |
| 158 | return rulesList; |
| 159 | } |
| 160 | |
| 161 | |
| 162 | /** |