summaryrefslogtreecommitdiffstats
path: root/contrib/java
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/java')
-rw-r--r--contrib/java/common/org/uscxml/dm/jexl/JexlDataModel.java268
-rw-r--r--contrib/java/common/org/uscxml/helper/StopWatch.java19
-rw-r--r--contrib/java/common/org/uscxml/helper/TestMonitor.java71
-rw-r--r--contrib/java/generated/build.properties5
-rw-r--r--contrib/java/generated/build.xml35
-rw-r--r--contrib/java/generated/org/uscxml/Data.java59
-rw-r--r--contrib/java/generated/org/uscxml/DataList.java20
-rw-r--r--contrib/java/generated/org/uscxml/DataMap.java20
-rw-r--r--contrib/java/generated/org/uscxml/DataModel.java77
-rw-r--r--contrib/java/generated/org/uscxml/DataModelExtension.java5
-rw-r--r--contrib/java/generated/org/uscxml/ErrorEvent.java9
-rw-r--r--contrib/java/generated/org/uscxml/Event.java5
-rw-r--r--contrib/java/generated/org/uscxml/InterpreterException.java11
-rw-r--r--contrib/java/generated/org/uscxml/InterpreterMonitor.java65
-rw-r--r--contrib/java/generated/org/uscxml/StateChart.java222
-rw-r--r--contrib/java/generated/org/uscxml/StateChartJava5Impl.java89
-rw-r--r--contrib/java/generated/org/uscxml/StringList.java10
-rw-r--r--contrib/java/generated/org/uscxml/StringVector.java15
-rw-r--r--contrib/java/generated/org/uscxml/dm/jexl/DataModelExtension.java5
-rw-r--r--contrib/java/generated/org/uscxml/dm/jexl/Event.java5
-rw-r--r--contrib/java/generated/org/uscxml/examples/hello-world.xml25
-rw-r--r--contrib/java/generated/org/uscxml/tests/gen/TestStateChart.java27
-rw-r--r--contrib/java/libs/commons-jexl3-3.0.jarbin0 -> 383861 bytes
-rw-r--r--contrib/java/libs/commons-logging-1.2.jarbin0 -> 61829 bytes
24 files changed, 1067 insertions, 0 deletions
diff --git a/contrib/java/common/org/uscxml/dm/jexl/JexlDataModel.java b/contrib/java/common/org/uscxml/dm/jexl/JexlDataModel.java
new file mode 100644
index 0000000..731ceaa
--- /dev/null
+++ b/contrib/java/common/org/uscxml/dm/jexl/JexlDataModel.java
@@ -0,0 +1,268 @@
+package org.uscxml.dm.jexl;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Field;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.jexl3.JexlBuilder;
+import org.apache.commons.jexl3.JexlEngine;
+import org.apache.commons.jexl3.JexlException;
+import org.apache.commons.jexl3.JexlExpression;
+import org.apache.commons.jexl3.MapContext;
+import org.uscxml.Data;
+import org.uscxml.DataList;
+import org.uscxml.DataMap;
+import org.uscxml.DataModel;
+import org.uscxml.DataModelExtension;
+import org.uscxml.ErrorEvent;
+import org.uscxml.Event;
+import org.uscxml.StringList;
+import org.uscxml.StringVector;
+
+public class JexlDataModel extends DataModel {
+
+ protected static final JexlEngine jexl = new JexlBuilder().cache(512).strict(true).silent(false).create();
+ public MapContext ctx = new MapContext();
+
+ @Override
+ public void addExtension(DataModelExtension ext) {
+ throw new UnsupportedOperationException("Cannot add extensions to the jexl datamodel");
+ }
+
+ @Override
+ public StringList getNames() {
+ StringList names = new StringList();
+ names.add("jexl");
+ return names;
+ }
+
+ @Override
+ public DataModel create() {
+ JexlDataModel dm = new JexlDataModel();
+ return dm;
+ }
+
+ @Override
+ public boolean isValidSyntax(String expr) {
+ try {
+ jexl.createExpression(expr);
+ return true;
+ } catch(JexlException e) {
+ return false;
+ }
+ }
+
+ @Override
+ public void setEvent(Event event) {
+ ctx.set("_event", event);
+ }
+
+ @Override
+ public Data getAsData(String content) {
+ try {
+ JexlExpression ex = jexl.createExpression(content);
+ return getJexlObjectAsData(ex.evaluate(ctx));
+ } catch(Exception e) {
+ }
+ return null;
+ }
+
+ @Override
+ public Data evalAsData(String content) {
+ JexlExpression expr = jexl.createExpression(content);
+ Data d = getJexlObjectAsData(expr.evaluate(ctx));
+// d.setAtom(expr.getParsedText());
+// d.setType(Data.Type.VERBATIM);
+ return d;
+ }
+
+ @Override
+ public boolean evalAsBool(String expr) {
+ try {
+ JexlExpression ex = jexl.createExpression("!!" + expr);
+ Object result = ex.evaluate(ctx);
+ return (Boolean) result;
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
+
+ @Override
+ public long getLength(String expr) {
+ try {
+ JexlExpression ex = jexl.createExpression(expr);
+ Object res = ex.evaluate(ctx);
+
+ return Array.getLength(res);
+
+ } catch(Exception e) {
+ throw new ErrorEvent("Cannot evaluate '" + expr + "' as an array: " + e.getMessage());
+ }
+ }
+
+ @Override
+ public void setForeach(String item, String array, String index, long iteration) {
+ Object res = null;
+ try {
+ JexlExpression ex = jexl.createExpression(array);
+ res = ex.evaluate(ctx);
+ } catch(Exception e) {
+ throw new ErrorEvent("Cannot evaluate '" + array + "' as an array: " + e.getMessage());
+ }
+ try {
+ JexlExpression ex = jexl.createExpression(item + "==" + item + ";");
+ ex.evaluate(ctx);
+
+ ctx.set(item, Array.get(res, (int) iteration));
+ } catch(Exception e) {
+ throw new ErrorEvent("Cannot set item '" + item + "' to current item: " + e.getMessage());
+ }
+ try {
+ if (index.length() > 0) {
+ ctx.set(index, iteration);
+ }
+ } catch(Exception e) {
+ throw new ErrorEvent("Cannot set index '" + index + "' to current index: " + e.getMessage());
+ }
+ }
+
+ @Override
+ public void assign(String location, Data data) {
+ try {
+ ctx.set(location, getDataAsJexlObject(data));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ public void init(String location, Data data) {
+ ctx.set(location, null);
+ assign(location, data);
+ }
+
+ @Override
+ public boolean isDeclared(String expr) {
+ try {
+ JexlExpression ex = jexl.createExpression(expr);
+ Object result = ex.evaluate(ctx);
+ return (Boolean) result;
+ } catch(JexlException e) {
+ }
+ return false;
+ }
+
+ protected Object evalAsObject(String expr) {
+ try {
+ JexlExpression ex = jexl.createExpression(expr);
+ return (ex.evaluate(ctx));
+ } catch(JexlException e) {
+ }
+ return null;
+ }
+
+ protected Data getJexlObjectAsData(Object obj) {
+ Data d = new Data();
+ if (obj.getClass().isArray()) {
+ int length = Array.getLength(obj);
+ for (int i = 0; i < length; i ++) {
+ d.getArray().add(getJexlObjectAsData(Array.get(obj, i)));
+ }
+ } else if (obj.getClass().isPrimitive() || isWrapperType(obj.getClass())) {
+ String val = obj.toString();
+ try {
+ Integer.parseInt(obj.toString());
+ d.setAtom(obj.toString());
+ d.setType(Data.Type.INTERPRETED);
+ return d;
+ } catch(NumberFormatException e) {}
+ try {
+ Double.parseDouble(obj.toString());
+ d.setAtom(obj.toString());
+ d.setType(Data.Type.INTERPRETED);
+ return d;
+ } catch(NumberFormatException e) {}
+ d.setAtom(obj.toString());
+ d.setType(Data.Type.VERBATIM);
+ return d;
+ } else {
+ Field[] fields = obj.getClass().getDeclaredFields();
+ for (Field field: fields) {
+ Object newObj = null;
+ try {
+ field.get(newObj);
+ d.getCompound().set(field.getName(), getJexlObjectAsData(newObj));
+ }
+ catch (IllegalArgumentException e) {}
+ catch (IllegalAccessException e) {}
+ }
+ return d;
+ }
+
+ return d;
+ }
+
+ protected Object getDataAsJexlObject(Data data) {
+ if (data.getAtom().length() > 0) {
+ if (data.getType() == Data.Type.INTERPRETED) {
+ try {
+ JexlExpression exp = jexl.createExpression(data.getAtom());
+ return exp.evaluate(ctx);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return new String(data.getAtom());
+ }
+ try {
+ JexlExpression exp = jexl.createExpression(data.getAtom());
+ return exp.evaluate(ctx);
+ } catch (Exception e) {
+ }
+ return new String("\"" + data.getAtom() + "\"");
+
+ } else if (data.getCompound().size() > 0) {
+ StringVector keys = data.getCompoundKeys();
+ DataMap dataCompound = data.getCompound();
+ Map<String, Object> objCompound = new HashMap<String, Object>();
+ for (int i = 0; i < keys.size(); i++) {
+ objCompound.put(keys.get(i), getDataAsJexlObject(dataCompound.get(keys.get(i))));
+ }
+ return objCompound;
+ } else if (data.getArray().size() > 0) {
+ DataList dataList = data.getArray();
+ List<Object> objList = new ArrayList<Object>((int) data.getArray().size());
+ for (int i = 0; i < dataList.size(); i++) {
+ objList.add(i, getDataAsJexlObject(dataList.get(i)));
+ }
+ return objList;
+ }
+ return new Object();
+ }
+
+ protected static boolean isWrapperType(Class<?> clazz) {
+ return WRAPPER_TYPES.contains(clazz);
+ }
+
+ private static final Set<Class<?>> WRAPPER_TYPES = getWrapperTypes();
+
+ private static Set<Class<?>> getWrapperTypes() {
+ Set<Class<?>> ret = new HashSet<Class<?>>();
+ ret.add(Boolean.class);
+ ret.add(Character.class);
+ ret.add(Byte.class);
+ ret.add(Short.class);
+ ret.add(Integer.class);
+ ret.add(Long.class);
+ ret.add(Float.class);
+ ret.add(Double.class);
+ ret.add(Void.class);
+ return ret;
+ }
+
+}
diff --git a/contrib/java/common/org/uscxml/helper/StopWatch.java b/contrib/java/common/org/uscxml/helper/StopWatch.java
new file mode 100644
index 0000000..29ce434
--- /dev/null
+++ b/contrib/java/common/org/uscxml/helper/StopWatch.java
@@ -0,0 +1,19 @@
+package org.uscxml.helper;
+
+public class StopWatch {
+
+ public StopWatch() {
+ }
+
+ public void reset() {
+ System.out.println("RESET");
+ }
+
+ public void start() {
+ System.out.println("START");
+ }
+ public void stop() {
+ System.out.println("STOP");
+ }
+
+}
diff --git a/contrib/java/common/org/uscxml/helper/TestMonitor.java b/contrib/java/common/org/uscxml/helper/TestMonitor.java
new file mode 100644
index 0000000..2b71d82
--- /dev/null
+++ b/contrib/java/common/org/uscxml/helper/TestMonitor.java
@@ -0,0 +1,71 @@
+package org.uscxml.helper;
+
+import org.uscxml.InterpreterMonitor;
+import org.uscxml.StringList;
+
+public class TestMonitor extends InterpreterMonitor {
+
+ public TestMonitor() {}
+
+ @Override
+ public void beforeExitingState(String stateId, String xpath, String stateXML) {
+ System.out.println("beforeExitingState: " + stateId + " " + xpath);
+ }
+
+ @Override
+ public void afterExitingState(String stateId, String xpath, String stateXML) {
+ System.out.println("afterExitingState: " + stateId + " " + xpath);
+ }
+
+ @Override
+ public void beforeExecutingContent(String tagName, String xpath, String contentXML) {
+ System.out.println("afterExecutingContent: " + tagName + " " + xpath);
+ }
+
+ @Override
+ public void afterExecutingContent(String tagName, String xpath, String contentXML) {
+ System.out.println("afterExecutingContent: " + tagName + " " + xpath);
+ }
+
+ @Override
+ public void beforeUninvoking(String xpath, String invokeid, String invokerXML) {
+ System.out.println("beforeUninvoking: " + xpath + " " + invokeid);
+ }
+
+ @Override
+ public void afterUninvoking(String xpath, String invokeid, String invokerXML) {
+ System.out.println("beforeUninvoking: " + xpath + " " + invokeid);
+ }
+
+ @Override
+ public void beforeTakingTransition(String xpath, String source, StringList targets, String transitionXML) {
+ System.out.println("beforeTakingTransition: " + xpath + " " + source + " " + targets);
+ }
+
+ @Override
+ public void afterTakingTransition(String xpath, String source, StringList targets, String transitionXML) {
+ System.out.println("afterTakingTransition: " + xpath + " " + source + " " + targets);
+ }
+
+ @Override
+ public void beforeEnteringState(String stateId, String xpath, String stateXML) {
+ System.out.println("beforeEnteringState: " + stateId + " " + xpath);
+ }
+
+ @Override
+ public void afterEnteringState(String stateId, String xpath, String stateXML) {
+ System.out.println("afterEnteringState: " + stateId + " " + xpath);
+ }
+
+ @Override
+ public void beforeInvoking(String xpath, String invokeid, String invokerXML) {
+ System.out.println("beforeInvoking: " + xpath + " " + invokeid);
+ }
+
+ @Override
+ public void afterInvoking(String xpath, String invokeid, String invokerXML) {
+ System.out.println("afterInvoking: " + xpath + " " + invokeid);
+ }
+
+
+}
diff --git a/contrib/java/generated/build.properties b/contrib/java/generated/build.properties
new file mode 100644
index 0000000..94338e2
--- /dev/null
+++ b/contrib/java/generated/build.properties
@@ -0,0 +1,5 @@
+# Default path on Windows (maybe with an '(x86)' in there for good measure)
+#umundo.jar=C:\\Program Files\\uMundo\\share\\umundo\\lib\\umundo.jar
+
+jexl.jar=../libs/commons-jexl3-3.0.jar
+logging.jar=../libs/commons-logging-1.2.jar \ No newline at end of file
diff --git a/contrib/java/generated/build.xml b/contrib/java/generated/build.xml
new file mode 100644
index 0000000..087ee3e
--- /dev/null
+++ b/contrib/java/generated/build.xml
@@ -0,0 +1,35 @@
+<project name="java-tests" default="test-w3c">
+
+ <property environment="env"/>
+
+ <property file="build.properties" />
+ <property name="src" value="." />
+ <property name="common" value="../common" />
+ <property name="bin" value="bin" />
+
+ <target name="clean">
+ <delete dir="${bin}" />
+ </target>
+
+ <target name="compile">
+ <mkdir dir="${bin}" />
+ <javac destdir="${bin}" debuglevel="lines,vars,source" debug="on"
+ encoding="utf-8" includeantruntime="false" target="1.5" source="1.5">
+ <src path="${src}" />
+ <src path="${common}" />
+ <src path="${generated.dir}" />
+ <classpath>
+ <pathelement location="${logging.jar}" />
+ <pathelement location="${jexl.jar}" />
+ </classpath>
+ <include name="**/*.java" />
+ </javac>
+ </target>
+
+ <target name="test-w3c" depends="compile">
+ <java classpath="${jexl.jar}:${logging.jar}:${bin}:${generated.dir}" classname="org.uscxml.tests.gen.TestStateChart">
+ <arg value="${test.file}"/>
+ </java>
+ </target>
+
+</project> \ No newline at end of file
diff --git a/contrib/java/generated/org/uscxml/Data.java b/contrib/java/generated/org/uscxml/Data.java
new file mode 100644
index 0000000..c3dfe7d
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/Data.java
@@ -0,0 +1,59 @@
+package org.uscxml;
+
+import java.lang.reflect.Field;
+
+import org.uscxml.Data.Type;
+
+public class Data {
+
+ public static enum Type {
+ VERBATIM,
+ INTERPRETED
+ }
+
+ public DataList getArray() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setAtom(String string) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setType(Type interpreted) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public DataMap getCompound() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void set(String name, Data jexlObjectAsData) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public String getAtom() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Type getType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public int size() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public StringVector getCompoundKeys() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/contrib/java/generated/org/uscxml/DataList.java b/contrib/java/generated/org/uscxml/DataList.java
new file mode 100644
index 0000000..f98d5f6
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/DataList.java
@@ -0,0 +1,20 @@
+package org.uscxml;
+
+public class DataList {
+
+ public void add(Data jexlObjectAsData) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public int size() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Data get(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/contrib/java/generated/org/uscxml/DataMap.java b/contrib/java/generated/org/uscxml/DataMap.java
new file mode 100644
index 0000000..ceed1ce
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/DataMap.java
@@ -0,0 +1,20 @@
+package org.uscxml;
+
+public class DataMap {
+
+ public int size() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public Data get(String object) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void set(String name, Data jexlObjectAsData) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/contrib/java/generated/org/uscxml/DataModel.java b/contrib/java/generated/org/uscxml/DataModel.java
new file mode 100644
index 0000000..8e12d19
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/DataModel.java
@@ -0,0 +1,77 @@
+package org.uscxml;
+
+import org.uscxml.dm.jexl.Event;
+
+public class DataModel {
+
+ public long getLength(String expr) {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public void setEvent(Event event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void addExtension(DataModelExtension ext) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public StringList getNames() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public DataModel create() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean isValidSyntax(String expr) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setEvent(org.uscxml.Event event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Data getAsData(String content) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Data evalAsData(String content) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean evalAsBool(String expr) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setForeach(String item, String array, String index, long iteration) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void assign(String location, Data data) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void init(String location, Data data) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public boolean isDeclared(String expr) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+}
diff --git a/contrib/java/generated/org/uscxml/DataModelExtension.java b/contrib/java/generated/org/uscxml/DataModelExtension.java
new file mode 100644
index 0000000..fbb38f9
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/DataModelExtension.java
@@ -0,0 +1,5 @@
+package org.uscxml;
+
+public class DataModelExtension {
+
+}
diff --git a/contrib/java/generated/org/uscxml/ErrorEvent.java b/contrib/java/generated/org/uscxml/ErrorEvent.java
new file mode 100644
index 0000000..699ddad
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/ErrorEvent.java
@@ -0,0 +1,9 @@
+package org.uscxml;
+
+public class ErrorEvent extends Event {
+
+ public ErrorEvent(String string) {
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git a/contrib/java/generated/org/uscxml/Event.java b/contrib/java/generated/org/uscxml/Event.java
new file mode 100644
index 0000000..9469b5f
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/Event.java
@@ -0,0 +1,5 @@
+package org.uscxml;
+
+public class Event extends java.lang.RuntimeException {
+
+}
diff --git a/contrib/java/generated/org/uscxml/InterpreterException.java b/contrib/java/generated/org/uscxml/InterpreterException.java
new file mode 100644
index 0000000..b2baa99
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/InterpreterException.java
@@ -0,0 +1,11 @@
+package org.uscxml;
+
+public class InterpreterException extends Exception {
+ private static final long serialVersionUID = -3534919496547591015L;
+
+ public InterpreterException(String name, String msg) {
+ super(msg);
+ }
+
+ public String name;
+}
diff --git a/contrib/java/generated/org/uscxml/InterpreterMonitor.java b/contrib/java/generated/org/uscxml/InterpreterMonitor.java
new file mode 100644
index 0000000..f67039f
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/InterpreterMonitor.java
@@ -0,0 +1,65 @@
+package org.uscxml;
+
+public class InterpreterMonitor {
+
+ public void beforeExitingState(String stateId, String xpath, String stateXML) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void afterExitingState(String stateId, String xpath, String stateXML) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void beforeExecutingContent(String tagName, String xpath, String contentXML) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void afterExecutingContent(String tagName, String xpath, String contentXML) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void beforeUninvoking(String xpath, String invokeid, String invokerXML) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void afterUninvoking(String xpath, String invokeid, String invokerXML) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void beforeTakingTransition(String xpath, String source, StringList targets, String transitionXML) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void afterTakingTransition(String xpath, String source, StringList targets, String transitionXML) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void beforeEnteringState(String stateId, String xpath, String stateXML) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void afterEnteringState(String stateId, String xpath, String stateXML) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void beforeInvoking(String xpath, String invokeid, String invokerXML) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void afterInvoking(String xpath, String invokeid, String invokerXML) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/contrib/java/generated/org/uscxml/StateChart.java b/contrib/java/generated/org/uscxml/StateChart.java
new file mode 100644
index 0000000..6b620ab
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/StateChart.java
@@ -0,0 +1,222 @@
+package org.uscxml;
+
+import java.util.BitSet;
+import java.util.Deque;
+import java.util.List;
+import java.util.Map;
+
+/** Base class for generated StateCharts */
+
+public abstract class StateChart {
+
+ public enum InterpreterState {
+ USCXML_FINISHED,
+ USCXML_UNDEF,
+ USCXML_IDLE,
+ USCXML_INITIALIZED,
+ USCXML_INSTANTIATED,
+ USCXML_MICROSTEPPED,
+ USCXML_MACROSTEPPED,
+ USCXML_CANCELLED
+ }
+
+ public enum StateType {
+ USCXML_STATE_ATOMIC,
+ USCXML_STATE_PARALLEL,
+ USCXML_STATE_COMPOUND,
+ USCXML_STATE_FINAL,
+ USCXML_STATE_HISTORY_DEEP,
+ USCXML_STATE_HISTORY_SHALLOW,
+ USCXML_STATE_INITIAL,
+ USCXML_STATE_HAS_HISTORY
+ }
+
+ public enum TransitionType {
+ USCXML_TRANS_SPONTANEOUS,
+ USCXML_TRANS_TARGETLESS,
+ USCXML_TRANS_INTERNAL,
+ USCXML_TRANS_HISTORY,
+ USCXML_TRANS_INITIAL
+ }
+
+ public abstract class State {
+ String name;
+ int parent;
+ BitSet children;
+ BitSet completion;
+ BitSet ancestors;
+ Data data;
+ StateType type;
+
+ public abstract void onEntry() throws InterpreterException;
+ public abstract void onExit() throws InterpreterException;
+ public abstract void invoke(Invoke invoker, boolean invoke) throws InterpreterException;
+ }
+
+ public abstract class Transition {
+ int source;
+ BitSet target;
+ String event;
+ String condition;
+ TransitionType type;
+ BitSet conflicts;
+ BitSet exitSet;
+
+ public abstract boolean isEnabled();
+ public abstract boolean isMatched();
+ public abstract void onTransition();
+ }
+
+ public class Data {
+ String id;
+ String src;
+ String expr;
+ String content;
+ }
+
+ public class Assign {
+ String location;
+ String expr;
+ String content;
+ }
+
+ public class Foreach {
+ String array;
+ String item;
+ String index;
+ }
+
+ public class Param {
+ String name;
+ String expr;
+ String location;
+ }
+
+ public class DoneData {
+ int source;
+ String content;
+ String contentExpr;
+ List<Param> params;
+ }
+
+ public abstract class Invoke {
+ StateChart machine;
+ String type;
+ String typeExpr;
+ String src;
+ String srcExpr;
+ String id;
+ String idlocation;
+ String sourceName;
+ String namelist;
+ boolean autoForward;
+ String content;
+ String contentExpr;
+ List<Param> params;
+
+ public abstract void finalize();
+ }
+
+ public class Send {
+ String event;
+ String eventExpr;
+ String target;
+ String targetExpr;
+ String type;
+ String typeExpr;
+ String id;
+ String idlocation;
+ String delay;
+ String delayExpr;
+ String namelist;
+ String content;
+ String contentExpr;
+ List<Param> params;
+ }
+
+ public List<Transition> transitions;
+ public List<State> states;
+
+ public Deque<Object> externalQueue;
+ public Deque<Object> internalQueue;
+
+ protected InterpreterState state = InterpreterState.USCXML_UNDEF;
+ protected Object event;
+
+ protected BitSet flags;
+ protected BitSet config;
+ protected BitSet history;
+ protected BitSet invocations;
+ protected BitSet initializedData;
+
+ protected Map<String, Integer> stateNamesToIndex;
+
+ public InterpreterState step() throws org.uscxml.InterpreterException {
+ return step(0);
+ }
+
+ public InterpreterState step(long blockMs) throws org.uscxml.InterpreterException {
+ /** Here you would implement microstep(T) as in the book chapter */
+
+
+ /** Just to silence the compiler warning */
+ if (true) throw new InterpreterException("", "");
+ return state;
+ }
+
+ public void cancel() {
+ state = InterpreterState.USCXML_CANCELLED;
+ }
+
+ public void reset() {
+ history.clear();
+ config.clear();
+ flags.clear();
+ // @TODO: uninvoke any invokers
+ invocations.clear();
+ }
+
+ public InterpreterState getState() { return state; }
+
+ public boolean isInState(String stateId) {
+ if (!stateNamesToIndex.containsKey(stateId))
+ return false;
+ return config.get((int) stateNamesToIndex.get(stateId));
+ }
+
+ public void receive(Object event) {
+ externalQueue.addLast(event);
+ }
+
+ protected Object dequeueInternal() {
+ try {
+ return internalQueue.removeLast();
+ } catch(Exception e) {
+ return null;
+ }
+ }
+
+ protected Object dequeueExternal() {
+ try {
+ return externalQueue.removeLast();
+ } catch(Exception e) {
+ return null;
+ }
+ }
+
+ public abstract boolean isTrue(String expression);
+ public abstract void raiseDoneEvent(State state, DoneData doneData);
+
+ public abstract void execContentLog(String label, String expression);
+ public abstract void execContentRaise(String event);
+ public abstract void execContentSend(Send send);
+ public abstract void execContentForeachInit(Foreach foreach);
+ public abstract void execContentForeachNext(Foreach foreach);
+ public abstract void execContentForeachDone(Foreach foreach);
+ public abstract void execContentAssign(Assign assign);
+ public abstract void execContentInit(Data data);
+ public abstract void execContentCancel(String sendId, String sendIdExpr);
+ public abstract void execContentScript(String src, String content);
+ public abstract void execContentFinalize(Invoke invoker, Object event);
+
+} \ No newline at end of file
diff --git a/contrib/java/generated/org/uscxml/StateChartJava5Impl.java b/contrib/java/generated/org/uscxml/StateChartJava5Impl.java
new file mode 100644
index 0000000..381a214
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/StateChartJava5Impl.java
@@ -0,0 +1,89 @@
+package org.uscxml;
+
+/**
+ * @author sradomski
+ *
+ * This is the base class inheriting the abstract StateChart class
+ * It is supposed to realize the callbacks with the language features
+ * found in Java5 only.
+ */
+
+public class StateChartJava5Impl extends StateChart {
+
+ @Override
+ public boolean isTrue(String expression) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public void raiseDoneEvent(State state, DoneData doneData) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void execContentLog(String label, String expression) {
+ // TODO Auto-generated method stub
+ }
+
+ @Override
+ public void execContentRaise(String event) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void execContentSend(Send send) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void execContentForeachInit(Foreach foreach) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void execContentForeachNext(Foreach foreach) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void execContentForeachDone(Foreach foreach) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void execContentAssign(Assign assign) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void execContentInit(Data data) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void execContentCancel(String sendId, String sendIdExpr) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void execContentScript(String src, String content) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void execContentFinalize(Invoke invoker, Object event) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/contrib/java/generated/org/uscxml/StringList.java b/contrib/java/generated/org/uscxml/StringList.java
new file mode 100644
index 0000000..6b37b36
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/StringList.java
@@ -0,0 +1,10 @@
+package org.uscxml;
+
+public class StringList {
+
+ public void add(String string) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
diff --git a/contrib/java/generated/org/uscxml/StringVector.java b/contrib/java/generated/org/uscxml/StringVector.java
new file mode 100644
index 0000000..d760a37
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/StringVector.java
@@ -0,0 +1,15 @@
+package org.uscxml;
+
+public class StringVector {
+
+ public int size() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public String get(int i) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
diff --git a/contrib/java/generated/org/uscxml/dm/jexl/DataModelExtension.java b/contrib/java/generated/org/uscxml/dm/jexl/DataModelExtension.java
new file mode 100644
index 0000000..0f70395
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/dm/jexl/DataModelExtension.java
@@ -0,0 +1,5 @@
+package org.uscxml.dm.jexl;
+
+public class DataModelExtension {
+
+}
diff --git a/contrib/java/generated/org/uscxml/dm/jexl/Event.java b/contrib/java/generated/org/uscxml/dm/jexl/Event.java
new file mode 100644
index 0000000..aa1eaae
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/dm/jexl/Event.java
@@ -0,0 +1,5 @@
+package org.uscxml.dm.jexl;
+
+public class Event {
+
+}
diff --git a/contrib/java/generated/org/uscxml/examples/hello-world.xml b/contrib/java/generated/org/uscxml/examples/hello-world.xml
new file mode 100644
index 0000000..3ac168c
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/examples/hello-world.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with this
+ work for additional information regarding copyright ownership. The ASF
+ licenses this file to You under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law
+ or agreed to in writing, software distributed under the License is
+ distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the specific language
+ governing permissions and limitations under the License.
+-->
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
+ initial="hello">
+
+ <final id="hello">
+ <onentry>
+ <log expr="'Hello, World!'" />
+ </onentry>
+ </final>
+
+</scxml> \ No newline at end of file
diff --git a/contrib/java/generated/org/uscxml/tests/gen/TestStateChart.java b/contrib/java/generated/org/uscxml/tests/gen/TestStateChart.java
new file mode 100644
index 0000000..d459c7e
--- /dev/null
+++ b/contrib/java/generated/org/uscxml/tests/gen/TestStateChart.java
@@ -0,0 +1,27 @@
+package org.uscxml.tests.gen;
+
+import org.uscxml.InterpreterException;
+import org.uscxml.StateChart;
+import org.uscxml.gen.TestStateChartBase;
+
+public class TestStateChart extends TestStateChartBase {
+
+ public static void main(String[] args) {
+ System.out.println("Testing " + args[0]);
+
+ TestStateChart machine = new TestStateChart();
+ try {
+ while(machine.step() != StateChart.InterpreterState.USCXML_FINISHED) {
+ // here we could inspect the state chart after a step
+ }
+ // when we arrive here, the state chart is finished
+ assert(machine.isInState("pass"));
+ System.out.println("PASSED");
+ System.exit(0); // EXIT_SUCCESS
+ } catch (InterpreterException e) {
+ System.out.println("FAILED");
+ System.exit(-1); // EXIT_FAILURE
+ }
+ }
+
+}
diff --git a/contrib/java/libs/commons-jexl3-3.0.jar b/contrib/java/libs/commons-jexl3-3.0.jar
new file mode 100644
index 0000000..94566bf
--- /dev/null
+++ b/contrib/java/libs/commons-jexl3-3.0.jar
Binary files differ
diff --git a/contrib/java/libs/commons-logging-1.2.jar b/contrib/java/libs/commons-logging-1.2.jar
new file mode 100644
index 0000000..93a3b9f
--- /dev/null
+++ b/contrib/java/libs/commons-logging-1.2.jar
Binary files differ