|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.google.gwt.core.client.JavaScriptObject
org.xwiki.gwt.dom.client.JavaScriptObject
public class JavaScriptObject
Extends GWT JavaScriptObject to add a fromJson method. Usage :
public class MyCar extends JavaScriptObject {
protected MyCar() {}
public final native int getWheelNumber() / *-{ return this.wheelnb; }-* /;
public final native String getColor() / *-{ return this.color; }-* /;
}
MyCar redcar = (MyCar) MyCar.fromJson("{ wheelnb: 4, color: 'red' }");
redcar.getWheelNumber();
redcar.getColor();
JavaScriptObject| Constructor Summary | |
|---|---|
protected |
JavaScriptObject()
Default constructor. |
| Method Summary | |
|---|---|
static JavaScriptObject |
fromJson(java.lang.String input)
Create a JavaScriptObject from a JSON string. |
java.lang.Object |
get(java.lang.String key)
Returns the reference stored in this JavaScript object for the given key. |
com.google.gwt.core.client.JsArrayString |
getKeys()
Returns all the keys set in this JavaScript object, to use with get(String) to iterate
over all properties, without knowing their names. |
java.lang.Object |
remove(java.lang.String key)
Removes a property from this JavaScript object. |
java.lang.Object |
set(java.lang.String key,
java.lang.Object ref)
Saves the given reference in this JavaScript object using the specified key. |
| Methods inherited from class com.google.gwt.core.client.JavaScriptObject |
|---|
cast, createArray, createFunction, createObject, equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
protected JavaScriptObject()
| Method Detail |
|---|
public static final JavaScriptObject fromJson(java.lang.String input)
input - a valid JSON string.
public final java.lang.Object get(java.lang.String key)
key - the key whose value to return
public final java.lang.Object set(java.lang.String key,
java.lang.Object ref)
key - the string used for storing and retrieving the referenceref - the object whose reference will be stored
public final java.lang.Object remove(java.lang.String key)
key - the name of the property to be removed
public final com.google.gwt.core.client.JsArrayString getKeys()
get(String) to iterate
over all properties, without knowing their names.
TODO: refactor this to return a map of (key, value) pairs.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||