Package org.mozilla.javascript

Examples of org.mozilla.javascript.Function


    }
    return f;
  }
 
  public float tf(int arg0) {
    Function func = otherMethods[M_TF_I];
    if (func == null) return super.tf(arg0);
    Object[] args = new Object[]{new Integer(arg0)};
    Object res = func.call(cx, scope, scope, args);
    float f = 0.0f;
    try {
      f = Float.parseFloat(res.toString());
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here


    }

    private String evaluateFormula(String type, Vertex vertex, String workspaceId, Authorizations authorizations) {
        String json = toJson(vertex, workspaceId, authorizations);

        Function f = (Function) scope.get("evaluate" + type + "FormulaJson", scope);
        Object result = f.call(context, scope, scope, new Object[]{json});

        return (String) Context.jsToJava(result, String.class);
    }
View Full Code Here

     * @return the function return value.
     */
    public Object invoke(String functionName, Object[] args, Class responseClass, Map contexts) {
        Context cx = Context.enter();
        try {
            Function function = getFunction(scriptScope, functionName);
            Scriptable invocationScope = getInvocationScope(cx, contexts);
            Object[] jsArgs = processArgs(functionName, args, invocationScope);
            Object jsResponse = function.call(cx, invocationScope, invocationScope, jsArgs);
            Object response = processResponse(functionName, jsResponse, responseClass);
            return response;
        } finally {
            Context.exit();
        }
View Full Code Here

                                              final Object... args) {
        Object fObj = rhinoScope.get(functionName, rhinoScope);
        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

        Context cx = Context.enter();
        Map<String,Object> results = null;
        Object process = scope.get("process", scope);
        try {
            if (process instanceof Function) {
                Function processFn = (Function)process;
                Object[] args = {mapToJsObject(input, scope)};
                Object result = processFn.call(cx, scope, scope, args);
                results = jsObjectToMap((Scriptable)result);
            } else {
                throw new RuntimeException(
                    "Script for process: " + myScript.getName() +
                    " is not a valid process script."
View Full Code Here

                args[0] = hint;
            }
            Object v = ScriptableObject.getProperty(this, methodName);
            if (!(v instanceof Function))
                continue;
            Function fun = (Function) v;
            Context cx = RhinoScriptEngine.enterContext();
            try {
                v = fun.call(cx, fun.getParentScope(), this, args);
            } finally {
                cx.exit();
            }
            if (v != null) {
                if (!(v instanceof Scriptable)) {
View Full Code Here

            Object obj = ScriptableObject.getProperty(localScope, name);
            if (! (obj instanceof Function)) {
                throw new NoSuchMethodException("no such method: " + name);
            }

            Function func = (Function) obj;
            Scriptable scope = func.getParentScope();
            if (scope == null) {
                scope = engineScope;
            }
            Object result = func.call(cx, scope, localScope,
                                      wrapArguments(args));
            return unwrapReturnValue(result);
        } catch (JavaScriptException jse) {
            if (DEBUG) jse.printStackTrace();
            int line = (line = jse.lineNumber()) == 0 ? -1 : line;
View Full Code Here

        return "JSAdapter";
    }
   
    @Override
    public Object get(String name, Scriptable start) {
        Function func = getAdapteeFunction(GET_PROP);
        if (func != null) {
            return call(func, new Object[] { name });
        } else {
            start = getAdaptee();
            return start.get(name, start);
View Full Code Here

        }
    }
   
    @Override
    public Object get(int index, Scriptable start) {
        Function func = getAdapteeFunction(GET_PROP);
        if (func != null) {
            return call(func, new Object[] { new Integer(index) });
        } else {
            start = getAdaptee();
            return start.get(index, start);
View Full Code Here

        }
    }
   
    @Override
    public boolean has(String name, Scriptable start) {
        Function func = getAdapteeFunction(HAS_PROP);
        if (func != null) {
            Object res = call(func, new Object[] { name });
            return Context.toBoolean(res);
        } else {
            start = getAdaptee();
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.Function

Copyright © 2018 www.massapicom. 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.