本文整理汇总了Java中jdk.nashorn.api.scripting.JSObject.getMember方法的典型用法代码示例。如果您正苦于以下问题:Java JSObject.getMember方法的具体用法?Java JSObject.getMember怎么用?Java JSObject.getMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.api.scripting.JSObject
的用法示例。
在下文中一共展示了JSObject.getMember方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProperty
import jdk.nashorn.api.scripting.JSObject; //导入方法依赖的package包/类
private static Object getProperty(final Object holder, final Object key) {
if (holder instanceof ScriptObject) {
return ((ScriptObject)holder).get(key);
} else if (holder instanceof JSObject) {
final JSObject jsObj = (JSObject)holder;
if (key instanceof Integer) {
return jsObj.getSlot((Integer)key);
} else {
return jsObj.getMember(Objects.toString(key));
}
} else {
return new AssertionError("should not reach here");
}
}
示例2: getProperty
import jdk.nashorn.api.scripting.JSObject; //导入方法依赖的package包/类
private static Object getProperty(final Object holder, final Object key) {
if (holder instanceof ScriptObject) {
return ((ScriptObject)holder).get(key);
} else if (holder instanceof JSObject) {
JSObject jsObj = (JSObject)holder;
if (key instanceof Integer) {
return jsObj.getSlot((Integer)key);
} else {
return jsObj.getMember(Objects.toString(key));
}
} else {
return new AssertionError("should not reach here");
}
}
示例3: getOptionalMember
import jdk.nashorn.api.scripting.JSObject; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static <T> T getOptionalMember( JSObject jsObject, String member, T defaultValue )
{
return jsObject.hasMember( member )
? (T)jsObject.getMember( member )
: defaultValue;
}
示例4: getMember
import jdk.nashorn.api.scripting.JSObject; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static <T> T getMember( JSObject jsObject, String member ) throws NoSuchFieldException
{
if ( jsObject.hasMember( member ) )
return (T)jsObject.getMember( member );
else
throw new NoSuchFieldException( member );
}
示例5: funcJSObject
import jdk.nashorn.api.scripting.JSObject; //导入方法依赖的package包/类
public static Object funcJSObject(final JSObject jsobj) {
return jsobj.getMember("foo");
}