svn commit r17591 - trunk/wsf/javascript/rhino/message_receiver/src/org/wso2/javascript/rhino

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit r17591 - trunk/wsf/javascript/rhino/message_receiver/src/org/wso2/javascript/rhino

Keith Chapman-4
Author: keith
Date: Thu May 29 05:03:58 2008
New Revision: 17591
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=17591

Log:
Fixing Mashup-740


Modified:
   trunk/wsf/javascript/rhino/message_receiver/src/org/wso2/javascript/rhino/JSToOMConverter.java

Modified: trunk/wsf/javascript/rhino/message_receiver/src/org/wso2/javascript/rhino/JSToOMConverter.java
URL: http://wso2.org/svn/browse/wso2/trunk/wsf/javascript/rhino/message_receiver/src/org/wso2/javascript/rhino/JSToOMConverter.java?rev=17591&r1=17590&r2=17591&view=diff
==============================================================================
--- trunk/wsf/javascript/rhino/message_receiver/src/org/wso2/javascript/rhino/JSToOMConverter.java (original)
+++ trunk/wsf/javascript/rhino/message_receiver/src/org/wso2/javascript/rhino/JSToOMConverter.java Thu May 29 05:03:58 2008
@@ -42,6 +42,7 @@
 import org.apache.axis2.databinding.utils.ConverterUtil;
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.EvaluatorException;
+import org.mozilla.javascript.NativeArray;
 import org.wso2.javascript.xmlimpl.QName;
 
 import java.math.BigDecimal;
@@ -52,6 +53,35 @@
 public class JSToOMConverter {
 
     public static String convertToString(Object jsObject) {
+        if (jsObject instanceof NativeArray) {
+            NativeArray nativeArray = (NativeArray) jsObject;
+            Object[] objects = nativeArray.getAllIds();
+            String returnString = "";
+            // Using a flag here to know weather the iterator is in the first position cause we
+            // want to separate the values in the array using a ,
+            boolean first = true;
+            for (int i = 0; i < objects.length; i++) {
+                Object object = objects[i];
+                Object value;
+                if (object instanceof String) {
+                    String property = (String) object;
+                    if ("length".equals(property)) {
+                        continue;
+                    }
+                    value = nativeArray.get(property, nativeArray);
+                } else {
+                    Integer property = (Integer) object;
+                    value = nativeArray.get(property.intValue(), nativeArray);
+                }
+                if (first) {
+                    returnString += value;
+                    first = false;
+                } else {
+                    returnString += ", " + value;
+                }
+            }
+            return returnString;
+        }
         return jsObject.toString();
     }
 

_______________________________________________
Wsf-javascript-dev mailing list
[hidden email]
http://wso2.org/cgi-bin/mailman/listinfo/wsf-javascript-dev