List of utility methods to do Javascript AST Check
int | getJSArrayLength(JSObject jsObject) get JS Array Length Object length = jsObject.getMember("length"); return (length == null) ? 0 : (int) length; |
JSObject | getObject(JSObject parent, Object object) Creates a new JSObject from string representation of a valid JavaScript object. return (JSObject) parent.eval(String.format("(function() { return %s; })()", object)); |
boolean | hasMember(JSObject object, String name) has Member if (object == null) return false; if (name == null) return false; try { return (boolean) object.eval("typeof this." + name + " !== 'undefined'"); } catch (JSException e) { return false; ... |
int[] | toPrimitiveIntArray(JSObject jsObject) to Primitive Int Array int length = getJSArrayLength(jsObject); int[] array = new int[length]; for (int i = 0; i < length; i++) array[i] = (int) jsObject.getSlot(i); return array; |