本文整理匯總了Java中org.mozilla.javascript.Context.toObject方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.toObject方法的具體用法?Java Context.toObject怎麽用?Java Context.toObject使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.mozilla.javascript.Context
的用法示例。
在下文中一共展示了Context.toObject方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getUserScriptScope
import org.mozilla.javascript.Context; //導入方法依賴的package包/類
public Scriptable getUserScriptScope(Context jsContext)
{
Scriptable scope = new ImporterTopLevel(jsContext);
for( String name : userScriptObjects.keySet() )
{
Object obj = userScriptObjects.get(name);
if( obj instanceof Boolean )
{
scope.put(name, scope, obj);
}
else if( obj != null )
{
Scriptable jsArgs = Context.toObject(obj, scope);
scope.put(name, scope, jsArgs);
}
}
return scope;
}
示例2: getScope
import org.mozilla.javascript.Context; //導入方法依賴的package包/類
@SuppressWarnings("nls")
public Scriptable getScope(Context jsContext)
{
Scriptable scope = new ImporterTopLevel(jsContext);
for( String name : scriptObjects.keySet() )
{
Object obj = scriptObjects.get(name);
if( obj instanceof Boolean )
{
scope.put(name, scope, obj);
}
else if( obj != null )
{
Scriptable jsArgs = Context.toObject(obj, scope);
scope.put(name, scope, jsArgs);
}
}
// Remove the ability to create new Java objects in the script. List
// comes from https://bugzilla.mozilla.org/show_bug.cgi?id=468385
scope.delete("Packages");
scope.delete("JavaImporter");
scope.delete("JavaAdapter");
scope.delete("getClass");
scope.delete("java");
scope.delete("javax");
scope.delete("com");
scope.delete("net");
scope.delete("edu");
scope.delete("org");
try
{
// Prevent existingObject.getClass().forName('...')
jsContext.setClassShutter(new ClassShutter()
{
@Override
public boolean visibleToScripts(String className)
{
return !className.equals("java.lang.Class");
}
});
}
catch( SecurityException se )
{
// ignore - there's no way to test presence of ClassShutter
// (indicative of a Context provided by calling module: ReportEngine
// for example) other than by attempting to set ClassShutter.
// See #8135
}
return scope;
}