/** * {@inheritDoc} */ @Override public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) { return wrapped_.call(cx, scope, thisObj, args); }
/** * {@inheritDoc} */ @Override public Scriptable getParentScope() { return wrapped_.getParentScope(); }
/** * {@inheritDoc} */ @Override public Scriptable construct(final Context cx, final Scriptable scope, final Object[] args) { return wrapped_.construct(cx, scope, args); }
if (converterObject instanceof Function) { Function f = (Function)converterObject; value = f.call(Context.getContext(), f.getParentScope(), this, ScriptRuntime.emptyArgs); } else {
/** * {@inheritDoc} */ @Override public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) throws JavaScriptException { // the js object to which this event is attached has to be the scope final SimpleScriptable jsObj = node_.getScriptableObject(); // compile "just in time" if (realFunction_ == null) { realFunction_ = cx.compileFunction(jsObj, jsSnippet_, eventName_ + " event for " + node_ + " in " + node_.getPage().getUrl(), 0, null); realFunction_.setParentScope(jsObj); } return realFunction_.call(cx, scope, thisObj, args); }
/** * {@inheritDoc} */ @Override public void put(final int index, final Scriptable start, final Object value) { wrapped_.put(index, wrapped_, value); }
/** * {@inheritDoc} */ @Override public String getClassName() { return wrapped_.getClassName(); }
/** * {@inheritDoc} */ @Override public void delete(final int index) { wrapped_.delete(index); }
/** * Performs the download and calls the callback method. */ @Override public void run() { final Scriptable scope = callback_.getParentScope(); final WebRequest request = new WebRequest(url_); try { final WebResponse webResponse = client_.loadWebResponse(request); final String content = webResponse.getContentAsString(); if (LOG.isDebugEnabled()) { LOG.debug("Downloaded content: " + StringUtils.abbreviate(content, 512)); } final Object[] args = new Object[] {content}; final ContextFactory cf = ((JavaScriptEngine) client_.getJavaScriptEngine()).getContextFactory(); cf.call(cx -> { callback_.call(cx, scope, scope, args); return null; }); } catch (final IOException e) { LOG.error("Behavior #default#download: Cannot download " + url_, e); } } }
/** * {@inheritDoc} */ @Override public Object call(final Context cx, final Scriptable scope, final Scriptable thisObj, final Object[] args) throws JavaScriptException { // the js object to which this event is attached has to be the scope final SimpleScriptable jsObj = node_.getScriptableObject(); // compile "just in time" if (realFunction_ == null) { realFunction_ = cx.compileFunction(jsObj, jsSnippet_, eventName_ + " event for " + node_ + " in " + node_.getPage().getUrl(), 0, null); realFunction_.setParentScope(jsObj); } return realFunction_.call(cx, scope, thisObj, args); }
/** * {@inheritDoc} */ @Override public void put(final String name, final Scriptable start, final Object value) { wrapped_.put(name, wrapped_, value); }
/** * {@inheritDoc} */ @Override public String getClassName() { return wrapped_.getClassName(); }
/** * {@inheritDoc} */ @Override public void delete(final String name) { wrapped_.delete(name); }
public Object run(final Context cx) { callback_.call(cx, scope, scope, args); return null; } };
/** * Performs the download and calls the callback method. */ @Override public void run() { final Scriptable scope = callback_.getParentScope(); final WebRequest request = new WebRequest(url_); try { final WebResponse webResponse = client_.loadWebResponse(request); final String content = webResponse.getContentAsString(); if (LOG.isDebugEnabled()) { LOG.debug("Downloaded content: " + StringUtils.abbreviate(content, 512)); } final Object[] args = new Object[] {content}; final ContextFactory cf = ((JavaScriptEngine) client_.getJavaScriptEngine()).getContextFactory(); cf.call(cx -> { callback_.call(cx, scope, scope, args); return null; }); } catch (final IOException e) { if (LOG.isErrorEnabled()) { LOG.error("Behavior #default#download: Cannot download " + url_, e); } } } }
/** * {@inheritDoc} */ @Override public Scriptable getParentScope() { return wrapped_.getParentScope(); }
/** * {@inheritDoc} */ @Override public Scriptable construct(final Context cx, final Scriptable scope, final Object[] args) { return wrapped_.construct(cx, scope, args); }
/** * {@inheritDoc} */ @Override public void put(final String name, final Scriptable start, final Object value) { wrapped_.put(name, wrapped_, value); }
/** * Decompile a JavaScript Function. * <p> * Decompiles a previously compiled JavaScript function object to * canonical source. * <p> * Returns function body of '[native code]' if no decompilation * information is available. * * @param fun the JavaScript function to decompile * @param indent the number of spaces to indent the result * @return a string representing the function source */ public final String decompileFunction(Function fun, int indent) { if (fun instanceof BaseFunction) return ((BaseFunction)fun).decompile(indent, 0); else return "function " + fun.getClassName() + "() {\n\t[native code]\n}\n"; }
/** * {@inheritDoc} */ @Override public void delete(final String name) { wrapped_.delete(name); }