1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.mycore.common.xml;
19
20 import org.jdom2.Element;
21 import org.jdom2.Namespace;
22 import org.jdom2.filter.ElementFilter;
23
24
25
26
27 public class MCRAttributeValueFilter extends ElementFilter {
28 private static final long serialVersionUID = 1L;
29
30 protected String attrKey;
31
32 protected String attrValue;
33
34 protected Namespace ns;
35
36 public MCRAttributeValueFilter(String attrKey, Namespace ns, String attrValue) {
37 super();
38 this.attrKey = attrKey;
39 this.attrValue = attrValue;
40 this.ns = ns;
41 }
42
43 public Element filter(Object arg0) {
44 Element e = super.filter(arg0);
45 if (e == null) {
46 return null;
47 }
48 String value = e.getAttributeValue(attrKey, ns);
49 return (value != null && value.equals(attrValue)) ? e : null;
50 }
51 }