Here you can find the source of javaToJS(Object o, Scriptable scope)
Parameter | Description |
---|---|
o | Any Java object. |
scope | The scope within which the conversion is made. |
static Object javaToJS(Object o, Scriptable scope)
//package com.java2s; //License from project: Open Source License import org.mozilla.javascript.Context; import org.mozilla.javascript.NativeArray; import org.mozilla.javascript.Scriptable; public class Main { /**// ww w . j a v a 2 s. c o m * Convert a Java object to a JavaScript one. This is basically like {@link Context#javaToJS} except that we convert arrays to real JavaScript arrays instead of {@link NativeJavaArray} instances. * This is done in order to satisfy lint implementation of {@code Array.isArray()}. * @param o Any Java object. * @param scope The scope within which the conversion is made. * @return An equivalent JavaScript object. */ static Object javaToJS(Object o, Scriptable scope) { Class<?> cls = o.getClass(); if (cls.isArray()) { return new NativeArray((Object[]) o); } else { return Context.javaToJS(o, scope); } } }