Package org.htmlunit.corejs.javascript
Class InterfaceAdapter
- java.lang.Object
-
- org.htmlunit.corejs.javascript.InterfaceAdapter
-
public class InterfaceAdapter extends java.lang.Object
Adapter to use JS function as implementation of Java interfaces with single method or multiple methods with the same signature.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.Object
proxyHelper
-
Constructor Summary
Constructors Modifier Constructor Description private
InterfaceAdapter(ContextFactory cf, java.lang.Class<?> cl)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.Object
create(Context cx, java.lang.Class<?> cl, ScriptableObject object)
Make glue object implementing interface cl that will call the supplied JS function when called.java.lang.Object
invoke(ContextFactory cf, java.lang.Object target, Scriptable topScope, java.lang.Object thisObject, java.lang.reflect.Method method, java.lang.Object[] args)
(package private) java.lang.Object
invokeImpl(Context cx, java.lang.Object target, Scriptable topScope, java.lang.Object thisObject, java.lang.reflect.Method method, java.lang.Object[] args)
private static boolean
isFunctionalMethodCandidate(java.lang.reflect.Method method)
We have to ignore java8 default methods and methods like 'equals', 'hashCode' and 'toString' as it occurs for example in the Comparator interface.
-
-
-
Constructor Detail
-
InterfaceAdapter
private InterfaceAdapter(ContextFactory cf, java.lang.Class<?> cl)
-
-
Method Detail
-
create
static java.lang.Object create(Context cx, java.lang.Class<?> cl, ScriptableObject object)
Make glue object implementing interface cl that will call the supplied JS function when called. Only interfaces were all methods have the same signature is supported.- Returns:
- The glue object or null if
cl
is not interface or has methods with different signatures.
-
isFunctionalMethodCandidate
private static boolean isFunctionalMethodCandidate(java.lang.reflect.Method method)
We have to ignore java8 default methods and methods like 'equals', 'hashCode' and 'toString' as it occurs for example in the Comparator interface.- Returns:
- true, if the function
-
invoke
public java.lang.Object invoke(ContextFactory cf, java.lang.Object target, Scriptable topScope, java.lang.Object thisObject, java.lang.reflect.Method method, java.lang.Object[] args)
-
invokeImpl
java.lang.Object invokeImpl(Context cx, java.lang.Object target, Scriptable topScope, java.lang.Object thisObject, java.lang.reflect.Method method, java.lang.Object[] args)
-
-