org.mozilla.javascript

Class JavaAdapter

Implemented Interfaces:
IdFunctionCall

public final class JavaAdapter
extends java.lang.Object
implements IdFunctionCall

Method Summary

static Object
callMethod(ContextFactory factory, Scriptable thisObj, Function f, Object[] args, long argsToWrap)
Utility method which dynamically binds a Context to the current thread, if none already exists.
static Object
convertResult(Object result, Class c)
static byte[]
createAdapterCode(ObjToIntMap functionNames, String adapterName, Class superClass, Class[] interfaces, String scriptClassName)
static Scriptable
createAdapterWrapper(Scriptable obj, Object adapter)
Object
execIdCall(IdFunctionObject f, Context cx, Scriptable scope, Scriptable thisObj, Object[] args)
static Object
getAdapterSelf(Class adapterClass, Object adapter)
static Function
getFunction(Scriptable obj, String functionName)
static void
init(Context cx, Scriptable scope, boolean sealed)
static Object
readAdapterObject(Scriptable self, ObjectInputStream in)
static Scriptable
runScript(Script script)
static void
writeAdapterObject(Object javaObject, ObjectOutputStream out)

Method Details

callMethod

public static Object callMethod(ContextFactory factory,
                                Scriptable thisObj,
                                Function f,
                                Object[] args,
                                long argsToWrap)
Utility method which dynamically binds a Context to the current thread, if none already exists.

convertResult

public static Object convertResult(Object result,
                                   Class c)

createAdapterCode

public static byte[] createAdapterCode(ObjToIntMap functionNames,
                                       String adapterName,
                                       Class superClass,
                                       Class[] interfaces,
                                       String scriptClassName)

createAdapterWrapper

public static Scriptable createAdapterWrapper(Scriptable obj,
                                              Object adapter)

execIdCall

public Object execIdCall(IdFunctionObject f,
                         Context cx,
                         Scriptable scope,
                         Scriptable thisObj,
                         Object[] args)
Specified by:
execIdCall in interface IdFunctionCall

getAdapterSelf

public static Object getAdapterSelf(Class adapterClass,
                                    Object adapter)
            throws NoSuchFieldException,
                   IllegalAccessException

getFunction

public static Function getFunction(Scriptable obj,
                                   String functionName)

init

public static void init(Context cx,
                        Scriptable scope,
                        boolean sealed)

readAdapterObject

public static Object readAdapterObject(Scriptable self,
                                       ObjectInputStream in)
            throws IOException,
                   ClassNotFoundException

runScript

public static Scriptable runScript(Script script)

writeAdapterObject

public static void writeAdapterObject(Object javaObject,
                                      ObjectOutputStream out)
            throws IOException