From bc14a311332ccabcfe0d05ea064d322281232d5b Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Wed, 14 Jan 2015 13:18:35 +0100
Subject: [PATCH] fix handling of java-arrays

---
 hsarjcli/resource/js/functions.js |   37 ++++++++++++++++++++++++-------------
 1 files changed, 24 insertions(+), 13 deletions(-)

diff --git a/hsarjcli/resource/js/functions.js b/hsarjcli/resource/js/functions.js
index 1a5edb9..a1f4fe1 100644
--- a/hsarjcli/resource/js/functions.js
+++ b/hsarjcli/resource/js/functions.js
@@ -1,3 +1,4 @@
+importClass(java.util.Arrays);
 importClass(java.util.ArrayList);
 importClass(java.util.HashMap);
 
@@ -51,21 +52,31 @@
 }
 
 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;
 		}
-		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 val;
 }

--
Gitblit v1.9.0-SNAPSHOT