Package org.mozilla.javascript

Examples of org.mozilla.javascript.Context.newObject()


    @Override public ExecutableScript executable(Object compiledScript, Map<String, Object> vars) {
        Context ctx = Context.enter();
        try {
            ctx.setWrapFactory(wrapFactory);

            Scriptable scope = ctx.newObject(globalScope);
            scope.setPrototype(globalScope);
            scope.setParentScope(null);
            for (Map.Entry<String, Object> entry : vars.entrySet()) {
                ScriptableObject.putProperty(scope, entry.getKey(), entry.getValue());
            }
View Full Code Here


    @Override public SearchScript search(Object compiledScript, SearchLookup lookup, @Nullable Map<String, Object> vars) {
        Context ctx = Context.enter();
        try {
            ctx.setWrapFactory(wrapFactory);

            Scriptable scope = ctx.newObject(globalScope);
            scope.setPrototype(globalScope);
            scope.setParentScope(null);

            for (Map.Entry<String, Object> entry : lookup.asMap().entrySet()) {
                ScriptableObject.putProperty(scope, entry.getKey(), entry.getValue());
View Full Code Here

    @Override public Object execute(Object compiledScript, Map<String, Object> vars) {
        Context ctx = Context.enter();
        ctx.setWrapFactory(wrapFactory);
        try {
            Script script = (Script) compiledScript;
            Scriptable scope = ctx.newObject(globalScope);
            scope.setPrototype(globalScope);
            scope.setParentScope(null);

            for (Map.Entry<String, Object> entry : vars.entrySet()) {
                ScriptableObject.putProperty(scope, entry.getKey(), entry.getValue());
View Full Code Here

          this.console = new JSEncogConsole();
          this.console.setConsole(this.externalConsole);
          Object con2 = Context.javaToJS(this.console, scope);
          ScriptableObject.putProperty(scope, "console", con2);
         
          this.current = (JSEncogCollection)cx.newObject(scope,"EncogCollection");
          this.current.setCollection(this.currentCollection);
          ScriptableObject.putProperty(scope, "current",this.current);
 
          cx.evaluateString(scope, script.getSource(), script.getName(), 1, null);
 
View Full Code Here

            Scriptable parentScope = getParentScope(objectModel);

            // Create a new local scope
            Scriptable scope;
            try {
                scope = ctx.newObject(parentScope);
            } catch (Exception e) {
                // Should normally not happen
                throw new CascadingRuntimeException("Cannont create script scope", e);
            }
            scope.setParentScope(parentScope);
View Full Code Here

                Object viewData = FlowHelper.getContextObject(objectModel);
                if (viewData != null) {
                    // Create a new local scope to hold the view data
                    Scriptable newScope;
                    try {
                        newScope = ctx.newObject(scope);
                    } catch (Exception e) {
                        // Should normally not happen
                        throw new CascadingRuntimeException("Cannont create function scope", e);
                    }
                    newScope.setParentScope(scope);
View Full Code Here

    ScriptableResult(Scriptable scope,
                     ResultSet rs, int startRow, int maxRows)
        throws SQLException, PropertyException, NotAFunctionException, JavaScriptException {
        Context cx = Context.getCurrentContext();
        Scriptable rowMap = cx.newObject(scope, "Array");
        put("rows", this, rowMap);
        Scriptable rowByIndex = cx.newObject(scope, "Array");
        put("rowsByIndex", this, rowByIndex);

        ResultSetMetaData rsmd = rs.getMetaData();
View Full Code Here

                     ResultSet rs, int startRow, int maxRows)
        throws SQLException, PropertyException, NotAFunctionException, JavaScriptException {
        Context cx = Context.getCurrentContext();
        Scriptable rowMap = cx.newObject(scope, "Array");
        put("rows", this, rowMap);
        Scriptable rowByIndex = cx.newObject(scope, "Array");
        put("rowsByIndex", this, rowByIndex);

        ResultSetMetaData rsmd = rs.getMetaData();
        int noOfColumns = rsmd.getColumnCount();
View Full Code Here

        ResultSetMetaData rsmd = rs.getMetaData();
        int noOfColumns = rsmd.getColumnCount();

        // Create the column name array
        Scriptable columnNames = cx.newObject(scope,
                                              "Array",
                                              new Object[] {new Integer(noOfColumns)});
        put("columnNames", this, columnNames);
        for (int i = 1; i <= noOfColumns; i++) {
            columnNames.put(i-1, columnNames, rsmd.getColumnName(i));
View Full Code Here

        while (rs.next()) {
            if ((maxRows != -1) && (processedRows == maxRows)) {
                isLimited = true;
                break;
            }
            Scriptable columns = cx.newObject(scope, "Array",
                                              new Object[] {new Integer(noOfColumns)});
            Scriptable columnMap = new Row();
            columnMap.setParentScope(columns.getParentScope());
            columnMap.setPrototype(getObjectPrototype(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.