/** * Attempts to find the next subsequence of the input sequence that matches the pattern. */ public boolean find() { ScriptHelper.eval("this.$$$matchResult___java_lang_Object = this.$$$nativeRegExp___java_lang_Object.exec(this.$$$input___java_lang_CharSequence)", this); if (matchResult == null) return false; ScriptHelper.eval("this.$$$nativeRegExp___java_lang_Object.lastIndex = this.$$$matchResult___java_lang_Object.index + this.$$$matchResult___java_lang_Object[0].length", this); return true; }
public void printInnerStackTrace(PrintWriter printWriter) { if (ScriptHelper.evalBoolean("this.stack", this)) { String stack= (String) ScriptHelper.eval("this.stack", this); printWriter.print(stack); } }
/** * Fills in the execution stack trace. */ public Throwable fillInStackTrace() { stackTrace= (String) ScriptHelper.eval("stackTrace.toString()", this); return this; }
public StringBuffer append(String s) { if (s == null) s= "null"; ScriptHelper.put("s", s, this); ScriptHelper.eval("this.buffer.push(s)", this); return this; }
/** * 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; }
public String getParameter(String aKey) { ScriptHelper.put("aKey", aKey, this); return (String) ScriptHelper.eval("getQuerystring(aKey)", this); }
/** * Returns a String object representing this Long's value. */ public String toString() { // Duplicate code to String#valueOf(long) ScriptHelper.put("l", value, this); return (String) ScriptHelper.eval("String(l)", this); }
/** * Returns a String object representing this Character's value. */ public String toString() { // Duplicate code to String#valueOf(char) ScriptHelper.put("c", value, this); return (String) ScriptHelper.eval("String.fromCharCode(c)", this); } public static char toUpperCase(char c)
/** * 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 String replace(CharSequence target, CharSequence replacement) { ScriptHelper.put("string", target, this); ScriptHelper.put("string2", replacement, this); return (String) ScriptHelper.eval("this.replaceAll(string, string2)", this); }
public static Object getProperty(Object obj, String propertyName) { ScriptHelper.put("obj", obj, null); ScriptHelper.put("propertyName", propertyName, null); return ScriptHelper.eval("obj[propertyName]", null); }
public final static String getTemplatePart(String content, String id) { ScriptHelper.put("content", content, null); ScriptHelper.put("id", id, null); String result= (String) ScriptHelper.eval("getTemplatePart(content, id)", null); return result; } }
public static void set(Object array, int i, Object v) { ScriptHelper.put("anArray", array, null); ScriptHelper.put("i", i, null); ScriptHelper.put("aValue", v, null); ScriptHelper.eval("anArray[i]=v;", null); //TODO revisar }
/** * Associates the specified value with the specified key in this map. */ public V put(K key, V value) { ScriptHelper.put("key", getRealKey(key), null); ScriptHelper.put("value", value, null); Object oldValue= ScriptHelper.eval("this.obj.put (key, value)", null); return (V) oldValue; }
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; }
public StringBuilder insert(int offset, String str) { consolidate(); ScriptHelper.put("offset", offset, this); ScriptHelper.put("str", str, this); ScriptHelper.eval("var os = offset; s = this.buffer[0]; this.buffer[0] = s.substring(0, os) + str + s.substring(os)", this); return this; }
public WebServiceLocator() { Object document= null; document= ScriptHelper.eval("window.document", this); clientSideEnabled= document != null; ServiceLocator.getInstance().setParametersHandler(new BrowserParametersHandler()); init(); }
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 Object invokeWithArguments(Object... args) throws Throwable { ScriptHelper.put("type", lookup.getSpecialCaller(), this); ScriptHelper.put("args", args, this); ScriptHelper.put("proxy", x, this); ScriptHelper.put("method", lookup.getMethod(), this); Object o= ScriptHelper.eval("type.$$$nativeClass___java_lang_Object.$$members[method.$$$signature___java_lang_String].apply(proxy, args)", this); return o; } }