本文整理汇总了Java中jdk.nashorn.internal.runtime.JSType.isString方法的典型用法代码示例。如果您正苦于以下问题:Java JSType.isString方法的具体用法?Java JSType.isString怎么用?Java JSType.isString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jdk.nashorn.internal.runtime.JSType
的用法示例。
在下文中一共展示了JSType.isString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findGetIndexMethod
import jdk.nashorn.internal.runtime.JSType; //导入方法依赖的package包/类
@Override
protected GuardedInvocation findGetIndexMethod(final CallSiteDescriptor desc, final LinkRequest request) {
final Object self = request.getReceiver();
final Class<?> returnType = desc.getMethodType().returnType();
if (returnType == Object.class && JSType.isString(self)) {
try {
return new GuardedInvocation(MH.findStatic(MethodHandles.lookup(), NativeString.class, "get", desc.getMethodType()), NashornGuards.getStringGuard());
} catch (final LookupException e) {
//empty. Shouldn't happen. Fall back to super
}
}
return super.findGetIndexMethod(desc, request);
}
示例2: getCharSequence
import jdk.nashorn.internal.runtime.JSType; //导入方法依赖的package包/类
private static CharSequence getCharSequence(final Object self) {
if (JSType.isString(self)) {
return (CharSequence)self;
} else if (self instanceof NativeString) {
return ((NativeString)self).getValue();
} else if (self != null && self == Global.instance().getStringPrototype()) {
return "";
} else {
throw typeError("not.a.string", ScriptRuntime.safeToString(self));
}
}
示例3: construct
import jdk.nashorn.internal.runtime.JSType; //导入方法依赖的package包/类
/**
* Constructor - ECMA 15.9.3.1 new Date (year, month [, date [, hours [, minutes [, seconds [, ms ] ] ] ] ] )
*
* @param isNew is this Date constructed with the new operator
* @param self self reference
* @param args arguments
* @return new Date
*/
@Constructor(arity = 7)
public static Object construct(final boolean isNew, final Object self, final Object... args) {
if (! isNew) {
return toStringImpl(new NativeDate(), FORMAT_DATE_TIME);
}
NativeDate result;
switch (args.length) {
case 0:
result = new NativeDate();
break;
case 1:
double num;
final Object arg = JSType.toPrimitive(args[0]);
if (JSType.isString(arg)) {
num = parseDateString(arg.toString());
} else {
num = timeClip(JSType.toNumber(args[0]));
}
result = new NativeDate(num);
break;
default:
result = new NativeDate(0);
final double[] d = convertCtorArgs(args);
if (d == null) {
result.setTime(Double.NaN);
} else {
final double time = timeClip(utc(makeDate(d), result.getTimeZone()));
result.setTime(time);
}
break;
}
return result;
}
示例4: isJavaScriptPrimitive
import jdk.nashorn.internal.runtime.JSType; //导入方法依赖的package包/类
@SuppressWarnings("unused")
private static boolean isJavaScriptPrimitive(final Object o) {
return JSType.isString(o) || o instanceof Boolean || JSType.isNumber(o) || o == null || o instanceof Symbol;
}