fix handling of java-arrays

This commit is contained in:
Peter Hormanns 2015-01-14 13:18:35 +01:00
parent 0d5b001230
commit bc14a31133

View File

@ -1,3 +1,4 @@
importClass(java.util.Arrays);
importClass(java.util.ArrayList);
importClass(java.util.HashMap);
@ -51,21 +52,31 @@ function hsaParseParamObject(o) {
}
function hsaToNativeJSObject(val) {
if (val instanceof java.util.List) {
var res = [];
for (var i = 0; i < val.size(); i++) {
res[i] = hsaToNativeJSObject(val.get(i));
if (val instanceof java.lang.Object) {
if (val instanceof java.util.List) {
var res = [];
for (var i = 0; i < val.size(); i++) {
res[i] = hsaToNativeJSObject(val.get(i));
}
return res;
}
return res;
}
if (val instanceof java.util.Map) {
var res = {};
var iter = val.keySet().iterator();
while (iter.hasNext()) {
var key = iter.next();
res[key] = hsaToNativeJSObject(val.get(key));
if (val instanceof java.util.Map) {
var res = {};
var iter = val.keySet().iterator();
while (iter.hasNext()) {
var key = iter.next();
res[key] = hsaToNativeJSObject(val.get(key));
}
return res;
}
var classSimpleName = val.getClass().getSimpleName();
if (classSimpleName == 'Object[]') {
var res = [];
for (var i = 0; i < val.length; i++) {
res[i] = hsaToNativeJSObject(val[i]);
}
return res;
}
return res;
}
return val;
}