|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.sgx.j2s.js.JsUtils
public class JsUtils
Utilities that easies defining and accessing native javascript language contructions from java.
Constructor Summary | |
---|---|
JsUtils()
|
Method Summary | |
---|---|
static java.lang.Object |
APPLY(java.lang.Object func,
java.lang.Object context,
java.lang.Object[] params)
|
static java.lang.Object[] |
ARR(java.lang.Object[] arr)
recursively apply NATIVE to each array item (returns an array of native elements or a "native array") |
static Element |
body()
|
static java.lang.Object |
CALL(java.lang.Object obj,
java.lang.String fName,
java.lang.Object[] params)
|
static boolean |
castToBoolean(java.lang.Object o2)
use this method when you need to cast from Object to a primitive type boolean in java code |
static float |
castToFloat(java.lang.Object o)
use this method when you need to cast from Object to a primitive type float in java code |
static int |
castToInt(java.lang.Object o2)
use this method when you need to cast from Object to a primitive type int in java code |
static Document |
document()
|
static java.lang.String |
dump(java.lang.Object o,
boolean onlyType)
|
static java.lang.String |
escapeHTML(java.lang.String s)
|
static void |
firebug()
|
static java.lang.Object |
FUNC(java.lang.Runnable r)
|
static java.lang.Object |
GET(java.lang.Object jsObj,
java.lang.Object key)
|
static Element |
HTML(java.lang.Object obj)
|
static java.lang.Object |
JAVA(java.lang.Object o)
|
static java.lang.Object |
NATIVE_aux(java.lang.String prop,
java.lang.Object val)
|
static java.lang.Object |
NATIVE(java.lang.Object val)
transformation of java Boolean, Integer, Double, Float, Character, Object[], Runnable and YUINativeWrapper to native objects. |
static java.lang.Object |
OBJ(java.lang.Object... props)
creates a native javascript objects. |
static boolean |
objectsAreEquals(java.lang.Object o1,
java.lang.Object o2,
java.util.Comparator<java.lang.Object> valueComparator)
|
static java.lang.String[] |
PROPS(java.lang.Object o)
return the names of an javascript object properties |
static java.lang.Object |
PUT(java.lang.Object jsObj,
java.lang.Object key,
java.lang.Object propValue)
perform the javascript statement jsObj[key]=propValue; |
static java.lang.Object |
runnableToFunc(java.lang.Runnable r)
|
private static java.lang.Object |
withContext(java.lang.Object func,
java.lang.Object context)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public JsUtils()
Method Detail |
---|
public static java.lang.String[] PROPS(java.lang.Object o)
o
- the object to get property names frompublic static java.lang.Object PUT(java.lang.Object jsObj, java.lang.Object key, java.lang.Object propValue)
jsObj[key]=propValue;
public static java.lang.Object GET(java.lang.Object jsObj, java.lang.Object key)
public static java.lang.Object OBJ(java.lang.Object... props)
Object o1 = OBJ(new Object[]{"attr1", 123, "attr2", false}); Object o2 = OBJ(new Object[]{"attr1": 123, "attr2", o1});pass null for creating an empty object. Note: the object literal syntax could be simple if using varargs function: Object o1 = OBJ("attr1", 123, "attr2", false); and I think this is ideally. Unfortunately, j2s varargs do not work when passing native objects as vararg arguments. So if you want to use this shorter syntax, you will have to "javize" your native objects. You can accomplish this in two ways. 1) use NativeWrapper: Object o1 = OBJ("nativeAttr1", NativeWrapper.create(nativeObject)); 2) "javize" the native object poblating the object with necesary java api with JsUtils.JAVA: Object o1 = OBJ("nativeAttr1", JAVA(nativeObject));
public static java.lang.Object NATIVE_aux(java.lang.String prop, java.lang.Object val)
public static java.lang.Object NATIVE(java.lang.Object val)
val
- object to convert to a native equivalent value
public static java.lang.Object[] ARR(java.lang.Object[] arr)
public static java.lang.Object JAVA(java.lang.Object o)
public static java.lang.Object APPLY(java.lang.Object func, java.lang.Object context, java.lang.Object[] params)
func
- a javascript native function objectcontext
- a javascript object used as a context in function evalparams
- params to be passed to the function
public static java.lang.Object CALL(java.lang.Object obj, java.lang.String fName, java.lang.Object[] params)
public static java.lang.Object FUNC(java.lang.Runnable r)
public static java.lang.Object runnableToFunc(java.lang.Runnable r)
private static java.lang.Object withContext(java.lang.Object func, java.lang.Object context)
func
- a js function objectcontext
- a context object
public static int castToInt(java.lang.Object o2)
public static boolean castToBoolean(java.lang.Object o2)
public static float castToFloat(java.lang.Object o)
public static boolean objectsAreEquals(java.lang.Object o1, java.lang.Object o2, java.util.Comparator<java.lang.Object> valueComparator)
public static void firebug()
public static java.lang.String dump(java.lang.Object o, boolean onlyType)
public static Element HTML(java.lang.Object obj)
public static Document document()
public static Element body()
public static java.lang.String escapeHTML(java.lang.String s)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |