Java Code Examples for org.mozilla.javascript.Scriptable#put()

The following examples show how to use org.mozilla.javascript.Scriptable#put() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TypeOfTest.java    From rhino-android with Apache License 2.0 6 votes vote down vote up
/**
 * ECMA 11.4.3 says that typeof on host object is Implementation-dependent
 */
public void test0() throws Exception
{
       final Function f = new BaseFunction()
       {
       	@Override
       	public Object call(Context _cx, Scriptable _scope, Scriptable _thisObj,
       			Object[] _args)
       	{
       		return _args[0].getClass().getName();
       	}
       };
	final ContextAction action = new ContextAction()
	{
		public Object run(final Context context)
		{
			final Scriptable scope = context.initStandardObjects();
			scope.put("myObj", scope, f);
			return context.evaluateString(scope, "typeof myObj", "test script", 1, null);
		}
	};
	doTest("function", action);
}
 
Example 2
Source File: JsFunction.java    From spork with Apache License 2.0 6 votes vote down vote up
/**
 * converts a bag to javascript object based on a schema
 * @param bag the bag to convert
 * @param schema the schema to use for conversion
 * @param depth call depth used for debugging messages
 * @return the resulting javascript object
 * @throws FrontendException
 * @throws ExecException
 */
private Scriptable pigBagToJS(DataBag bag, Schema schema, int depth) throws FrontendException, ExecException {
    debugConvertPigToJS(depth, "Bag", bag, schema);
    if (schema.size() == 1 && schema.getField(0).type == DataType.TUPLE) {
        // unwrapping as bags always contain a tuple
        schema = schema.getField(0).schema;
    }
    Scriptable array = jsScriptEngine.jsNewArray(bag.size());
    array.setParentScope(jsScriptEngine.getScope());
    int i= 0;
    for (Tuple t : bag) {
        array.put(i++, array, pigTupleToJS(t, schema, depth + 1));
    }
    debugReturn(depth, array);
    return array;
}
 
Example 3
Source File: ExpressionLanguageJavaScriptImpl.java    From oval with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Object evaluate(final String expression, final Map<String, ?> values) throws ExpressionEvaluationException {
   LOG.debug("Evaluating JavaScript expression: {1}", expression);
   try {
      final Context ctx = ContextFactory.getGlobal().enterContext();
      final Scriptable scope = ctx.newObject(parentScope);
      scope.setPrototype(parentScope);
      scope.setParentScope(null);
      for (final Entry<String, ?> entry : values.entrySet()) {
         scope.put(entry.getKey(), scope, Context.javaToJS(entry.getValue(), scope));
      }
      final Script expr = expressionCache.get(expression);
      return expr.exec(ctx, scope);
   } catch (final EvaluatorException ex) {
      throw new ExpressionEvaluationException("Evaluating JavaScript expression failed: " + expression, ex);
   } finally {
      Context.exit();
   }
}
 
Example 4
Source File: TypeOfTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * ECMA 11.4.3 says that typeof on host object is Implementation-dependent
 */
public void test0() throws Exception
{
       final Function f = new BaseFunction()
       {
       	@Override
       	public Object call(Context _cx, Scriptable _scope, Scriptable _thisObj,
       			Object[] _args)
       	{
       		return _args[0].getClass().getName();
       	}
       };
	final ContextAction action = new ContextAction()
	{
		public Object run(final Context context)
		{
			final Scriptable scope = context.initStandardObjects();
			scope.put("myObj", scope, f);
			return context.evaluateString(scope, "typeof myObj", "test script", 1, null);
		}
	};
	doTest("function", action);
}
 
Example 5
Source File: PrimitiveTypeScopeResolutionTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private void testWithTwoScopes(final String scriptScope1,
                               final String scriptScope2)
{
	final ContextAction action = new ContextAction()
	{
		public Object run(final Context cx)
		{
	        final Scriptable scope1 = cx.initStandardObjects(
	            new MySimpleScriptableObject("scope1"));
	        final Scriptable scope2 = cx.initStandardObjects(
	            new MySimpleScriptableObject("scope2"));
	        cx.evaluateString(scope2, scriptScope2, "source2", 1, null);

	        scope1.put("scope2", scope1, scope2);

	        return cx.evaluateString(scope1, scriptScope1, "source1", 1,
	                                 null);
		}
	};
	Utils.runWithAllOptimizationLevels(action);
}
 
