blob: dd5e39a31d061c54c408b838fb1e610ff00699e8 (
plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
package org.uscxml.tests.execContent;
import org.uscxml.Data;
import org.uscxml.Event;
import org.uscxml.Factory;
import org.uscxml.Interpreter;
import org.uscxml.InterpreterException;
import org.uscxml.WrappedExecutableContent;
public class TestCustomExecContent extends WrappedExecutableContent {
static int instanceId = 0;
public int id = 0;
public TestCustomExecContent() {
id = instanceId++;
}
@Override
public String getLocalName() {
return "custom";
}
@Override
public String getNamespace() {
return "http://www.w3.org/2005/07/scxml";
}
@Override
public void enterElement(String node) {
System.out.println(id + " entering:" + node);
}
@Override
public void exitElement(String node) {
System.out.println(id + " exiting:" + node);
}
@Override
public boolean processChildren() {
return false;
}
@Override
public WrappedExecutableContent create(Interpreter interpreter) {
return new TestCustomExecContent();
}
/**
* @param args
* @throws InterruptedException
* @throws InterpreterException
*/
public static void main(String[] args) throws InterruptedException, InterpreterException {
System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64.jnilib");
TestCustomExecContent execContent = new TestCustomExecContent();
Factory.getInstance().registerExecutableContent(execContent);
Interpreter interpreter = Interpreter.fromXML(
"<scxml>\n" +
" <state id=\"s0\">\n" +
" <onentry>\n" +
" <custom foo=\"bar\">\n" +
" <something></something>\n" +
" </custom>\n" +
" <custom foo=\"bar\">\n" +
" <something></something>\n" +
" </custom>\n" +
" </onentry>\n" +
" <transition target=\"exit\" />" +
" </state>\n" +
" <final id=\"exit\" />" +
"</scxml>\n"
);
interpreter.interpret();
Thread.sleep(1000);
}
}
|