public class JavascriptObject extends Object
Modifier and Type | Field and Description |
---|---|
protected netscape.javascript.JSObject |
jsObject |
protected static int |
objectCounter |
protected static Map<netscape.javascript.JSObject,JavascriptObject> |
peerRegistry |
protected IJavascriptRuntime |
runtime |
protected String |
variableName |
Modifier | Constructor and Description |
---|---|
protected |
JavascriptObject() |
protected |
JavascriptObject(String type) |
protected |
JavascriptObject(String type,
netscape.javascript.JSObject jsObject)
Wraps a Javascript JSObject returned from a function.
|
protected |
JavascriptObject(String type,
Object... args) |
protected |
JavascriptObject(String type,
Object[] ary,
boolean isArray) |
protected |
JavascriptObject(String type,
String stringRepresentation)
Builds a new JavascriptObject based on a string representation of the object.
|
Modifier and Type | Method and Description |
---|---|
protected Boolean |
checkBoolean(Object val,
Boolean def)
Checks a returned Javascript value where we expect a boolean but could
get null.
|
protected Integer |
checkInteger(Object val,
Integer def) |
protected Object |
checkUndefined(Object val)
JSObject will return the String "undefined" at certain times, so we
need to make sure we're not getting a value that looks valid, but isn't.
|
netscape.javascript.JSObject |
getJSObject()
Get the underlying object used by the Javascript runtime.
|
protected String |
getNextVariableName()
Gets the name of the next variable which will be the objectname plus a
unique number
|
protected Object |
getProperty(String key)
Get the specified property for this object.
|
protected <T> T |
getProperty(String key,
Class<T> type)
Gets the property and casts to the appropriate type
|
String |
getVariableName()
Gets the name of this variable within the Javascript runtime
|
protected Object |
invokeJavascript(String function)
Invokes a JavaScript function that takes no arguments.
|
protected Object |
invokeJavascript(String function,
Object... args)
Invoke the specified JavaScript function in the JavaScript runtime.
|
protected <T> T |
invokeJavascriptReturnValue(String function,
Class<T> returnType)
Invokes a JavaScript function that takes no arguments.
|
protected <T> T |
invokeJavascriptReturnValue(String function,
Class<T> returnType,
Object... args)
Invoke the specified JavaScript function in the JavaScript runtime.
|
protected boolean |
isMemberDefined(String member) |
protected void |
setProperty(String propertyName,
JavascriptEnum propertyValue)
Sets a property on this Javascript object for which the value is a
JavascriptEnum
The value is set to what is returned by the getEnumValue() method on the JavascriptEnum
|
protected void |
setProperty(String propertyName,
JavascriptObject propertyValue)
Sets a property on this Javascript object for which the value is a
Javascript object itself.
|
protected void |
setProperty(String propertyName,
Object propertyValue)
Sets a property on this Javascript object.
|
protected static Map<netscape.javascript.JSObject,JavascriptObject> peerRegistry
protected IJavascriptRuntime runtime
protected netscape.javascript.JSObject jsObject
protected static int objectCounter
protected String variableName
protected JavascriptObject()
protected JavascriptObject(String type)
type
- The type of underlying Javascript object to createprotected JavascriptObject(String type, String stringRepresentation)
type
- The type of object to buildstringRepresentation
- A string representation of the object, which can be executed by
the Javascript runtime.protected JavascriptObject(String type, Object... args)
type
- The type of underlying Javascript object to create.args
- Any arguments required to create the object.protected JavascriptObject(String type, Object[] ary, boolean isArray)
type
- The type of underlying Javascript object to create.ary
- The array to be passed in.isArray
- boolean to indicate the an array is to be used as the parameter
rather than breaking up into individual parameters.protected JavascriptObject(String type, netscape.javascript.JSObject jsObject)
type
- Type of Javascript object to create.jsObject
- Object returned from Javascript.public netscape.javascript.JSObject getJSObject()
protected final String getNextVariableName()
public String getVariableName()
protected void setProperty(String propertyName, Object propertyValue)
propertyName
- The property namepropertyValue
- The property value.protected void setProperty(String propertyName, JavascriptObject propertyValue)
propertyName
- The name of the property.propertyValue
- The value of the property.protected void setProperty(String propertyName, JavascriptEnum propertyValue)
propertyName
- The name of the property.propertyValue
- The value of the property.protected Object getProperty(String key)
key
- The property nameprotected <T> T getProperty(String key, Class<T> type)
T
- key
- The property nametype
- The property typeprotected Object invokeJavascript(String function)
function
- The function to invokeprotected Object invokeJavascript(String function, Object... args)
function
- The function to invokeargs
- Any arguments to pass to the functionprotected <T> T invokeJavascriptReturnValue(String function, Class<T> returnType)
T
- function
- The function to invokereturnType
- The type of object to returnprotected <T> T invokeJavascriptReturnValue(String function, Class<T> returnType, Object... args)
T
- function
- The function to invokereturnType
- The type of object to returnargs
- Any arguments to pass to the functionprotected boolean isMemberDefined(String member)
protected Object checkUndefined(Object val)
val
- The value from Javascript to be checked.protected Boolean checkBoolean(Object val, Boolean def)
val
- The value from Javascript to be checked.def
- The default return value, which can be null.Copyright © 2016. All Rights Reserved.