Example 6
Source File: Require.java    From JsDroidCmd with Mozilla Public License 2.0 5 votes vote down vote up
private Scriptable executeModuleScript(Context cx, String id,
        Scriptable exports, ModuleScript moduleScript, boolean isMain)
{
    final ScriptableObject moduleObject = (ScriptableObject)cx.newObject(
            nativeScope);
    URI uri = moduleScript.getUri();
    URI base = moduleScript.getBase();
    defineReadOnlyProperty(moduleObject, "id", id);
    if(!sandboxed) {
        defineReadOnlyProperty(moduleObject, "uri", uri.toString());
    }
    final Scriptable executionScope = new ModuleScope(nativeScope, uri, base);
    // Set this so it can access the global JS environment objects.
    // This means we're currently using the "MGN" approach (ModuleScript
    // with Global Natives) as specified here:
    // <http://wiki.commonjs.org/wiki/Modules/ProposalForNativeExtension>
    executionScope.put("exports", executionScope, exports);
    executionScope.put("module", executionScope, moduleObject);
    moduleObject.put("exports", moduleObject, exports);
    install(executionScope);
    if(isMain) {
        defineReadOnlyProperty(this, "main", moduleObject);
    }
    executeOptionalScript(preExec, cx, executionScope);
    moduleScript.getScript().exec(cx, executionScope);
    executeOptionalScript(postExec, cx, executionScope);
    return ScriptRuntime.toObject(cx, nativeScope,
            ScriptableObject.getProperty(moduleObject, "exports"));
}
 
Example 7
Source File: JsFunction.java    From spork with Apache License 2.0 5 votes vote down vote up
/**
 * converts a map to javascript object based on a schema
 * @param map the map to convert
 * @param schema the schema to use for conversion
 * @param depth call depth used for debugging messages
 * @return the resulting javascript object
 */
private Scriptable pigMapToJS(Map<String, Object> map, Schema schema, int depth) {
    debugConvertPigToJS(depth, "Map", map, schema);
    Scriptable object = jsScriptEngine.jsNewObject();

    for (Entry<String, Object> entry : map.entrySet()) {
        object.put(entry.getKey(), object, entry.getValue());
    }
    debugReturn(depth, object);
    return object;
}
 
Example 8
Source File: JsFunction.java    From spork with Apache License 2.0 5 votes vote down vote up
/**
 * converts a tuple to javascript object based on a schema
 * @param tuple the tuple to convert
 * @param schema the schema to use for conversion
 * @param depth call depth used for debugging messages
 * @return the resulting javascript object 
 */
@SuppressWarnings("unchecked")
private Scriptable pigTupleToJS(Tuple tuple, Schema schema, int depth) throws FrontendException, ExecException {
    debugConvertPigToJS(depth, "Tuple", tuple, schema);
    Scriptable object = null;
    if (tuple != null) {
        object = jsScriptEngine.jsNewObject(); 

        for (int i = 0; i < schema.size(); i++) {
            FieldSchema field = schema.getField(i);
            Object value;
            if (field.type == DataType.BAG) {
                value = pigBagToJS((DataBag)tuple.get(i), field.schema, depth + 1);
            } else if (field.type == DataType.TUPLE) {
                value = pigTupleToJS((Tuple)tuple.get(i), field.schema, depth + 1);
            } else if (field.type == DataType.MAP) {
                value = pigMapToJS((Map<String, Object>)tuple.get(i), field.schema, depth + 1);
            } else {
                debugConvertPigToJS(depth+1, "value", tuple.get(i), field.schema);
                value = Context.javaToJS(tuple.get(i), jsScriptEngine.getScope());
                debugReturn(depth + 1, value);
            }
            object.put(field.alias, object, value);
        }
    }
    debugReturn(depth, object);
    return object;
}
 
