本文整理汇总了Java中org.mozilla.javascript.ImporterTopLevel类的典型用法代码示例。如果您正苦于以下问题:Java ImporterTopLevel类的具体用法?Java ImporterTopLevel怎么用?Java ImporterTopLevel使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImporterTopLevel类属于org.mozilla.javascript包,在下文中一共展示了ImporterTopLevel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getUserScriptScope
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的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: initJavaScript
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的package包/类
private void initJavaScript() {
LogUtils.logMessage("Initialising JavaScript...");
contextFactory.call(new ContextAction() {
@Override
public Object run(Context cx) {
ImporterTopLevel importer = new ImporterTopLevel();
importer.initStandardObjects(cx, false);
systemScope = importer;
Object frameworkScriptable = Context.javaToJS(Framework.this, systemScope);
ScriptableObject.putProperty(systemScope, FRAMEWORK_VARIABLE, frameworkScriptable);
systemScope.setAttributes(FRAMEWORK_VARIABLE, ScriptableObject.READONLY);
globalScope = (ScriptableObject) cx.newObject(systemScope);
globalScope.setPrototype(systemScope);
globalScope.setParentScope(null);
return null;
}
});
}
示例3: initJsScope
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的package包/类
private @NonNull ScriptableObject initJsScope(@NonNull Context jsContext) {
// Set the main Rhino goodies
ImporterTopLevel importerTopLevel = new ImporterTopLevel(jsContext);
ScriptableObject scope = jsContext.initStandardObjects(importerTopLevel, false);
ScriptableObject.putProperty(scope, "context", Context.javaToJS(mContext, scope));
try {
importClasses(jsContext, scope);
importPackages(jsContext, scope);
importConsole(scope);
importVariables(scope);
importFunctions(scope);
} catch (StethoJsException e) {
String message = String.format("%s\n%s", e.getMessage(), Log.getStackTraceString(e));
LogUtil.e(e, message);
CLog.writeToConsole(Console.MessageLevel.ERROR, Console.MessageSource.JAVASCRIPT, message);
}
return scope;
}
示例4: start
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的package包/类
public void start() {
LOG.debug("Start MacroRuntime {}", this);
context = Context.enter();
context.setLanguageVersion(Context.VERSION_ES6);
context.setWrapFactory(new SCWrapFactory());
globalScope = new ImporterTopLevel(context);
// List<URI> paths;
// try {
// paths = Collections.singletonList(this.getClass().getResource("/macro/console.js").toURI());
// } catch (URISyntaxException e) {
// throw new UnexpectedException(e);
// }
// ModuleSourceProvider sourceProvider = new UrlModuleSourceProvider(paths, null);
// ModuleScriptProvider scriptProvider = new SoftCachingModuleScriptProvider(sourceProvider);
// RequireBuilder builder = new RequireBuilder();
// builder.setModuleScriptProvider(scriptProvider);
// builder.setSandboxed(false);
// Require require = builder.createRequire(context, globalScope);
//
// require.install(globalScope);
// loadScriptToGlobalVariable("console", "console");
context.evaluateString(globalScope, getInitScript(), "init.js", 1, null);
started = true;
}
示例5: init
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的package包/类
/**
* Initialize the JavaScript context using given parent scope.
*
* @param scPrototype
* Parent scope object. If it's null, use default scope.
*/
public void init( Scriptable scPrototype ) throws CrosstabException
{
final Context cx = Context.enter( );
try
{
if ( scPrototype == null )
{
scope = new ImporterTopLevel( cx );
}
else
{
scope = cx.newObject( scPrototype );
scope.setPrototype( scPrototype );
}
}
catch ( RhinoException jsx )
{
throw convertException( jsx );
}
finally
{
Context.exit( );
}
}
示例6: BIRTExternalContext
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的package包/类
/**
* The constructor.
*
* @param context
*/
public BIRTExternalContext( IReportContext context )
{
this.context = context;
final Context cx = Context.enter( );
try
{
Scriptable scope = new ImporterTopLevel( cx );
scriptableContext = cx.getWrapFactory( ).wrapAsJavaObject( cx,
scope,
context,
null );
}
catch ( Exception e )
{
logger.log( e );
}
finally
{
Context.exit( );
}
}
示例7: setUp
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的package包/类
protected void setUp( ) throws Exception
{
super.setUp( );
// Create test output file
// We must make sure this folder will be created successfully
// before we do next job.
openOutputFolder( );
openOutputFile( );
// Create top-level Javascript scope
jsContext = Context.enter( );
jsScope = new ImporterTopLevel( jsContext );
// Add JS functions testPrint and testPrintln for scripts to write
// to output file
jsScope.put( "_testCase", jsScope, this );
jsContext
.evaluateString(
jsScope,
"function testPrint(str) { _testCase.testPrint(str); }; "
+ "function testPrintln(str) { _testCase.testPrintln(str); }; ",
"BaseTestCase.setUp", 1, null );
}
示例8: mirrorCursorModelSetUp
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的package包/类
@Before
public void mirrorCursorModelSetUp() throws Exception
{
this.scope = new ImporterTopLevel( );
DataEngineContext context = DataEngineContext.newInstance( DataEngineContext.DIRECT_PRESENTATION,
scope,
null,
null );
context.setTmpdir( this.getTempDir( ) );
de = (DataEngineImpl) DataEngine.newDataEngine( context );
this.creator = new CubeUtility( );
creator.createCube( de );
creator.createCube1( de );
cube1 = creator.getCube( CubeUtility.cubeName, de );
cube2 = creator.getCube( CubeUtility.timeCube, de );
}
示例9: baseSetUp
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的package包/类
@Before
public void baseSetUp() throws Exception
{
// Create test output file
// We must make sure this folder will be created successfully
// before we do next job.
openOutputFolder();
openOutputFile();
// Create top-level Javascript scope
jsContext = Context.enter( );
jsScope = new ImporterTopLevel(jsContext);
scriptContext = new ScriptContext().newContext(jsScope);
// Add JS functions testPrint and testPrintln for scripts to write
// to output file
jsScope.put("_testCase", jsScope, this );
jsContext.evaluateString( jsScope,
"function testPrint(str) { _testCase.testPrint(str); }; " +
"function testPrintln(str) { _testCase.testPrintln(str); }; "
, "BaseTestCase.setUp", 1, null );
}
示例10: initialize
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的package包/类
/**
* Initialize the engine.
* Put the manager into the context-manager
* map hashtable too.
*/
@Override
public void initialize(BSFManager mgr, String lang,
@SuppressWarnings("rawtypes") // superclass does not support types
Vector declaredBeans)
throws BSFException {
super.initialize(mgr, lang, declaredBeans);
// Initialize context and global scope object
try {
Context cx = Context.enter();
global = new ImporterTopLevel(cx);
Scriptable bsf = Context.toObject(new BSFFunctions(mgr, this), global);
global.put("bsf", global, bsf);
@SuppressWarnings("unchecked") // superclass does not support types
final Vector<BSFDeclaredBean> beans = declaredBeans;
for (BSFDeclaredBean declaredBean : beans) {
declareBean(declaredBean);
}
}
catch (Throwable t) {
handleError(t);
}
finally {
Context.exit();
}
}
示例11: initScriptable
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的package包/类
private void initScriptable() throws IOException, RhinoException {
Context context = Context.enter();
try{
this.scriptable = new ImporterTopLevel(context);
context.evaluateReader(this.getScriptable(), Files.newBufferedReader(this.getFile().toPath(), StandardCharsets.UTF_8), this.getName(), 0, null);
ScriptableObject.putProperty(this.getScriptable(), "logger", this.getLogger());
ScriptableObject.putProperty(this.getScriptable(), "takoyaki", Takoyaki.getInstance());
}finally{
Context.exit();
}
}
示例12: AbstractScriptHandler
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的package包/类
/**
* The constructor.
*
*/
public AbstractScriptHandler( )
{
final Context cx = Context.enter( );
try
{
// scope = cx.initStandardObjects();
scope = new ImporterTopLevel( cx );
}
finally
{
Context.exit( );
}
}
示例13: init
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的package包/类
/**
* Initialize the JavaScript context using given parent scope.
*
* @param scPrototype
* Parent scope object. If it's null, use default scope.
*/
public final void init( Scriptable scPrototype ) throws ChartException
{
final Context cx = Context.enter( );
try
{
if ( scPrototype == null ) // NO PROTOTYPE
{
// scope = cx.initStandardObjects();
scope = new ImporterTopLevel( cx );
}
else
{
scope = cx.newObject( scPrototype );
scope.setPrototype( scPrototype );
// !don't reset the parent scope here.
// scope.setParentScope( null );
}
// final Scriptable scopePrevious = scope;
// !deprecated, remove this later. use script context instead.
// registerExistingScriptableObject( this, "chart" ); //$NON-NLS-1$
// scope = scopePrevious; // RESTORE
// !deprecated, remove this later, use logger from script context
// instead.
// ADD LOGGING CAPABILITIES TO JAVASCRIPT ACCESS
final Object oConsole = Context.javaToJS( getLogger( ), scope );
scope.put( "logger", scope, oConsole ); //$NON-NLS-1$
}
catch ( RhinoException jsx )
{
throw convertException( jsx );
}
finally
{
Context.exit( );
}
}
示例14: dimensionFilterProcessorSetUp
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的package包/类
@Before
public void dimensionFilterProcessorSetUp()
{
cx = new ScriptContext();
this.baseScope = new ImporterTopLevel( );
this.cubeQuery = createCubeQueryDefinition( );
}
示例15: cursorModelSetUp
import org.mozilla.javascript.ImporterTopLevel; //导入依赖的package包/类
@Before
public void cursorModelSetUp() throws Exception
{
this.scope = new ImporterTopLevel();
DataEngineContext context = DataEngineContext.newInstance( DataEngineContext.DIRECT_PRESENTATION,
scope,
null,
null );
context.setTmpdir( this.getTempDir( ) );
de = (DataEngineImpl) DataEngine.newDataEngine( context );
creator = new CubeUtility();
creator.createCube(de );
cube = creator.getCube( CubeUtility.cubeName, de );
}