public interface JSScriptable
extends org.mozilla.javascript.Scriptable
Modifier and Type | Method and Description |
---|---|
default boolean |
addExternalFunction(CachedMethodKey key,
java.lang.String methodName,
ScriptWrapper wrapper)
Add an external function.
|
org.mozilla.javascript.Context |
createJSContext(java.lang.ClassLoader loader)
Create the Javascript context associated with this Scriptable.
|
default void |
defineBuiltIntFunctions()
Define the BuiltIntFunctions.
|
default void |
defineExternalFunctions()
Define the external functions.
|
default void |
defineFunctionProperties()
Define the Function Properties.
|
default java.lang.Object |
execute(java.lang.String methodName,
java.lang.Object... args)
Execute a method, used for methods applied on a property in the script.
|
default java.lang.Class<?>[] |
getDefinedClasses()
Return the array of classes to be defined in the context of the wrapper.
|
default java.lang.Class<? extends org.mozilla.javascript.ScriptableObject> |
getExecutorClass()
Return the executor class, used for methods applied on properties in the script.
|
default ScriptableExecutor |
getExecutorInstance()
Return the executor.
|
default java.util.Map<java.lang.String,ScriptableExecutor> |
getExecutorInstancesMap()
Return the executors Map.
|
default java.util.Map<java.lang.String,java.lang.Class<? extends org.mozilla.javascript.ScriptableObject>> |
getExecutorsMap()
Return the executors map, used for methods applied on properties in the script.
|
default java.lang.String[] |
getFunctionProperties()
Return the array of function properties which can be called by the Javascript script.
|
org.mozilla.javascript.Context |
getJSContext()
Return Javascript context.
|
default java.lang.String[] |
getObjectNames()
Return the object properties names as it will be found in the Javascript source.
|
default void |
jsConstructor()
This Method jsConstructor is mandatory to be able to construct the Object as a javascript object.
|
void |
setContext(ScriptContext context)
Set the context of the script wrapper.
|
void |
setDefinedClasses(java.lang.Class<?>... classes)
Set an array of classes to be defined in the contxt of the wrapper.
|
default void jsConstructor()
void setContext(ScriptContext context)
context
- org.mozilla.javascript.Context getJSContext()
org.mozilla.javascript.Context createJSContext(java.lang.ClassLoader loader)
loader
- the ClassLoadervoid setDefinedClasses(java.lang.Class<?>... classes)
classes
- the classesdefault java.lang.Class<?>[] getDefinedClasses()
default java.lang.String[] getFunctionProperties()
public String[] getFunctionProperties() { String[] array = {"print}; return array; }Then you should have an associated "print " method in your JSScriptable class, for example:
public void print(String arg) { context.echo(arg); }And for example the following script will trigger the "echo" method of the context:
execute: function() { print("toto"); }
default void defineBuiltIntFunctions()
default void defineFunctionProperties()
default void defineExternalFunctions()
default boolean addExternalFunction(CachedMethodKey key, java.lang.String methodName, ScriptWrapper wrapper)
key
- the function keymethodName
- the method name to call in the ScriptWrapperwrapper
- the associated ScriptWrapperdefault java.lang.String[] getObjectNames()
default java.lang.Class<? extends org.mozilla.javascript.ScriptableObject> getExecutorClass()
default java.util.Map<java.lang.String,java.lang.Class<? extends org.mozilla.javascript.ScriptableObject>> getExecutorsMap()
default ScriptableExecutor getExecutorInstance()
default java.util.Map<java.lang.String,ScriptableExecutor> getExecutorInstancesMap()
default java.lang.Object execute(java.lang.String methodName, java.lang.Object... args)
methodName
- the methodName method nameargs
- the argumentsCopyright © 2019-2024 Herve Girod. All Rights Reserved. Documentation and source under the BSD licence