Example 9
Source File: JsFunction.java    From spork with Apache License 2.0 5 votes vote down vote up
@Override
public Object exec(Tuple tuple) throws IOException {
	Schema inputSchema = this.getInputSchema();
    if (LOG.isDebugEnabled()) {
        LOG.debug( "CALL " + stringify(outputSchema) + " " + functionName + " " + stringify(inputSchema));
    }
    // UDF always take a tuple: unwrapping when not necessary to simplify UDFs
    if (inputSchema.size() == 1 && inputSchema.getField(0).type == DataType.TUPLE) {
        inputSchema = inputSchema.getField(0).schema;
    }

    Scriptable params = pigTupleToJS(tuple, inputSchema, 0);

    Object[] passedParams = new Object[inputSchema.size()];
    for (int j = 0; j < passedParams.length; j++) {
        passedParams[j] = params.get(inputSchema.getField(j).alias, params);
    }

    Object result = jsScriptEngine.jsCall(functionName, passedParams);
    if (LOG.isDebugEnabled()) {
        LOG.debug( "call "+functionName+"("+Arrays.toString(passedParams)+") => "+toString(result));
    }

    // We wrap the result with an object in the following cases:
    //   1. Result is not an object type.
    //   2. OutputSchema is a tuple type. 
    if (!(result instanceof NativeObject) || outputSchema.getField(0).type == DataType.TUPLE) {
        Scriptable wrapper = jsScriptEngine.jsNewObject();
        wrapper.put(outputSchema.getField(0).alias, wrapper, result);
        result = wrapper;
    }
    Tuple evalTuple = jsToPigTuple((Scriptable)result, outputSchema, 0);
    Object eval = outputSchema.size() == 1 ? evalTuple.get(0) : evalTuple;
    LOG.debug(eval);
    return eval;
}
 
Example 10
Source File: TypeOfTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private void testCustomizeTypeOf(final String expected, final Scriptable obj)
{
	final ContextAction action = new ContextAction()
	{
		public Object run(final Context context)
		{
			final Scriptable scope = context.initStandardObjects();
			scope.put("myObj", scope, obj);
			return context.evaluateString(scope, "typeof myObj", "test script", 1, null);
		}
	};
	doTest(expected, action);
}
 
Example 11
Source File: GeneratedMethodNameTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
public void doTest(final String scriptCode) throws Exception {
	final Context cx = ContextFactory.getGlobal().enterContext();
	try {
           Scriptable topScope = cx.initStandardObjects();
   		topScope.put("javaNameGetter", topScope, new JavaNameGetter());
   		Script script = cx.compileString(scriptCode, "myScript", 1, null);
   		script.exec(cx, topScope);
	} finally {
	    Context.exit();
	}
}
 
Example 12
Source File: PrimitiveTypeScopeResolutionTest.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Test that FunctionObject use the right top scope to convert a primitive
 * to an object
 */
@Test
public void functionObjectPrimitiveToObject() throws Exception {
    final String scriptScope2 = "function f() {\n"
        + "String.prototype.foo = 'from 2'; \n"
        + "var s2 = 's2';\n"
        + "var s2Foo = s2.foo;\n"
        + "var s2FooReadByFunction = myObject.readPropFoo(s2);\n"
        + "if (s2Foo != s2FooReadByFunction)\n"
        + "throw 's2 got: ' + s2FooReadByFunction;\n"
        + "}";

    // define object with custom method
    final MyObject myObject = new MyObject();
    final String[] functionNames = { "readPropFoo" };
    myObject.defineFunctionProperties(functionNames, MyObject.class,
        ScriptableObject.EMPTY);

    final String scriptScope1 = "String.prototype.foo = 'from 1'; scope2.f()";

    final ContextAction action = new ContextAction()
    {
        public Object run(final Context cx)
        {
            final Scriptable scope1 = cx.initStandardObjects(
                new MySimpleScriptableObject("scope1"));
            final Scriptable scope2 = cx.initStandardObjects(
                new MySimpleScriptableObject("scope2"));

            scope2.put("myObject", scope2, myObject);
            cx.evaluateString(scope2, scriptScope2, "source2", 1, null);

            scope1.put("scope2", scope1, scope2);

            return cx.evaluateString(scope1, scriptScope1, "source1", 1, null);
        }
    };
    Utils.runWithAllOptimizationLevels(action);
}
 
