Bug 992359 - b. Add skeletal NativeJSObject.toBundle; r=blassey

This commit is contained in:
Jim Chen
2014-05-12 12:50:46 -04:00
parent 36c1c7bcb9
commit c45c40f38b
3 changed files with 153 additions and 2 deletions

View File

@@ -7,6 +7,8 @@ package org.mozilla.gecko.util;
import org.mozilla.gecko.mozglue.JNITarget;
import android.os.Bundle;
/**
* NativeJSObject is a wrapper around the SpiderMonkey JSAPI to make it possible to
* access Javascript objects in Java.
@@ -61,6 +63,40 @@ public class NativeJSObject
*/
public native boolean optBoolean(String name, boolean fallback);
/**
* Returns the value of an object property as a Bundle.
*
* @param name
* Property name
* @throws IllegalArgumentException
* If the property does not exist or if its type does not match the return type
* @throws NullPointerException
* If name is null or if this JS object has been disposed
* @throws IllegalThreadStateException
* If not called on the thread this object is attached to
* @throws UnsupportedOperationException
* If an internal JSAPI call failed
*/
public native Bundle getBundle(String name);
/**
* Returns the value of an object property as a Bundle.
*
* @param name
* Property name
* @param fallback
* Value to return if property does not exist
* @throws IllegalArgumentException
* If the property exists and its type does not match the return type
* @throws NullPointerException
* If name is null or if this JS object has been disposed
* @throws IllegalThreadStateException
* If not called on the thread this object is attached to
* @throws UnsupportedOperationException
* If an internal JSAPI call failed
*/
public native Bundle optBundle(String name, Bundle fallback);
/**
* Returns the value of a double property.
*
@@ -211,6 +247,18 @@ public class NativeJSObject
*/
public native boolean has(String name);
/**
* Returns the Bundle representation of this object.
*
* @throws NullPointerException
* If this JS object has been disposed
* @throws IllegalThreadStateException
* If not called on the thread this object is attached to
* @throws UnsupportedOperationException
* If an internal JSAPI call failed
*/
public native Bundle toBundle();
/**
* Returns the JSON representation of this object.
*