diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-07-01 22:51:30 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-07-01 22:51:30 (GMT) |
commit | 945160d0539ad119ffc986fac712db76c7203e84 (patch) | |
tree | c43e4a7db898026bc62cc20af5061d07736f847e /src/bindings/swig/java/org/uscxml/Data.java | |
parent | c70d02010ea99e6c8e35da3b767f41f1ee5dce56 (diff) | |
download | uscxml-945160d0539ad119ffc986fac712db76c7203e84.zip uscxml-945160d0539ad119ffc986fac712db76c7203e84.tar.gz uscxml-945160d0539ad119ffc986fac712db76c7203e84.tar.bz2 |
More polishing for bindings C# and Java
Diffstat (limited to 'src/bindings/swig/java/org/uscxml/Data.java')
-rw-r--r-- | src/bindings/swig/java/org/uscxml/Data.java | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/src/bindings/swig/java/org/uscxml/Data.java b/src/bindings/swig/java/org/uscxml/Data.java deleted file mode 100644 index 7781f47..0000000 --- a/src/bindings/swig/java/org/uscxml/Data.java +++ /dev/null @@ -1,89 +0,0 @@ -package org.uscxml; - -import java.util.HashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -public class Data { - public Map<String, Data> compound = new HashMap<String, Data>(); - public List<Data> array = new LinkedList<Data>(); - public String atom; - public Type type = Type.INTERPRETED; - - public enum Type { - VERBATIM, INTERPRETED - } - - public static Data fromJSON(String jsonString) { - return new Data(DataNative.fromJSON(jsonString)); - } - - public Data() { - } - - public Data(String atom, Data.Type type) { - this.atom = atom; - this.type = type; - } - - public Data(DataNative nativeData) { - if (!nativeData.getCompound().empty()) { - // data is a key value compound - StringVector keys = nativeData.getCompundKeys(); - for(int i = 0; i < keys.size(); i++) { - this.compound.put(keys.get(i), new Data(nativeData.getCompound().get(keys.get(i)))); - } - } else if (!nativeData.getArray().isEmpty()) { - // data is an array - for (int i = 0; i < nativeData.getArray().size(); i++) { - this.array.add(new Data(nativeData.getArray().get(i))); - } - } else { - // data is a single atom - this.atom = nativeData.getAtom(); - if (nativeData.getType() == DataNative.Type.INTERPRETED) { - this.type = Type.INTERPRETED; - } else { - this.type = Type.VERBATIM; - } - } - } - - @Override - public String toString() { - return toJSON(); - } - - public String toJSON() { - DataNative nativeData = toNative(this); - return DataNative.toJSON(nativeData); - } - - public static DataNative toNative(Data data) { - DataNative nativeData = new DataNative(); - //nativeData.swigCMemOwn = false; - if (data.compound != null && !data.compound.isEmpty()) { - DataMap nativeDataMap = new DataMap(); - for (String key : data.compound.keySet()) { - nativeDataMap.set(key, toNative(data.compound.get(key))); - } - nativeData.setCompound(nativeDataMap); - } else if (data.array != null && !data.array.isEmpty()) { - DataList nativeDataList = new DataList(); - for (Data item : data.array) { - nativeDataList.add(toNative(item)); - } - nativeData.setArray(nativeDataList); - } else if (data.atom != null) { - nativeData.setAtom(data.atom); - if (data.type == Type.INTERPRETED) { - nativeData.setType(DataNative.Type.INTERPRETED); - } else { - nativeData.setType(DataNative.Type.VERBATIM); - } - } - return nativeData; - } - -} |