Example 13
Source File: Require.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
private Scriptable executeModuleScript(Context cx, String id,
        Scriptable exports, ModuleScript moduleScript, boolean isMain)
{
    final ScriptableObject moduleObject = (ScriptableObject)cx.newObject(
            nativeScope);
    URI uri = moduleScript.getUri();
    URI base = moduleScript.getBase();
    defineReadOnlyProperty(moduleObject, "id", id);
    if(!sandboxed) {
        defineReadOnlyProperty(moduleObject, "uri", uri.toString());
    }
    final Scriptable executionScope = new ModuleScope(nativeScope, uri, base);
    // Set this so it can access the global JS environment objects.
    // This means we're currently using the "MGN" approach (ModuleScript
    // with Global Natives) as specified here:
    // <http://wiki.commonjs.org/wiki/Modules/ProposalForNativeExtension>
    executionScope.put("exports", executionScope, exports);
    executionScope.put("module", executionScope, moduleObject);
    moduleObject.put("exports", moduleObject, exports);
    install(executionScope);
    if(isMain) {
        defineReadOnlyProperty(this, "main", moduleObject);
    }
    executeOptionalScript(preExec, cx, executionScope);
    moduleScript.getScript().exec(cx, executionScope);
    executeOptionalScript(postExec, cx, executionScope);
    return ScriptRuntime.toObject(nativeScope,
            ScriptableObject.getProperty(moduleObject, "exports"));
}
 
Example 14
Source File: GeneratedMethodNameTest.java    From rhino-android with Apache License 2.0 5 votes vote down vote up
public void doTest(final String scriptCode) throws Exception {
	final Context cx = new RhinoAndroidHelper().enterContext();
	try {
           Scriptable topScope = cx.initStandardObjects();
   		topScope.put("javaNameGetter", topScope, new JavaNameGetter());
   		Script script = cx.compileString(scriptCode, "myScript", 1, null);
   		script.exec(cx, topScope);
	} finally {
	    Context.exit();
	}
}
 
Example 15
Source File: PrimitiveTypeScopeResolutionTest.java    From rhino-android with Apache License 2.0 5 votes vote down vote up
/**
 * Test that FunctionObject use the right top scope to loadClass a primitive
 * to an object
 */
@Test
public void functionObjectPrimitiveToObject() throws Exception {
    final String scriptScope2 = "function f() {\n"
        + "String.prototype.foo = 'from 2'; \n"
        + "var s2 = 's2';\n"
        + "var s2Foo = s2.foo;\n"
        + "var s2FooReadByFunction = myObject.readPropFoo(s2);\n"
        + "if (s2Foo != s2FooReadByFunction)\n"
        + "throw 's2 got: ' + s2FooReadByFunction;\n"
        + "}";

    // define object with custom method
    final MyObject myObject = new MyObject();
    final String[] functionNames = { "readPropFoo" };
    myObject.defineFunctionProperties(functionNames, MyObject.class,
        ScriptableObject.EMPTY);

    final String scriptScope1 = "String.prototype.foo = 'from 1'; scope2.f()";

    final ContextAction action = new ContextAction()
    {
        public Object run(final Context cx)
        {
            final Scriptable scope1 = cx.initStandardObjects(
                new MySimpleScriptableObject("scope1"));
            final Scriptable scope2 = cx.initStandardObjects(
                new MySimpleScriptableObject("scope2"));

            scope2.put("myObject", scope2, myObject);
            cx.evaluateString(scope2, scriptScope2, "source2", 1, null);

            scope1.put("scope2", scope1, scope2);

            return cx.evaluateString(scope1, scriptScope1, "source1", 1, null);
        }
    };
    Utils.runWithAllOptimizationLevels(action);
}
 
Example 16
Source File: DataAdapterUtil.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This method is used to register the Java Script Objects which are defined in the scope of
 * source ResultSet ( might be IResultSet or CubeCursor ) to target scope. One possible client
 * of this method is Report Engine. A classic use case is that instead of register its own "row" object 
 * the Report Engine can simply call this method with proper argument so that the "row" object
 * registered in IResultIterator's scope, that is, JSResultSetRow, can be accessed by engine using
 * engine scope. 
 *   
 * @param targetScope
 * @param source
 * @throws AdapterException 
 */
