本文整理了Java中org.mozilla.javascript.Context.compileString()
方法的一些代码示例,展示了Context.compileString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.compileString()
方法的具体详情如下:
包路径:org.mozilla.javascript.Context
类名称:Context
方法名:compileString
[英]Compiles the source in the given string.
Returns a script that may later be executed.
[中]编译给定字符串中的源代码。
返回以后可能执行的脚本。
代码示例来源:origin: pentaho/pentaho-kettle
jsscript = jscx.compileString( strActiveScript, "script", 1, null );
代码示例来源:origin: pentaho/pentaho-kettle
Script evalScript = jscx.compileString( scr, "script", 1, null );
evalScript.exec( jscx, jsscope );
代码示例来源:origin: pentaho/pentaho-kettle
Script evalScript = jscx.compileString( scr, "script", 1, null );
evalScript.exec( jscx, jsscope );
代码示例来源:origin: pentaho/pentaho-kettle
Script endScript = data.cx.compileString( strEndScript, "trans_End", 1, null );
endScript.exec( data.cx, data.scope );
if ( log.isDetailed() ) {
代码示例来源:origin: pentaho/pentaho-kettle
Script startScript = data.cx.compileString( strStartScript, "trans_Start", 1, null );
startScript.exec( data.cx, data.scope );
if ( log.isDetailed() ) {
data.script = data.cx.compileString( strTransformScript, "script", 1, null );
} catch ( Exception e ) {
throw new KettleValueException( BaseMessages.getString(
代码示例来源:origin: jasperreports/jasperreports
protected Script getCompiledExpression(String expression)
{
Script compiledExpression = (Script) compiledExpressions.get(expression);
if (compiledExpression == null)
{
compiledExpression = context.compileString(expression, "expression", 0, null);
compiledExpressions.put(expression, compiledExpression);
}
return compiledExpression;
}
代码示例来源:origin: de.matrixweb.smaller/javascript
private ModuleScript getModuleScript(final Context cx, final String moduleId,
final Class<?> clazz) throws IOException, URISyntaxException {
final String path = '/' + this.name + '/' + moduleId + ".js";
final URL url = clazz.getResource(path);
if (url == null) {
return null;
}
return new ModuleScript(cx.compileString(IOUtils.toString(url), moduleId,
1, null), new URI(moduleId), null);
}
代码示例来源:origin: dingjibang/GDX-RPG
/**编译脚本(如果没有就添加到缓存)*/
protected Script get(Scriptable scriptable, Context ctx, String fileName) {
fileName = getPath(fileName);
synchronized(completedScripts) {
Script script = completedScripts.get(fileName);
if(script == null)
completedScripts.put(fileName, script = ctx.compileString(File.readString(path + fileName), null, 1, null));
return script;
}
}
代码示例来源:origin: org.seasar.mayaa/mayaa
protected Object normalExecute(Context cx, Scriptable scope) {
if (cx == null || scope == null) {
throw new IllegalArgumentException();
}
if (_rhinoScript == null) {
_rhinoScript = cx.compileString(
getText(), _sourceName, _lineNumber + _offsetLine, null);
}
return _rhinoScript.exec(cx, scope);
}
代码示例来源:origin: apache/cxf
private Object[] compileScript(Context cx, String scriptStr, Scriptable scriptScope, File f) {
int opt = cx.getOptimizationLevel();
cx.setOptimizationLevel(-1);
Script script = cx.compileString(scriptStr, f.getName(), 1, null);
script.exec(cx, scriptScope);
Object[] ids = scriptScope.getIds();
cx.setOptimizationLevel(opt);
script = cx.compileString(scriptStr, f.getName(), 1, null);
script.exec(cx, scriptScope);
return ids;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-js
private Object[] compileScript(Context cx, String scriptStr, Scriptable scriptScope, File f) {
int opt = cx.getOptimizationLevel();
cx.setOptimizationLevel(-1);
Script script = cx.compileString(scriptStr, f.getName(), 1, null);
script.exec(cx, scriptScope);
Object[] ids = scriptScope.getIds();
cx.setOptimizationLevel(opt);
script = cx.compileString(scriptStr, f.getName(), 1, null);
script.exec(cx, scriptScope);
return ids;
}
代码示例来源:origin: org.apache.cocoon/cocoon-expression-language-impl
private void compile() {
Context ctx = Context.enter();
try {
this.script = ctx.compileString(getExpression(), "", 1, null);
} finally {
Context.exit();
}
}
代码示例来源:origin: rhino/js
private static Script compile(Context cx, String source)
{
int[] linep = { 0 };
String filename = Context.getSourcePositionFromStack(linep);
if (filename == null) {
filename = "<Script object>";
linep[0] = 1;
}
ErrorReporter reporter;
reporter = DefaultErrorReporter.forEval(cx.getErrorReporter());
return cx.compileString(source, null, reporter, filename,
linep[0], null);
}
代码示例来源:origin: ro.isdc.wro4j/rhino
private static Script compile(Context cx, String source)
{
int[] linep = { 0 };
String filename = Context.getSourcePositionFromStack(linep);
if (filename == null) {
filename = "<Script object>";
linep[0] = 1;
}
ErrorReporter reporter;
reporter = DefaultErrorReporter.forEval(cx.getErrorReporter());
return cx.compileString(source, null, reporter, filename,
linep[0], null);
}
代码示例来源:origin: com.sun.phobos/phobos-rhino
private static Script compile(Context cx, String source)
{
int[] linep = { 0 };
String filename = Context.getSourcePositionFromStack(linep);
if (filename == null) {
filename = "<Script object>";
linep[0] = 1;
}
ErrorReporter reporter;
reporter = DefaultErrorReporter.forEval(cx.getErrorReporter());
return cx.compileString(source, null, reporter, filename,
linep[0], null);
}
代码示例来源:origin: geogebra/geogebra
private static Script compile(Context cx, String source)
{
int[] linep = { 0 };
String filename = Context.getSourcePositionFromStack(linep);
if (filename == null) {
filename = "<Script object>";
linep[0] = 1;
}
ErrorReporter reporter;
reporter = DefaultErrorReporter.forEval(cx.getErrorReporter());
return cx.compileString(source, null, reporter, filename,
linep[0], null);
}
代码示例来源:origin: org.hibnet/webpipes-rhino
@Override
public ModuleScript getModuleScript(Context cx, String moduleId, URI moduleUri, URI baseUri, Scriptable paths) throws Exception {
Script script = cx.compileString(moduleResource.getOutput().getContent(), moduleResource.getName(), 1, null);
return new ModuleScript(script, URI.create(moduleResource.getName()), URI.create(moduleResource.getName()));
}
});
代码示例来源:origin: datacleaner/DataCleaner
@Initialize
public void init() {
_contextFactory = new ContextFactory();
final Context context = _contextFactory.enterContext();
try {
_script = context.compileString(sourceCode, this.getClass().getSimpleName(), 1, null);
_sharedScope = context.initStandardObjects();
JavaScriptUtils.addToScope(_sharedScope, new JavaScriptLogger(), "logger", "log");
JavaScriptUtils.addToScope(_sharedScope, System.out, "out");
} finally {
Context.exit();
}
}
代码示例来源:origin: datacleaner/DataCleaner
@Initialize
public void init() {
_contextFactory = new ContextFactory();
final Context context = _contextFactory.enterContext();
try {
_script = context.compileString(sourceCode, this.getClass().getSimpleName(), 1, null);
_sharedScope = context.initStandardObjects();
JavaScriptUtils.addToScope(_sharedScope, new JavaScriptLogger(), "logger", "log");
JavaScriptUtils.addToScope(_sharedScope, System.out, "out");
} finally {
Context.exit();
}
}
代码示例来源:origin: io.apigee.trireme/trireme-util
@JSConstructor
@SuppressWarnings("unused")
public static Object construct(Context cx, Object[] args, Function ctorObj, boolean inNewExpr)
{
if (!inNewExpr) {
return cx.newObject(ctorObj, CLASS_NAME, args);
}
String code = stringArg(args, 0);
String fileName = stringArg(args, 1, "anonymous");
ScriptImpl self = new ScriptImpl();
self.script = cx.compileString(code, fileName, 1, null);
return self;
}
内容来源于网络,如有侵权,请联系作者删除!