diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-08-13 17:30:58 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-08-13 17:30:58 (GMT) |
commit | cf45e4bf71dd2a8b27c50d247c3f09a1e22e1fa9 (patch) | |
tree | d0561246efce6d170050b64d48f8b49316f149af /contrib/java | |
parent | 422dedee98e956a7f4cffa69a4ba0a34716dec7f (diff) | |
download | uscxml-cf45e4bf71dd2a8b27c50d247c3f09a1e22e1fa9.zip uscxml-cf45e4bf71dd2a8b27c50d247c3f09a1e22e1fa9.tar.gz uscxml-cf45e4bf71dd2a8b27c50d247c3f09a1e22e1fa9.tar.bz2 |
More work on java datamodel interface
Diffstat (limited to 'contrib/java')
-rw-r--r-- | contrib/java/.classpath | 1 | ||||
-rw-r--r-- | contrib/java/.project | 5 | ||||
-rw-r--r-- | contrib/java/src/org/uscxml/tests/TestData.java | 23 | ||||
-rw-r--r-- | contrib/java/src/org/uscxml/tests/TestDataModel.java | 11 | ||||
-rw-r--r-- | contrib/java/src/org/uscxml/tests/TestInvoker.java | 9 |
5 files changed, 38 insertions, 11 deletions
diff --git a/contrib/java/.classpath b/contrib/java/.classpath index 053c69a..96001cb 100644 --- a/contrib/java/.classpath +++ b/contrib/java/.classpath @@ -2,6 +2,7 @@ <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="uscxml"/> + <classpathentry kind="src" path="bindings"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> </classpath> diff --git a/contrib/java/.project b/contrib/java/.project index 4c68397..fda3442 100644 --- a/contrib/java/.project +++ b/contrib/java/.project @@ -16,6 +16,11 @@ </natures> <linkedResources> <link> + <name>bindings</name> + <type>2</type> + <location>/Users/sradomski/Documents/TK/Code/uscxml/src/bindings/swig/java</location> + </link> + <link> <name>uscxml</name> <type>2</type> <location>/Users/sradomski/Documents/TK/Code/uscxml/build/cli/src/bindings/swig/java</location> diff --git a/contrib/java/src/org/uscxml/tests/TestData.java b/contrib/java/src/org/uscxml/tests/TestData.java new file mode 100644 index 0000000..cb2fc0b --- /dev/null +++ b/contrib/java/src/org/uscxml/tests/TestData.java @@ -0,0 +1,23 @@ +package org.uscxml.tests; + +import org.uscxml.Data; +import org.uscxml.DataNative; + +public class TestData { + + public static void main(String[] args) { + System.load("/Users/sradomski/Documents/TK/Code/uscxml/build/cli/lib/libuscxmlNativeJava64_d.jnilib"); + { + Data data = Data.fromJSON("[1,2,3,4,5]"); + DataNative nData2 = Data.toNative(data); + Data data2 = new Data(nData2); + System.out.println(data2); + } + { + Data data = Data.fromJSON("{ \"foo\": \"bar\", \"faz\": 12 }"); + DataNative nData2 = Data.toNative(data); + Data data2 = new Data(nData2); + System.out.println(data2); + } + } +} diff --git a/contrib/java/src/org/uscxml/tests/TestDataModel.java b/contrib/java/src/org/uscxml/tests/TestDataModel.java index 0721501..06a56d7 100644 --- a/contrib/java/src/org/uscxml/tests/TestDataModel.java +++ b/contrib/java/src/org/uscxml/tests/TestDataModel.java @@ -1,14 +1,11 @@ package org.uscxml.tests; import org.uscxml.Data; +import org.uscxml.DataNative; import org.uscxml.Event; import org.uscxml.Factory; import org.uscxml.Interpreter; import org.uscxml.JavaDataModel; -import org.uscxml.SWIGTYPE_p_Arabica__DOM__DocumentT_std__string_t; -import org.uscxml.SWIGTYPE_p_Arabica__DOM__ElementT_std__string_t; -import org.uscxml.SWIGTYPE_p_boost__shared_ptrT_uscxml__DataModelImpl_t; -import org.uscxml.SWIGTYPE_p_uscxml__InterpreterImpl; import org.uscxml.StringSet; @@ -55,14 +52,14 @@ public class TestDataModel extends JavaDataModel { } @Override - public Data getStringAsData(String content) { + public DataNative getStringAsData(String content) { /** * Evaluate the string as a value expression and * transform it into a JSON-like Data structure */ System.out.println("getStringAsData " + content); Data data = new Data(); - return data; + return Data.toNative(data); } @Override @@ -79,7 +76,7 @@ public class TestDataModel extends JavaDataModel { public void setForeach(String item, String array, String index, long iteration) { /** * Prepare an iteration of the foreach element, by setting the variable in index - * to the curent iteration and setting the variable in item to the current item + * to the current iteration and setting the variable in item to the current item * from array. */ System.out.println("setForeach " + item + " " + index + " " + iteration); diff --git a/contrib/java/src/org/uscxml/tests/TestInvoker.java b/contrib/java/src/org/uscxml/tests/TestInvoker.java index b41bd43..8f68c6b 100644 --- a/contrib/java/src/org/uscxml/tests/TestInvoker.java +++ b/contrib/java/src/org/uscxml/tests/TestInvoker.java @@ -1,6 +1,7 @@ package org.uscxml.tests; import org.uscxml.Data; +import org.uscxml.DataNative; import org.uscxml.Event; import org.uscxml.Factory; import org.uscxml.Interpreter; @@ -20,10 +21,10 @@ public class TestInvoker extends JavaInvoker { } @Override - public Data getDataModelVariables() { + public DataNative getDataModelVariables() { Data data = new Data(); - data.getArray().add(new Data("foo", Data.Type.VERBATIM)); - return data; + data.array.add(new Data("foo", Data.Type.VERBATIM)); + return Data.toNative(data); } @Override @@ -35,7 +36,7 @@ public class TestInvoker extends JavaInvoker { public void invoke(InvokeRequest req) { System.out.println("invoke"); - System.out.println(Data.toJSON(req.getData())); + System.out.println(req.getData()); System.out.println(req.getXML()); Event ev = new Event(); |