public static void registerDataObject( ScriptContext context,
		ILinkedResult source ) throws AdapterException
{
	try
	{
		Scriptable targetScope = ( (IDataScriptEngine) context.getScriptEngine( IDataScriptEngine.ENGINE_NAME ) ).getJSScope( context );
		int type = ( (ILinkedResult) source ).getCurrentResultType( );
		if ( type == ILinkedResult.TYPE_TABLE )
		{
			targetScope.put( "row",
					targetScope,
					new JSResultIteratorObject( (ILinkedResult) source,
							targetScope ) );
			targetScope.put( "data",
					targetScope,
					new JSResultIteratorObject( (ILinkedResult) source,
							targetScope ) );
		}
		else if ( type == ILinkedResult.TYPE_CUBE && source.getCurrentResult( )!= null )
		{
			Scriptable scope = ( (ICubeCursor) source.getCurrentResult( ) ).getScope( );
			targetScope.put( "data", targetScope, scope.get( "data", scope ) );
			if( scope.get( "data", scope ) != null && scope.get( "data", scope ) instanceof Scriptable )
				targetScope.put( "row", targetScope, scope.get( "row", scope ) );
			targetScope.put( "dimension",
					targetScope,
					scope.get( "dimension", scope ) );
			targetScope.put( "measure", targetScope, scope.get( "measure",
					scope ) );
		}
	}
	catch ( BirtException e )
	{
		throw new AdapterException( e.getErrorCode( ), e );
	}
}
 
Example 17
Source File: JsonParser.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
private Object readObject() throws ParseException {
    consumeWhitespace();
    Scriptable object = cx.newObject(scope);
    // handle empty object literal case early
    if (pos < length && src.charAt(pos) == '}') {
        pos += 1;
        return object;
    }
    String id;
    Object value;
    boolean needsComma = false;
    while (pos < length) {
        char c = src.charAt(pos++);
        switch(c) {
            case '}':
                if (!needsComma) {
                    throw new ParseException("Unexpected comma in object literal");
                }
                return object;
            case ',':
                if (!needsComma) {
                    throw new ParseException("Unexpected comma in object literal");
                }
                needsComma = false;
                break;
            case '"':
                if (needsComma) {
                    throw new ParseException("Missing comma in object literal");
                }
                id = readString();
                consume(':');
                value = readValue();

                long index = ScriptRuntime.indexFromString(id);
                if (index < 0) {
                  object.put(id, object, value);
                } else {
                  object.put((int)index, object, value);
                }

                needsComma = true;
                break;
            default:
                throw new ParseException("Unexpected token in object literal");
        }
        consumeWhitespace();
    }
    throw new ParseException("Unterminated object literal");
}
 
Example 18
Source File: GrammarContext.java    From JVoiceXML with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Updates the parent scope:
 * <ul>
 * <li>rules.rulename</li>
 * <li>rules.latest()</li>
 * <li>meta.rulename</li>
 * <li>meta.current()</li>
 * </ul>
 * 
 * @param context
 * @param parentScope
 * @param ruleScope
 * @param out
 */
private void updateParentScope(
        org.mozilla.javascript.Context parentContext,
        Scriptable parentScope,
        org.mozilla.javascript.Context grammarContext,
        Scriptable grammarScope, Object out) {

    // Setup rules
    Scriptable ruleObject = (Scriptable) parentScope.get("rules",
            parentScope);
    ruleObject.put(ruleName, ruleObject, out); // sets rules.rulename
    parentContext.evaluateString(parentScope,
            getRulesLastestScript(ruleName), "Context:rules.Latest", 0,
            null); // sets rules.latest()

    // Setup meta
    // meta.rulename will be set based on the match in the current context
    // meta.current() will be set based on the current value if the parent
    // context plus the value coming out of the rule context
    String ruleMetaCurrent = (String) grammarContext.evaluateString(
            grammarScope, "meta.current().text;", "Context:rule get meta",
            0, null);

    parentContext.evaluateString(parentScope, "meta." + ruleName
            + "=function() {return {text:'" + ruleMetaCurrent
            + "', score:1.0};};", "Context:rule set meta." + ruleName, 0,
            null);

    if (ruleMetaCurrent.length() > 0) {
        String parentMetaCurrent = (String) parentContext.evaluateString(
                parentScope, "meta.current().text;",
                "Context:parent get meta", 0, null);

        if (parentMetaCurrent.length() == 0) {
            parentContext.evaluateString(parentScope,
                    "meta.current=function() {return {text:'"
                            + ruleMetaCurrent + "', score:1.0};};",
                    "AddToMatchedText:set meta1", 0, null);
        } else {
            parentContext.evaluateString(parentScope,
                    "meta.current=function() {return {text:'"
                            + parentMetaCurrent + " " + ruleMetaCurrent
                            + "', score:1.0};};",
                    "AddToMatchedText:set meta1", 0, null);
        }
    }
}
 
