本文整理匯總了Java中jdk.nashorn.api.scripting.ScriptObjectMirror.values方法的典型用法代碼示例。如果您正苦於以下問題:Java ScriptObjectMirror.values方法的具體用法?Java ScriptObjectMirror.values怎麽用?Java ScriptObjectMirror.values使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類jdk.nashorn.api.scripting.ScriptObjectMirror
的用法示例。
在下文中一共展示了ScriptObjectMirror.values方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAsList
import jdk.nashorn.api.scripting.ScriptObjectMirror; //導入方法依賴的package包/類
public List getAsList() {
switch (type) {
case JS_ARRAY:
ScriptObjectMirror som = (ScriptObjectMirror) value;
return new ArrayList(som.values());
case LIST:
return getValue(List.class);
case JSON:
DocumentContext doc = (DocumentContext) value;
return doc.json();
default:
throw new RuntimeException("cannot convert to list: " + this);
}
}
示例2: call
import jdk.nashorn.api.scripting.ScriptObjectMirror; //導入方法依賴的package包/類
public static ScriptValue call(String name, String argString, ScriptContext context, boolean reuseParentConfig) {
ScriptValue argValue = evalKarateExpression(argString, context);
ScriptValue sv = evalKarateExpression(name, context);
switch (sv.getType()) {
case JS_FUNCTION:
switch (argValue.getType()) {
case JSON:
// force to java map (or list)
argValue = new ScriptValue(argValue.getValue(DocumentContext.class).read("$"));
case JS_ARRAY:
case JS_OBJECT:
case MAP:
case LIST:
case STRING:
case INPUT_STREAM:
case PRIMITIVE:
case NULL:
break;
default:
throw new RuntimeException("only json or primitives allowed as (single) function call argument");
}
ScriptObjectMirror som = sv.getValue(ScriptObjectMirror.class);
return evalFunctionCall(som, argValue.getValue(), context);
case FEATURE_WRAPPER:
Object callArg = null;
switch (argValue.getType()) {
case LIST:
callArg = argValue.getValue(List.class);
break;
case JSON:
callArg = argValue.getValue(DocumentContext.class).read("$");
break;
case MAP:
callArg = argValue.getValue(Map.class);
break;
case JS_OBJECT:
callArg = argValue.getValue(ScriptObjectMirror.class);
break;
case JS_ARRAY:
ScriptObjectMirror temp = argValue.getValue(ScriptObjectMirror.class);
callArg = temp.values();
break;
case NULL:
break;
default:
throw new RuntimeException("only json, list/array or map allowed as feature call argument");
}
FeatureWrapper feature = sv.getValue(FeatureWrapper.class);
return evalFeatureCall(feature, callArg, context, reuseParentConfig);
default:
context.logger.warn("not a js function or feature file: {} - {}", name, sv);
return ScriptValue.NULL;
}
}