java.lang.Object
com.dlsc.gmapsfx.javascript.JavascriptObject
- Direct Known Subclasses:
DirectionsGeocodedWaypoint,DirectionsLeg,DirectionsPane,DirectionsRenderer,DirectionsRequest,DirectionsResult,DirectionsRoute,DirectionsService,DirectionsSteps,DirectionsWaypoint,Distance,DrivingOptions,Duration,ElevationResult,ElevationService,GeocoderAddressComponent,GeocoderComponentRestrictions,GeocoderGeometry,GeocoderRequest,GeocodingResult,GeocodingService,GMapPoint,GoogleMap,InfoWindow,InfoWindowOptions,JavascriptArray,JavascriptFunction,LatLong,LatLongBounds,LocationElevationRequest,MapOptions,MapShape,MapShapeOptions,Marker,MarkerClusterer,MarkerOptions,MaxZoomResult,MaxZoomService,MVCArray,PathElevationRequest,Projection,Size
public class JavascriptObject extends Object
Base class for any Google JavaScript object.
- Author:
- Rob Terpilowski
-
Field Summary
Fields Modifier and Type Field Description protected JSObjectjsObjectprotected static intobjectCounterprotected static Map<JSObject,JavascriptObject>peerRegistryprotected IJavascriptRuntimeruntimeprotected StringvariableName -
Constructor Summary
Constructors Modifier Constructor Description protectedJavascriptObject()protectedJavascriptObject(String type)protectedJavascriptObject(String type, Object... args)protectedJavascriptObject(String type, Object[] ary, boolean isArray)protectedJavascriptObject(String type, String stringRepresentation)Builds a new JavascriptObject based on a string representation of the object.protectedJavascriptObject(String type, JSObject jsObject)Wraps a Javascript JSObject returned from a function. -
Method Summary
Modifier and Type Method Description protected BooleancheckBoolean(Object val, Boolean def)Checks a returned Javascript value where we expect a boolean but could get null.protected IntegercheckInteger(Object val, Integer def)protected ObjectcheckUndefined(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.JSObjectgetJSObject()Get the underlying object used by the Javascript runtime.protected StringgetNextVariableName()Gets the name of the next variable which will be the objectname plus a unique numberprotected ObjectgetProperty(String key)Get the specified property for this object.protected <T> TgetProperty(String key, Class<T> type)Gets the property and casts to the appropriate typeStringgetVariableName()Gets the name of this variable within the Javascript runtimeprotected ObjectinvokeJavascript(String function)Invokes a JavaScript function that takes no arguments.protected ObjectinvokeJavascript(String function, Object... args)Invoke the specified JavaScript function in the JavaScript runtime.protected <T> TinvokeJavascriptReturnValue(String function, Class<T> returnType)Invokes a JavaScript function that takes no arguments.protected <T> TinvokeJavascriptReturnValue(String function, Class<T> returnType, Object... args)Invoke the specified JavaScript function in the JavaScript runtime.protected booleanisMemberDefined(String member)protected voidsetProperty(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 JavascriptEnumprotected voidsetProperty(String propertyName, JavascriptObject propertyValue)Sets a property on this Javascript object for which the value is a Javascript object itself.protected voidsetProperty(String propertyName, Object propertyValue)Sets a property on this Javascript object.
-
Field Details
-
peerRegistry
-
runtime
-
jsObject
-
objectCounter
protected static int objectCounter -
variableName
-
-
Constructor Details
-
JavascriptObject
protected JavascriptObject() -
JavascriptObject
- Parameters:
type- The type of underlying Javascript object to create
-
JavascriptObject
Builds a new JavascriptObject based on a string representation of the object. This is useful when constructing functions as objects- Parameters:
type- The type of object to buildstringRepresentation- A string representation of the object, which can be executed by the Javascript runtime.
-
JavascriptObject
- Parameters:
type- The type of underlying Javascript object to create.args- Any arguments required to create the object.
-
JavascriptObject
- Parameters:
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.
-
JavascriptObject
Wraps a Javascript JSObject returned from a function.- Parameters:
type- Type of Javascript object to create.jsObject- Object returned from Javascript.
-
-
Method Details
-
getJSObject
Get the underlying object used by the Javascript runtime.- Returns:
- The underlying Javascript object
-
getNextVariableName
Gets the name of the next variable which will be the objectname plus a unique number- Returns:
- The name of the next variable to create
-
getVariableName
Gets the name of this variable within the Javascript runtime- Returns:
- The name of this variable.
-
setProperty
Sets a property on this Javascript object.- Parameters:
propertyName- The property namepropertyValue- The property value.
-
setProperty
Sets a property on this Javascript object for which the value is a Javascript object itself.- Parameters:
propertyName- The name of the property.propertyValue- The value of the property.
-
setProperty
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- Parameters:
propertyName- The name of the property.propertyValue- The value of the property.
-
getProperty
Get the specified property for this object.- Parameters:
key- The property name- Returns:
- The value of the property
-
getProperty
Gets the property and casts to the appropriate type- Type Parameters:
T-- Parameters:
key- The property nametype- The property type- Returns:
- The value of the property
-
invokeJavascript
Invokes a JavaScript function that takes no arguments.- Parameters:
function- The function to invoke- Returns:
- The return value of the function call.
-
invokeJavascript
Invoke the specified JavaScript function in the JavaScript runtime.- Parameters:
function- The function to invokeargs- Any arguments to pass to the function- Returns:
- The result of the function.
-
invokeJavascriptReturnValue
Invokes a JavaScript function that takes no arguments.- Type Parameters:
T-- Parameters:
function- The function to invokereturnType- The type of object to return- Returns:
- The result of the function.
-
invokeJavascriptReturnValue
Invoke the specified JavaScript function in the JavaScript runtime.- Type Parameters:
T-- Parameters:
function- The function to invokereturnType- The type of object to returnargs- Any arguments to pass to the function- Returns:
- The result of the function.
-
isMemberDefined
-
checkUndefined
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.- Parameters:
val- The value from Javascript to be checked.- Returns:
- Either null or the value passed in.
-
checkBoolean
Checks a returned Javascript value where we expect a boolean but could get null.- Parameters:
val- The value from Javascript to be checked.def- The default return value, which can be null.- Returns:
- The actual value, or if null, returns false.
-
checkInteger
-