本文整理汇总了Java中jdk.nashorn.internal.runtime.ScriptRuntime.builtinObjectToString方法的典型用法代码示例。如果您正苦于以下问题:Java ScriptRuntime.builtinObjectToString方法的具体用法?Java ScriptRuntime.builtinObjectToString怎么用?Java ScriptRuntime.builtinObjectToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.runtime.ScriptRuntime
的用法示例。
在下文中一共展示了ScriptRuntime.builtinObjectToString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toString
import jdk.nashorn.internal.runtime.ScriptRuntime; //导入方法依赖的package包/类
/**
* ECMA 15.4.4.2 Array.prototype.toString ( )
*
* @param self self reference
* @return string representation of array
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object toString(final Object self) {
final Object obj = Global.toObject(self);
if (obj instanceof ScriptObject) {
final InvokeByName joinInvoker = getJOIN();
final ScriptObject sobj = (ScriptObject)obj;
try {
final Object join = joinInvoker.getGetter().invokeExact(sobj);
if (Bootstrap.isCallable(join)) {
return joinInvoker.getInvoker().invokeExact(join, sobj);
}
} catch (final RuntimeException | Error e) {
throw e;
} catch (final Throwable t) {
throw new RuntimeException(t);
}
}
// FIXME: should lookup Object.prototype.toString and call that?
return ScriptRuntime.builtinObjectToString(self);
}
示例2: toLocaleString
import jdk.nashorn.internal.runtime.ScriptRuntime; //导入方法依赖的package包/类
/**
* ECMA 15.2.4.3 Object.prototype.toLocaleString ( )
*
* @param self self reference
* @return localized ToString
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object toLocaleString(final Object self) {
final Object obj = JSType.toScriptObject(self);
if (obj instanceof ScriptObject) {
final InvokeByName toStringInvoker = getTO_STRING();
final ScriptObject sobj = (ScriptObject)self;
try {
final Object toString = toStringInvoker.getGetter().invokeExact(sobj);
if (Bootstrap.isCallable(toString)) {
return toStringInvoker.getInvoker().invokeExact(toString, sobj);
}
} catch (final RuntimeException | Error e) {
throw e;
} catch (final Throwable t) {
throw new RuntimeException(t);
}
throw typeError("not.a.function", "toString");
}
return ScriptRuntime.builtinObjectToString(self);
}
示例3: toLocaleString
import jdk.nashorn.internal.runtime.ScriptRuntime; //导入方法依赖的package包/类
/**
* ECMA 15.2.4.3 Object.prototype.toLocaleString ( )
*
* @param self self reference
* @return localized ToString
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static Object toLocaleString(final Object self) {
final Object obj = JSType.toScriptObject(self);
if (obj instanceof ScriptObject) {
final InvokeByName toStringInvoker = getTO_STRING();
final ScriptObject sobj = (ScriptObject)obj;
try {
final Object toString = toStringInvoker.getGetter().invokeExact(sobj);
if (Bootstrap.isCallable(toString)) {
return toStringInvoker.getInvoker().invokeExact(toString, sobj);
}
} catch (final RuntimeException | Error e) {
throw e;
} catch (final Throwable t) {
throw new RuntimeException(t);
}
throw typeError("not.a.function", "toString");
}
return ScriptRuntime.builtinObjectToString(self);
}
示例4: toString
import jdk.nashorn.internal.runtime.ScriptRuntime; //导入方法依赖的package包/类
/**
* ECMA 15.2.4.2 Object.prototype.toString ( )
*
* @param self self reference
* @return ToString of object
*/
@Function(attributes = Attribute.NOT_ENUMERABLE)
public static String toString(final Object self) {
return ScriptRuntime.builtinObjectToString(self);
}