Example 19
Source File: Context.java    From JVoiceXML with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
     * Updates the parent scope:
     * <ul>
     * <li>rules.rulename</li>
     * <li>rules.latest()</li>
     * <li>meta.rulename</li>
     * <li>meta.current()</li>
     * </ul>
     * 
     * @param context
     * @param parentScope
     * @param ruleScope
     * @param out
     */
    private void updateParentScope(org.mozilla.javascript.Context context,
            Scriptable parentScope, Scriptable ruleScope, Object out) {
        // Setup rules
        Scriptable ruleObject = (Scriptable) parentScope.get("rules",
                parentScope);
        ruleObject.put(ruleName, ruleObject, out); // sets rules.rulename
        context.evaluateString(parentScope, getRulesLastestScript(ruleName),
                "Context:rules.Latest", 0, null); // sets rules.latest()

        // Setup meta
        // meta.rulename will be set based on the match in the current context
        // meta.current() will be set based on the current value if the parent
        // context plus the value coming out of the rule context
        String ruleMetaCurrent = (String) context.evaluateString(ruleScope,
                "meta.current().text;", "Context:rule get meta", 0, null);

//        LOGGER.debug("ruleMetaCurrent="+ruleMetaCurrent);
//        LOGGER.debug("about to execute: "+"meta."+ruleName+"=function() {return {text:'"+ruleMetaCurrent+"', score:1.0}};");
        context.evaluateString(parentScope, "meta." + ruleName
                + "=function() {return {text:'" + ruleMetaCurrent
                + "', score:1.0};};", "Context:rule set meta." + ruleName, 0,
                null);

        if (ruleMetaCurrent.length() > 0) {
            String parentMetaCurrent = (String) context.evaluateString(
                    parentScope, "meta.current().text;",
                    "Context:parent get meta", 0, null);

            if (parentMetaCurrent.length() == 0) {
                context.evaluateString(parentScope,
                        "meta.current=function() {return {text:'"
                                + ruleMetaCurrent + "', score:1.0};};",
                        "AddToMatchedText:set meta1", 0, null);
            } else {
                context.evaluateString(parentScope,
                        "meta.current=function() {return {text:'"
                                + parentMetaCurrent + " " + ruleMetaCurrent
                                + "', score:1.0};};",
                        "AddToMatchedText:set meta1", 0, null);
            }
        }
    }
 
Example 20
Source File: PreparedDummyQuery.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * @param queryResults
 * @param queryScope
 * @throws BirtException 
 */
private ResultIterator( QueryResults queryResults,
		ExprManager exprManager, Scriptable queryScope,
		Scriptable parentScope ) throws BirtException
{
	this.queryResults = queryResults;
	this.exprManager = exprManager;
	this.queryScope = queryScope;
	this.jsDummyRowObject = new JSDummyRowObject(exprManager,
			queryScope, parentScope, session.getEngineContext( ).getScriptContext( ));

	queryScope.put( "row", queryScope, jsDummyRowObject );
	
	this.getRdSaveUtil( ).doSaveStart( );

	exprValueMap = new HashMap( );
	Map exprMap = getBindingMap( exprManager.getBindingExprs( ) );
	Iterator it = exprMap.entrySet( ).iterator( );
	
	while ( it.hasNext( ) )
	{
		Map.Entry entry = (Entry) it.next( );
		String exprName = (String) entry.getKey( );
		IBaseExpression baseExpr = (IBaseExpression) entry.getValue( );
		Object exprValue = ExprEvaluateUtil.evaluateRawExpression( baseExpr,
				queryScope,
				session.getEngineContext( ).getScriptContext( ) );
		IBinding binding = exprManager.getBinding( exprName );
		if ( baseExpr != null && binding.getDataType( ) != baseExpr.getDataType( ) )
			exprValue = DataTypeUtil.convert( exprValue,
					binding.getDataType( ) );

		exprValueMap.put( exprName, exprValue );
	}

	this.getRdSaveUtil( ).doSaveExpr( exprValueMap );
	
	if( needCache() )
	{
		try 
		{
			createCacheOutputStream( );
			saveMetaData( );
			IOUtil.writeInt(this.rowOutputStream, 1 );
			cacheRow( );
		} 
		catch (IOException e) 
		{
			throw new DataException( ResourceConstants.CREATE_CACHE_TEMPFILE_ERROR );
		}
	}
}