@Override public Object apply(Object input) { // ideally we need a close() function to discard the context once it is not used anymore Context cx = Context.getCurrentContext(); if (cx == null) { cx = contextFactory.enterContext(); } final Object res = fn.call(cx, scope, scope, new Object[]{input}); return res != null ? Context.toObject(res, scope) : null; } };
@Override public String apply(Object input) { // ideally we need a close() function to discard the context once it is not used anymore Context cx = Context.getCurrentContext(); if (cx == null) { cx = contextFactory.enterContext(); } final Object res = fn.call(cx, scope, scope, new Object[]{input}); return res != null ? Context.toString(res) : null; } };
@Override public double apply(Object[] args) { // ideally we need a close() function to discard the context once it is not used anymore Context cx = Context.getCurrentContext(); if (cx == null) { cx = contextFactory.enterContext(); } return Context.toNumber(fn.call(cx, scope, scope, args)); } };
public Object exec(List arguments) throws TemplateModelException { Context cx = Context.getCurrentContext(); Object[] args = arguments.toArray(); BeansWrapper wrapper = getWrapper(); for (int i = 0; i < args.length; i++) { args[i] = wrapper.unwrap((TemplateModel) args[i]); } return wrapper.wrap(((Function) getScriptable()).call(cx, ScriptableObject.getTopLevelScope(fnThis), fnThis, args)); } }
private static RegExpImpl getImpl() { Context cx = Context.getCurrentContext(); return (RegExpImpl) ScriptRuntime.getRegExpProxy(cx); }
/** * @deprecated NativeJavaPackage is an internal class, do not use * it directly. */ public NativeJavaPackage(String packageName) { this(false, packageName, Context.getCurrentContext().getApplicationClassLoader()); }
/** * Makes sure the context is properly initialized. */ private void initContext() { if (Context.getCurrentContext() == null) { Context.enter(); } }
/** * @deprecated NativeJavaPackage is an internal class, do not use * it directly. */ @Deprecated public NativeJavaPackage(String packageName) { this(false, packageName, Context.getCurrentContext().getApplicationClassLoader()); }
/** * Returns representation of the [[ThrowTypeError]] object. * See ECMA 5 spec, 13.2.3 * * @deprecated {@link #typeErrorThrower(Context)} */ @Deprecated public static BaseFunction typeErrorThrower() { return typeErrorThrower(Context.getCurrentContext()); }
private static RegExpImpl getImpl() { Context cx = Context.getCurrentContext(); return (RegExpImpl) ScriptRuntime.getRegExpProxy(cx); }
/** * @see #isJavaPrimitiveWrap() */ public final void setJavaPrimitiveWrap(boolean value) { Context cx = Context.getCurrentContext(); if (cx != null && cx.isSealed()) { Context.onSealedMutation(); } javaPrimitiveWrap = value; }
private Object toScriptable( ScriptableDelegate[] list ) { Object[] delegates = new Object[ list.length ]; for (int i = 0; i < delegates.length; i++) { delegates[i] = toScriptable( list[i] ); } return Context.getCurrentContext().newArray( this, delegates ); }
void initialize( JavaScriptEngine parent, ScriptableDelegate scriptable ) throws JavaScriptException, NotAFunctionException, PropertyException, SAXException { super.initialize( parent, scriptable ); _document = (Document) parent; _style = (Style) Context.getCurrentContext().newObject( this, "Style" ); }
/** * @see #isJavaPrimitiveWrap() */ public final void setJavaPrimitiveWrap(boolean value) { Context cx = Context.getCurrentContext(); if (cx != null && cx.isSealed()) { Context.onSealedMutation(); } javaPrimitiveWrap = value; }
public Scriptable getPeoplePaging(String filter, ScriptPagingDetails pagingRequest, String sortBy, Boolean sortAsc) { List<PersonInfo> persons = getPeopleImpl(filter, pagingRequest, sortBy, sortAsc); Object[] peopleRefs = new Object[persons.size()]; for (int i = 0; i < peopleRefs.length; i++) { peopleRefs[i] = persons.get(i).getNodeRef(); } return Context.getCurrentContext().newArray(getScope(), peopleRefs); }
/** * @return Array of settable permissions for this Node */ public Scriptable getSettablePermissions() { Set<String> permissions = this.services.getPermissionService().getSettablePermissions(getNodeRef()); Object[] result = permissions.toArray(new Object[0]); return Context.getCurrentContext().newArray(this.scope, result); }
@Override public double apply(Object[] args) { // ideally we need a close() function to discard the context once it is not used anymore Context cx = Context.getCurrentContext(); if (cx == null) { cx = contextFactory.enterContext(); } return Context.toNumber(fn.call(cx, scope, scope, args)); } };
static ElementArray newElementArray( Scriptable parent ) { try { return (ElementArray) Context.getCurrentContext().newObject( parent, "ElementArray" ); } catch (PropertyException e) { throw new RhinoException( e ); } catch (NotAFunctionException e) { throw new RhinoException( e ); } catch (JavaScriptException e) { throw new RhinoException( e ); } }
public Scriptable jsGet_frames() throws SAXException, PropertyException, JavaScriptException, NotAFunctionException { if (_frames == null) { WebResponse.Scriptable scriptables[] = getDelegate().getFrames(); Window[] frames = new Window[ scriptables.length ]; for (int i = 0; i < frames.length; i++) { frames[ i ] = (Window) toScriptable( scriptables[ i ] ); } _frames = (ElementArray) Context.getCurrentContext().newObject( this, "ElementArray" ); _frames.initialize( frames ); } return _frames; }
private void initializeControls() throws PropertyException, NotAFunctionException, JavaScriptException { ScriptableDelegate scriptables[] = getDelegate().getElementDelegates(); Control[] controls = new Control[ scriptables.length ]; for (int i = 0; i < controls.length; i++) { controls[ i ] = (Control) toScriptable( scriptables[ i ] ); } _controls = (ElementArray) Context.getCurrentContext().newObject( this, "ElementArray" ); _controls.initialize( controls ); }