1 package de.mindcrimeilab.xsanalyzer;
2
3 import java.util.Arrays;
4 import java.util.List;
5
6 import org.apache.commons.lang.StringUtils;
7 import org.apache.xerces.xs.XSObject;
8
9 public abstract class NamespaceFilteredWorker extends AbstractXsComponentWorker implements XsComponentWorker {
10
11
12 protected List<String> filteredNamespaces;
13
14 public NamespaceFilteredWorker() {
15 super();
16 }
17
18
19
20
21
22
23 public void setFilteredNamespaces(String[] namespaces) {
24 filteredNamespaces = Arrays.asList(namespaces);
25 }
26
27 @Override
28 public boolean isSupported(XSObject object) {
29 boolean accepts = false;
30 if (null == object) {
31 accepts = false;
32 }
33 else if (null == filteredNamespaces) {
34 accepts = true;
35 }
36 else {
37 String namespace = object.getNamespace();
38
39 if (null == namespace) {
40 accepts = true;
41 }
42 else if (StringUtils.isNotEmpty(namespace) && !filteredNamespaces.contains(namespace)) {
43 accepts = true;
44 }
45 else {
46 accepts = false;
47 }
48 }
49 return accepts;
50 }
51
52 @Override
53 abstract public void execute(XSObject object, XSObject parent);
54 }