org.graalvm.polyglot.Value.isString()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(1.7k)|赞(0)|评价(0)|浏览(79)

本文整理了Java中org.graalvm.polyglot.Value.isString()方法的一些代码示例,展示了Value.isString()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Value.isString()方法的具体详情如下:
包路径:org.graalvm.polyglot.Value
类名称:Value
方法名:isString

Value.isString介绍

[英]Returns true if this value represents a string.
[中]如果此值表示字符串,则返回true

代码示例

代码示例来源:origin: org.graalvm.sdk/polyglot-tck

descs.add(NUMBER);
if (value.isString()) {
  descs.add(STRING);

代码示例来源:origin: org.graalvm/polyglot-tck

descs.add(NUMBER);
if (value.isString()) {
  descs.add(STRING);

代码示例来源:origin: reactiverse/es4x

@Override
 public Object transform(T jsObject) {

  final Value value = Value.asValue(jsObject);

  if (value.isHostObject() || value.isString() || value.isNumber() || value.isBoolean() || value.isNativePointer() || value.isProxyObject()) {
   throw new ClassCastException("type is not Object or Array");
  }

  if (value.isNull()) {
   return null;
  }

  final Context ctx = Context.getCurrent();
  String encoded = ctx.eval(stringify).execute(value).asString();

  char c = encoded.charAt(0);

  // encoded messages are expected not to be pretty printed
  if (c == '{') {
   return new JsonObject(encoded);
  }
  if (c == '[') {
   return new JsonArray(encoded);
  }

  throw new ClassCastException("type is not Object or Array");
 }
}

代码示例来源:origin: reactiverse/es4x

@Override
public void encodeToWire(Buffer buffer, T jsObject) {
 final Value value = Value.asValue(jsObject);
 if (value.isHostObject() || value.isString() || value.isNumber() || value.isBoolean() || value.isNativePointer() || value.isProxyObject()) {
  throw new ClassCastException("type is not Object or Array");
 }
 if (value.isNull()) {
  buffer.appendInt(0);
  return;
 }
 final Context ctx = Context.getCurrent();
 Buffer encoded = Buffer.buffer(ctx.eval(stringify).execute(value).asString());
 buffer.appendInt(encoded.length());
 buffer.appendBuffer(buffer);
}

相关文章