public StringBuffer append(String s) { if (s == null) s= "null"; ScriptHelper.put("s", s, this); ScriptHelper.eval("this.buffer.push(s)", this); return this; }
public static boolean isProxyClass(Class class1) { ScriptHelper.put("class1", class1, null); return ScriptHelper.evalBoolean("class1 && class1.$$$nativeClass___java_lang_Object && class1.$$$nativeClass___java_lang_Object.classname.startsWith(\"ProxyOf_\")", null); }
/** * Decodes a application/x-www-form-urlencoded string using a specific encoding scheme. * * @param enc must be 'UTF-8' */ public static String decode(String s, String enc) { ScriptHelper.put("s", s, null); s= s.replaceAll("\\+", " "); s= (String) ScriptHelper.eval("decodeURIComponent(s)", null); return s; }
/** * Returns the character at the specified index. */ public char charAt(int index) { if (index < 0 || index >= length()) { throw new IndexOutOfBoundsException(); } ScriptHelper.put("index", index, this); return ScriptHelper.evalChar("this.charCodeAt(index)", this); }
/** * Returns the index within this string of the last occurrence of the specified character. */ public int lastIndexOf(int ch) { ScriptHelper.put("str", String.valueOf((char) ch), this); return ScriptHelper.evalInt("this.lastIndexOf(str)", this); }
/** * Returns the index within this string of the first occurrence of the specified character. */ public int indexOf(int ch) { ScriptHelper.put("ch", ch, this); return ScriptHelper.evalInt("this.indexOf(String.fromCharCode(ch), 0)", this); }
private static int getMatchIndex(Object matchObject) { ScriptHelper.put("matchObject", matchObject, null); return ScriptHelper.evalInt("matchObject.index", null); };
public int lastIndexOf(String str) { ScriptHelper.put("str", str, this); return ScriptHelper.evalInt("this.lastIndexOf(str)", this); }
public static long round(double a) { ScriptHelper.put("a", a, null); return ScriptHelper.evalInt("Math.round(a)", null); }
/** * Returns the absolute value of a long value. */ public static long abs(long a) { ScriptHelper.put("a", a, null); return ScriptHelper.evalLong("Math.abs(a)", null); }
public String getParameter(String aKey) { ScriptHelper.put("aKey", aKey, this); return (String) ScriptHelper.eval("getQuerystring(aKey)", this); }
/** * Returns the value to which the specified key is mapped in this identity hash map, * or null if the map contains no mapping for this key. */ public V get(Object key) { ScriptHelper.put("key", getRealKey(key), null); Object value= ScriptHelper.eval("this.obj.get (key)", null); return (V) value; }
public long requestAnimationFrame(Runnable aRunnable) { Runnable runnableForDebugging= wrapRunnableForDebugging(aRunnable); ScriptHelper.put("ra", runnableForDebugging, this); return ScriptHelper.evalLong("requestAnimationFrame(function(time) {ra.$run$void();})", this); }
public void onHashChange(Runnable aRunnable) { Runnable runnableForDebugging= wrapRunnableForDebugging(aRunnable); ScriptHelper.put("ra", runnableForDebugging, this); ScriptHelper.evalNoResult("window.onhashchange= function() {ra.$run$void();}", this); }
public <T> void save(String aKey, T aValue) { String serializedValue= ServiceLocator.getInstance().getSerializationService().serialize(aValue); ScriptHelper.put("key", aKey, this); ScriptHelper.put("serialized", serializedValue, this); ScriptHelper.eval("localStorage.setItem(key, serialized)", this); } }
public <T> T load(String aKey) { ScriptHelper.put("key", aKey, this); String serializedValue= (String) ScriptHelper.eval("localStorage.getItem(key)", this); if (serializedValue != null && !serializedValue.isEmpty()) return (T) ServiceLocator.getInstance().getSerializationService().deserialize(serializedValue); else return null; }