summaryrefslogtreecommitdiffstats
path: root/embedding
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-07-21 11:34:44 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-07-21 11:34:44 (GMT)
commitdc5f5ddfa10bf91524e6f7555c263eaea069dcb0 (patch)
tree576b15e7fe75476e8ece954b52aa88871941beb5 /embedding
parent641117e7400e9e5ef0fa451f732eb9009f0914cb (diff)
downloaduscxml-dc5f5ddfa10bf91524e6f7555c263eaea069dcb0.zip
uscxml-dc5f5ddfa10bf91524e6f7555c263eaea069dcb0.tar.gz
uscxml-dc5f5ddfa10bf91524e6f7555c263eaea069dcb0.tar.bz2
try / catch blocks for applications and work on dot output
Diffstat (limited to 'embedding')
-rw-r--r--embedding/java/src/org/uscxml/tests/monitor/TestCustomMonitor.java51
1 files changed, 51 insertions, 0 deletions
diff --git a/embedding/java/src/org/uscxml/tests/monitor/TestCustomMonitor.java b/embedding/java/src/org/uscxml/tests/monitor/TestCustomMonitor.java
new file mode 100644
index 0000000..c748f50
--- /dev/null
+++ b/embedding/java/src/org/uscxml/tests/monitor/TestCustomMonitor.java
@@ -0,0 +1,51 @@
+package org.uscxml.tests.monitor;
+
+import org.uscxml.Data;
+import org.uscxml.Interpreter;
+import org.uscxml.InterpreterException;
+import org.uscxml.InterpreterMonitor;
+
+public class TestCustomMonitor extends InterpreterMonitor {
+
+ @Override
+ public void afterEnteringState(Interpreter interpreter, String stateId,
+ String xpath, String state, boolean moreComing) {
+ System.out.println("Entered state " + stateId);
+ if ("s2".equals(stateId)) {
+ Data data = interpreter.getDataModel().getStringAsData("foo");
+ System.out.println(data);
+ }
+ }
+
+ public static void main(String[] args) throws InterpreterException {
+ System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64.jnilib");
+
+ String xml =
+ "<scxml datamodel=\"ecmascript\">" +
+ " <datamodel>" +
+ " <data id=\"foo\">" +
+ " { foo: 'bar', baz: 'foo' }" +
+ " </data>" +
+ " </datamodel>" +
+ " <state id=\"s1\">" +
+ " <transition target=\"s2\" />" +
+ " </state>" +
+ " <state id=\"s2\">" +
+ " <transition target=\"s3\" />" +
+ " </state>" +
+ " <state id=\"s3\">" +
+ " <transition target=\"done\" />" +
+ " </state>" +
+ " <final id=\"done\" />" +
+ "</scxml>";
+
+ // parse and interpret
+ Interpreter interpreter = Interpreter.fromXML(xml);
+
+ TestCustomMonitor monitor = new TestCustomMonitor();
+ interpreter.addMonitor(monitor);
+
+ interpreter.interpret();
+ }
+
+}