Package org.mozilla.javascript

Examples of org.mozilla.javascript.Function.call()


              while(sortIndex < args.length){
                Function func = ((Function)args[sortIndex]);
                boolean ascending = (Boolean)args[sortIndex + 1];
                Object v1;
                try{
                  v1 = func.call(cx, scope, (Scriptable) o1, new Object[]{o1});
                }catch(EcmaError e){
                  v1 = Undefined.instance;
                }
                Object v2;
                try{
View Full Code Here


                }catch(EcmaError e){
                  v1 = Undefined.instance;
                }
                Object v2;
                try{
                  v2 = func.call(cx, scope, (Scriptable) o2, new Object[]{o2});
                }catch(EcmaError e){
                  v2 = Undefined.instance;
                }
                int comparison = CompareValues.instance.compare(v1, v2);
                if (comparison != 0)
View Full Code Here

      Function getContentType = (Function) ScriptableObject.getProperty(bestRep, "output");
      PersistableObject.enableSecurity(true);
      if(response != null && setType) {
        response.setContentType(bestType + "; charset=UTF-8");
      }
      getContentType.call(PersevereContextFactory.getContext(), GlobalData.getGlobalScope(), bestRep, new Object[]{value});
      return;
    }
   
    response.setStatus(406);
    try {
View Full Code Here

          if (oldFunction != null) {
            // create a new function that combines the other two
            ((Query) oldQuery).conditionFunction = new BaseFunction() {
              public Object call(org.mozilla.javascript.Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
                return ScriptRuntime.toBoolean(newFunction.call(cx,  scope, thisObj, args)) ||
                  ScriptRuntime.toBoolean(oldFunction.call(cx, scope, thisObj, args));
              }
            };
          }
        }
        watchSet.put(key, value);
View Full Code Here

          response.getOutputStream().write(((String)body).getBytes("UTF-8"));
        else if (body instanceof Scriptable){
          Function forEach = (Function) ScriptableObject.getProperty((Scriptable) body, "forEach");
          Scriptable global = GlobalData.getGlobalScope();
          final ServletOutputStream outputStream = response.getOutputStream();
          forEach.call(PersevereContextFactory.getContext(), global, (Scriptable) body, new Object[]{
            new PersevereNativeFunction(){
              @Override
              public Object profilableCall(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
                try {
                  outputStream.write(args[0].toString().getBytes("UTF-8"));
View Full Code Here

          Persistable rootQuery = ObjectId.idForObject(source,"").getTarget();
          Function postMethod = (Function) ScriptableObject.getProperty((Persistable) rootQuery, "post");
          if(postMethod instanceof Method)
            ((Method)postMethod).call(PersevereContextFactory.getContext(), GlobalData.getGlobalScope(), rootQuery, new Object[]{newObject.object}, true);
          else
            postMethod.call(PersevereContextFactory.getContext(), GlobalData.getGlobalScope(), rootQuery, new Object[]{newObject.object});
          Method onSave = (Method) ScriptableObject.getProperty(newObject.object, "onSave");
          onSave.call(PersevereContextFactory.getContext(), GlobalData.getGlobalScope(), newObject.object, new Object[0], true);
        }
        newObject.processed = true;
      }
View Full Code Here

    private void notifyReadyStateChangeListener() {
        if (readyStateChangeListener instanceof Function) {
            LOG.fine("notify " + readyState);
            // for now, call with no args.
            Function listenerFunction = (Function)readyStateChangeListener;
            listenerFunction.call(Context.getCurrentContext(), getParentScope(), null, new Object[] {});
        }
    }

    private void doOpen(String method, String urlString, boolean async, String user, String password) {
        // ignoring auth for now.
View Full Code Here

        if (!(fObj instanceof Function)) {
            throw new RuntimeException("Missing test function " + functionName);
        }
        Function function = (Function)fObj;
        try {
            return function.call(rhinoContext, rhinoScope, rhinoScope, args);
        } catch (RhinoException angryRhino) {
            if (expectingException != null && angryRhino instanceof JavaScriptException) {
                JavaScriptException jse = (JavaScriptException)angryRhino;
                Assert.assertEquals(jse.getValue(), expectingException);
                return null;
View Full Code Here

     * @param passedParams the parameters to pass
     * @return the result of the function
     */
    public Object jsCall(String functionName, Object[] passedParams) {
        Function f = (Function)scope.get(functionName, scope);
        Object result = f.call(getContext(), scope, scope, passedParams);
        return result;
    }

    Scriptable getScope() {
        return scope;
View Full Code Here

            Object[] args = new Object[] {
                Context.javaToJS(_path, scope),
                Context.javaToJS(_request, scope),
                Context.javaToJS(_response, scope)
            };
            return function.call(context, scope, scope, args);
        }
       
        /*
         * obtain a javascript function from the given scope
         */
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.