本文整理了Java中org.mozilla.javascript.Function.call()
方法的一些代码示例,展示了Function.call()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Function.call()
方法的具体详情如下:
包路径:org.mozilla.javascript.Function
类名称:Function
方法名:call
[英]Call the function. Note that the array of arguments is not guaranteed to have length greater than 0.
[中]调用函数。请注意,参数数组的长度不能保证大于0。
代码示例来源:origin: apache/incubator-druid
public boolean applyInContext(Context cx, Object input)
{
if (extractionFn != null) {
input = extractionFn.apply(input);
}
return Context.toBoolean(fnApply.call(cx, scope, scope, new Object[]{input}));
}
代码示例来源:origin: apache/incubator-druid
@Override
public String apply(Object input)
{
// ideally we need a close() function to discard the context once it is not used anymore
Context cx = Context.getCurrentContext();
if (cx == null) {
cx = contextFactory.enterContext();
}
final Object res = fn.call(cx, scope, scope, new Object[]{input});
return res != null ? Context.toString(res) : null;
}
};
代码示例来源:origin: apache/incubator-druid
@Override
public double apply(Object[] args)
{
// ideally we need a close() function to discard the context once it is not used anymore
Context cx = Context.getCurrentContext();
if (cx == null) {
cx = contextFactory.enterContext();
}
return Context.toNumber(fn.call(cx, scope, scope, args));
}
};
代码示例来源:origin: apache/incubator-druid
@Override
public Object apply(Object input)
{
// ideally we need a close() function to discard the context once it is not used anymore
Context cx = Context.getCurrentContext();
if (cx == null) {
cx = contextFactory.enterContext();
}
final Object res = fn.call(cx, scope, scope, new Object[]{input});
return res != null ? Context.toObject(res, scope) : null;
}
};
代码示例来源:origin: stackoverflow.com
String script = "function abc(x,y) {return x+y;}";
Context context = Context.enter();
try {
ScriptableObject scope = context.initStandardObjects();
Scriptable that = context.newObject(scope);
Function fct = context.compileFunction(scope, script, "script", 1, null);
Object result = fct.call(
context, scope, that, new Object[] {2, 3});
System.out.println(Context.jsToJava(result, int.class));
} finally {
Context.exit();
}
代码示例来源:origin: stackoverflow.com
String script = "function abc(x,y) {return x+y;}"
+ "function def(u,v) {return u-v;}";
Context context = Context.enter();
try {
ScriptableObject scope = context.initStandardObjects();
context.evaluateString(scope, script, "script", 1, null);
Function fct = (Function)scope.get("abc", scope);
Object result = fct.call(
context, scope, scope, new Object[] {2, 3});
System.out.println(Context.jsToJava(result, int.class));
} finally {
Context.exit();
}
代码示例来源:origin: org.freemarker/freemarker
public Object exec(List arguments) throws TemplateModelException {
Context cx = Context.getCurrentContext();
Object[] args = arguments.toArray();
BeansWrapper wrapper = getWrapper();
for (int i = 0; i < args.length; i++) {
args[i] = wrapper.unwrap((TemplateModel) args[i]);
}
return wrapper.wrap(((Function) getScriptable()).call(cx,
ScriptableObject.getTopLevelScope(fnThis), fnThis, args));
}
}
代码示例来源:origin: rnewson/couchdb-lucene
result = viewFun.call(context, scope, null, new Object[]{scriptable});
} catch (final JavaScriptException e) {
LOG.warn(doc + " caused exception during conversion.", e);
代码示例来源:origin: rhino/js
/**
* @see org.mozilla.javascript.Function#call
*/
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
Object[] args)
{
return ((Function)obj).call(cx,scope,thisObj,args);
}
代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik
public Object run(Context cx) {
handler.call(cx, globalObject, globalObject, args);
return null;
}
});
代码示例来源:origin: org.apache.xmlgraphics/batik-bridge
public Object run(Context cx) {
handler.call(cx, globalObject, globalObject, args);
return null;
}
});
代码示例来源:origin: rhino/js
/**
* @see org.mozilla.javascript.Function#call
*/
@Override
public Object call(Context cx, Scriptable scope, Scriptable thisObj,
Object[] args)
{
synchronized(thisObj instanceof Wrapper ? ((Wrapper)thisObj).unwrap() : thisObj) {
return ((Function)obj).call(cx,scope,thisObj,args);
}
}
}
代码示例来源:origin: org.apache.xmlgraphics/batik-bridge
public Object run(Context cx) {
Object a = Context.toObject(arg, globalObject);
Object[] args = { a };
handler.call(cx, globalObject, globalObject, args);
return null;
}
});
代码示例来源:origin: org.apache.druid/druid-processing
public boolean applyInContext(Context cx, Object input)
{
if (extractionFn != null) {
input = extractionFn.apply(input);
}
return Context.toBoolean(fnApply.call(cx, scope, scope, new Object[]{input}));
}
代码示例来源:origin: io.druid/druid-processing
public boolean applyInContext(Context cx, Object input)
{
if (extractionFn != null) {
input = extractionFn.apply(input);
}
return Context.toBoolean(fnApply.call(cx, scope, scope, new Object[]{input}));
}
代码示例来源:origin: org.apache.druid/java-util
@Override
public Object apply(Object input)
{
// ideally we need a close() function to discard the context once it is not used anymore
Context cx = Context.getCurrentContext();
if (cx == null) {
cx = contextFactory.enterContext();
}
final Object res = fn.call(cx, scope, scope, new Object[]{input});
return res != null ? Context.toObject(res, scope) : null;
}
};
代码示例来源:origin: io.druid/druid-processing
@Override
public String apply(Object input)
{
// ideally we need a close() function to discard the context once it is not used anymore
Context cx = Context.getCurrentContext();
if (cx == null) {
cx = contextFactory.enterContext();
}
final Object res = fn.call(cx, scope, scope, new Object[]{input});
return res != null ? Context.toString(res) : null;
}
};
代码示例来源:origin: datacleaner/DataCleaner
@Close
public void close() {
final Context context = _contextFactory.enterContext();
try {
_closeFunction.call(context, _sharedScope, _sharedScope, new Object[0]);
} finally {
Context.exit();
}
}
代码示例来源:origin: org.freemarker/com.springsource.freemarker
public Object exec(List arguments) throws TemplateModelException {
Context cx = Context.getCurrentContext();
Object[] args = arguments.toArray();
BeansWrapper wrapper = getWrapper();
for (int i = 0; i < args.length; i++) {
args[i] = wrapper.unwrap((TemplateModel)args[i]);
}
return wrapper.wrap(((Function)getScriptable()).call(cx,
ScriptableObject.getTopLevelScope(fnThis), fnThis, args));
}
}
代码示例来源:origin: io.apisense/rhino-android
private Object call(Function func, Object[] args) {
Context cx = Context.getCurrentContext();
Scriptable thisObj = getAdaptee();
Scriptable scope = func.getParentScope();
try {
return func.call(cx, scope, thisObj, args);
} catch (RhinoException re) {
throw Context.reportRuntimeError(re.getMessage());
}
}
内容来源于网络,如有侵权,请联系作者删除!