-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utilities.java
60 lines (52 loc) · 1.96 KB
/
Utilities.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package nl.bos.appworks.utilities;
import com.eibus.util.logger.CordysLogger;
import com.eibus.xml.nom.Node;
import com.eibus.xml.xpath.NodeSet;
import com.eibus.xml.xpath.ResultNode;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Utilities {
private static final CordysLogger logger = CordysLogger.getCordysLogger(Utilities.class);
private Utilities() throws InstantiationException {
throw new InstantiationException("Not instantiatable utilities class");
}
public static String getHelloString(String arg) {
return "Hello " + arg;
}
/*
nl.bos.appworks.utilities.Utilities.matches (
string(ns2:Readsaved_searchOutput/ns2:Readsaved_searchResponse/ns3:saved_search/ns3:ss_reg_ex/text()),
string(instance:iterator_case)
)
*/
public static boolean matches(String regex, String input) {
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(input);
return m.matches();
}
public static boolean matches(String regex, int xmlInput) {
if(logger.isDebugEnabled()) {
logger.debug(xmlInput);
logger.debug(Node.writeToString(xmlInput, true));
}
return matches(regex, Node.writeToString(xmlInput, false));
}
/*
nl.bos.appworks.utilities.Utilities.matches (
string(ns2:Readsaved_searchOutput/ns2:Readsaved_searchResponse/ns3:saved_search/ns3:ss_reg_ex/text()),
instance:iterator_case
)
*/
public static boolean matches(String regex, NodeSet nodeSetInput) {
StringBuilder input = new StringBuilder();
while (nodeSetInput.hasNext()) {
long nextNode = nodeSetInput.next();
int node = ResultNode.getElementNode(nextNode);
input.append(Node.writeToString(node, false));
}
if(logger.isDebugEnabled()) {
logger.debug(String.valueOf(input));
}
return matches(regex, String.valueOf(input));
}
}