- All Known Implementing Classes:
JavascriptRuntime
public interface IJavascriptRuntime
An interface for interacting with a JavaScript environment which includes
methods for building strings that represent functions and constructors as
well as providing a means to execute commands.
- Author:
- Rob Terpilowski
-
Method Summary
Modifier and Type Method Description JSObjectexecute(String command)Execute the specified command returning a value (if any)StringgetArrayConstructor(String javascriptObjectType, Object[] ary)Gets an array parameter constructor as a String, which then can be passed to the execute() method.StringgetArrayFunction(String function, Object[] ary)Gets an array function as a String, which then can be passed to the execute() method.StringgetConstructor(String javascriptObjectType, Object... args)Gets a constructor as a string which then can be passed to the execute().StringgetFunction(String function, Object... args)Gets a function as a String, which then can be passed to the execute() method.StringgetFunction(String variable, String function, Object... args)Gets a function as a String, which then can be passed to the execute() method.
-
Method Details
-
execute
Execute the specified command returning a value (if any)- Parameters:
command- The JavaScript command to execute- Returns:
- The underlying JavaScript object that was returned by the script.
-
getConstructor
Gets a constructor as a string which then can be passed to the execute().- Parameters:
javascriptObjectType- The type of JavaScript object to createargs- The args of the constructor- Returns:
- A string which can be passed to the JavaScript environment to create a new object.
-
getArrayConstructor
Gets an array parameter constructor as a String, which then can be passed to the execute() method. Note, this is where the parameter to the constructor is an array, rather than the varargs which are broken down into separate parameters.- Parameters:
javascriptObjectType- type The type of JavaScript object array to createary- The array elements- Returns:
- A string which can be passed to the JavaScript environment to create a new array.
-
getFunction
Gets a function as a String, which then can be passed to the execute() method.- Parameters:
variable- The variable to invoke the function on.function- The function to invokeargs- Arguments the function requires- Returns:
- A string which can be passed to the JavaScript environment to invoke the function
-
getFunction
Gets a function as a String, which then can be passed to the execute() method.- Parameters:
function- The function to invokeargs- Arguments the function requires- Returns:
- A string which can be passed to the JavaScript environment to invoke the function
-
getArrayFunction
Gets an array function as a String, which then can be passed to the execute() method.- Parameters:
function- The function to invokeary- The array of arguments to pass to the function.- Returns:
- A string which can be passed to the JavaScript environment to invoke the function
-