if ( result instanceof Scriptable) {   String jsClass = ((Scriptable) result).getClassName(); if (jsClass.equals("Date")) { return new Date((long) Context.toNumber(result)); } else if (jsClass.equals("Boolean")) { return new Boolean(Context.toBoolean(result)); } else if (jsClass.equals("Number")) { return new Double(Context.toNumber(result)); } else {   return result.toString(); } } return result;
return convertNativeObjToJavaObj(result);
	public static Object evaluateJSExpr(Context cx, Scriptable scope,			String scriptText, String source, int lineNo)			throws DataException 	{		Object result = null;		try		{			result = cx.evaluateString(scope, scriptText, source, lineNo, null);		}		catch ( Exception e)		{			RethrowJSEvalException(e);		}				if ( result instanceof Scriptable) 		{			// Return type is a Javascript native object			// Convert to Java object with same value			String jsClass = ((Scriptable) result).getClassName();			if (jsClass.equals("Date")) 			{				return new Date((long) Context.toNumber(result));			} 			else if (jsClass.equals("Boolean")) 			{				return new Boolean(Context.toBoolean(result));			} 			else if (jsClass.equals("Number")) 			{				return new Double(Context.toNumber(result));			} 			else 			{				// For JS "String" type, toString gives the correct result				// For all other types that we cannot handle, toString is the best we can do				return result.toString();			}		}		return result;	}