Top Description Fields Constructors Methods
com.dlsc.gmapsfx.javascript

public Class JavascriptRuntime

extends Object
implements IJavascriptRuntime
Class Inheritance
All Implemented Interfaces
com.dlsc.gmapsfx.javascript.IJavascriptRuntime
Imports
netscape.javascript.JSObject

Class for interacting with the JavaScript environment. This class is used by the JavaScript objects, but should not need to be used directly for creating or changing maps.
Author
Rob Terpilowski

Field Summary

Modifier and TypeField and Description
public static IWebEngine
protected static IJavascriptRuntime

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public JSObject

Returns:

The underlying JavaScript object that was returned by the script.
execute
(String
The JavaScript command to execute
command
)

Implements com.dlsc.gmapsfx.javascript.IJavascriptRuntime.execute.

References Deprecated JSObject is deprecated or references (maybe indirectly) at least one deprecated element.

Execute the specified command returning a value (if any)

protected String

Returns:

A String representation of the argument.
getArgString
(Object
The object to convert
arg
)

Takes the specified object and converts the argument to a String.

public String

Returns:

A string which can be passed to the JavaScript environment to create a new array.
getArrayConstructor
(String
type The type of JavaScript object array to create
javascriptObjectType
,
Object[]
The array elements
ary
)

Implements com.dlsc.gmapsfx.javascript.IJavascriptRuntime.getArrayConstructor.

Gets an array parameter constructor as a String, which then can be passed to the execute() method.

public String

Returns:

A string which can be passed to the JavaScript environment to invoke the function
getArrayFunction
(String
The function to invoke
function
,
Object[]
The array of arguments to pass to the function.
ary
)

Implements com.dlsc.gmapsfx.javascript.IJavascriptRuntime.getArrayFunction.

Gets an array function as a String, which then can be passed to the execute() method.

public String

Returns:

A string which can be passed to the JavaScript environment to create a new object.
getConstructor
(String
The type of JavaScript object to create
javascriptObjectType
,
Object...
The args of the constructor
args
)

Implements com.dlsc.gmapsfx.javascript.IJavascriptRuntime.getConstructor.

Gets a constructor as a string which then can be passed to the execute().

public String

Returns:

A string which can be passed to the JavaScript environment to invoke the function
getFunction
(String
The variable to invoke the function on.
variable
,
String
The function to invoke
function
,
Object...
Arguments the function requires
args
)

Implements com.dlsc.gmapsfx.javascript.IJavascriptRuntime.getFunction.

Gets a function as a String, which then can be passed to the execute() method.

public String

Returns:

A string which can be passed to the JavaScript environment to invoke the function
getFunction
(String
The function to invoke
function
,
Object...
Arguments the function requires
args
)

Implements com.dlsc.gmapsfx.javascript.IJavascriptRuntime.getFunction.

Gets a function as a String, which then can be passed to the execute() method.

public static IJavascriptRuntime

Returns:

A singleton instance
getInstance
()

Gets a singleton instance of this class, creating one if it doesn't yet exist.

public static void
setDefaultWebEngine(IWebEngine
The underlying WebEngine to use.
e
)

Set the WebEngine that this runtime should use.

public static void
setJavascriptRuntime(IJavascriptRuntime
The runtime to use
testRuntime
)

Sets a Javascript runtime to use.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

engineback to summary
public static IWebEngine engine
runtimeback to summary
protected static IJavascriptRuntime runtime

Constructor Detail

JavascriptRuntimeback to summary
public JavascriptRuntime()

Method Detail

executeback to summary
public JSObject execute(String command)

Implements com.dlsc.gmapsfx.javascript.IJavascriptRuntime.execute.

References Deprecated

JSObject is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

Execute the specified command returning a value (if any)

Parameters
command:String

The JavaScript command to execute

Returns:JSObject

The underlying JavaScript object that was returned by the script.

Annotations
@Override
getArgStringback to summary
protected String getArgString(Object arg)

Takes the specified object and converts the argument to a String.

Parameters
arg:Object

The object to convert

Returns:String

A String representation of the argument.

getArrayConstructorback to summary
public String getArrayConstructor(String javascriptObjectType, Object[] ary)

Implements com.dlsc.gmapsfx.javascript.IJavascriptRuntime.getArrayConstructor.

Gets an array parameter constructor as a String, which then can be passed to the execute() method.

Parameters
javascriptObjectType:String

type The type of JavaScript object array to create

ary:Object[]

The array elements

Returns:String

A string which can be passed to the JavaScript environment to create a new array.

Annotations
@Override
getArrayFunctionback to summary
public String getArrayFunction(String function, Object[] ary)

Implements com.dlsc.gmapsfx.javascript.IJavascriptRuntime.getArrayFunction.

Gets an array function as a String, which then can be passed to the execute() method.

Parameters
function:String

The function to invoke

ary:Object[]

The array of arguments to pass to the function.

Returns:String

A string which can be passed to the JavaScript environment to invoke the function

Annotations
@Override
getConstructorback to summary
public String getConstructor(String javascriptObjectType, Object... args)

Implements com.dlsc.gmapsfx.javascript.IJavascriptRuntime.getConstructor.

Gets a constructor as a string which then can be passed to the execute().

Parameters
javascriptObjectType:String

The type of JavaScript object to create

args:Object[]

The args of the constructor

Returns:String

A string which can be passed to the JavaScript environment to create a new object.

Annotations
@Override
getFunctionback to summary
public String getFunction(String variable, String function, Object... args)

Implements com.dlsc.gmapsfx.javascript.IJavascriptRuntime.getFunction.

Gets a function as a String, which then can be passed to the execute() method.

Parameters
variable:String

The variable to invoke the function on.

function:String

The function to invoke

args:Object[]

Arguments the function requires

Returns:String

A string which can be passed to the JavaScript environment to invoke the function

Annotations
@Override
getFunctionback to summary
public String getFunction(String function, Object... args)

Implements com.dlsc.gmapsfx.javascript.IJavascriptRuntime.getFunction.

Gets a function as a String, which then can be passed to the execute() method.

Parameters
function:String

The function to invoke

args:Object[]

Arguments the function requires

Returns:String

A string which can be passed to the JavaScript environment to invoke the function

Annotations
@Override
getInstanceback to summary
public static IJavascriptRuntime getInstance()

Gets a singleton instance of this class, creating one if it doesn't yet exist.

Returns:IJavascriptRuntime

A singleton instance

setDefaultWebEngineback to summary
public static void setDefaultWebEngine(IWebEngine e)

Set the WebEngine that this runtime should use.

Parameters
e:IWebEngine

The underlying WebEngine to use.

setJavascriptRuntimeback to summary
public static void setJavascriptRuntime(IJavascriptRuntime testRuntime)

Sets a Javascript runtime to use. Should only be used by unit tests to set a mock runtime

Parameters
testRuntime:IJavascriptRuntime

The runtime to use