jdk.nashorn.api.scripting.JSObject.call()方法的使用及代码示例

x33g5p2x  于2022-01-22 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(226)

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

JSObject.call介绍

暂无

代码示例

代码示例来源:origin: spullara/mustache.java

@Override
 public String apply(String s) {
  Object call = jso.call(jso, s);
  return call == null ? null : call.toString();
 }
};

代码示例来源:origin: spullara/mustache.java

@Override
public String stringify(Object object) {
 if (object instanceof JSObject) {
  final JSObject jso = (JSObject) object;
  if (jso.isFunction()) {
   Object call = jso.call(jso);
   return stringify(coerce(call));
  }
 }
 return super.stringify(object);
}

代码示例来源:origin: com.enonic.xp/portal-script

@Override
  public Object call( final Object thiz, final Object... args )
  {
    final JSObject func = (JSObject) args[0];
    final Object[] array = (Object[]) args[1];

    final Object[] jsArray = JsObjectConverter.toJsArray( array );
    return func.call( thiz, jsArray );
  }
}

代码示例来源:origin: com.eas.platypus/platypus-js-common-utils

public Object toJava(Object aValue) {
  if (aValue instanceof ScriptObject) {
    aValue = ScriptUtils.wrap((ScriptObject) aValue);
  }
  if (aValue instanceof JSObject) {
    assert toPrimitiveFunc != null : SCRIPT_NOT_INITIALIZED;
    aValue = toPrimitiveFunc.call(null, new Object[]{aValue});
  } else if (aValue == ScriptRuntime.UNDEFINED) {
    return null;
  }
  return aValue;
}

代码示例来源:origin: com.eas.platypus/platypus-js-common-utils

public Object toJs(Object aValue) {
  if (aValue instanceof Date) {// force js boxing of date, because of absence js literal of date value
    assert toDateFunc != null : SCRIPT_NOT_INITIALIZED;
    return toDateFunc.call(null, aValue);
  } else if (aValue instanceof Number) {
    return ((Number) aValue).doubleValue();
  } else if (aValue instanceof HasPublished) {
    return ((HasPublished) aValue).getPublished();
  } else {
    return aValue;
  }
}

代码示例来源:origin: com.eas.platypus/platypus-js-common-utils

public String toJson(Object aObj) {
  assert writeJsonFunc != null : SCRIPT_NOT_INITIALIZED;
  if (aObj instanceof Undefined) {//nashorn JSON parser could not work with undefined.
    aObj = null;
  }
  if (aObj instanceof JSObject || aObj instanceof CharSequence
      || aObj instanceof Number || aObj instanceof Boolean || aObj instanceof ScriptObject || aObj == null) {
    return JSType.toString(writeJsonFunc.call(null, new Object[]{aObj}));
  } else {
    throw new IllegalArgumentException("Java object couldn't be converted to JSON!");
  }
}

代码示例来源:origin: com.eas.platypus/platypus-js-common-utils

@Override
public void completed(Integer result, Object attachment) {
  callingSpace.process(callingContext, () -> {
    if (aOnSuccess != null) {
      aOnSuccess.call(null, new Object[]{result});
    }
  });
}

代码示例来源:origin: com.eas.platypus/platypus-js-scripting

public static Object load(final String aResourceName, String aCalledFromFile, JSObject aOnSuccess, JSObject aOnFailure) throws Exception {
  Scripts.Space space = Scripts.getSpace();
  return _load(aResourceName, aCalledFromFile, space, aOnSuccess != null ? (Object aLoaded) -> {
    aOnSuccess.call(null, new Object[]{space.toJs(aLoaded)});
  } : null, aOnFailure != null ? (Exception ex) -> {
    aOnFailure.call(null, new Object[]{space.toJs(ex.getMessage())});
  } : null);
}

代码示例来源:origin: com.eas.platypus/platypus-js-common-utils

public JSObject readJsArray(Collection<Map<String, Object>> aCollection) {
  JSObject result = makeArray();
  JSObject jsPush = (JSObject) result.getMember("push");
  aCollection.forEach((Map<String, Object> aItem) -> {
    JSObject jsItem = makeObj();
    aItem.entrySet().forEach((Map.Entry<String, Object> aItemContent) -> {
      jsItem.setMember(aItemContent.getKey(), toJs(aItemContent.getValue()));
    });
    jsPush.call(result, new Object[]{jsItem});
  });
  return result;
}

代码示例来源:origin: com.eas.platypus/platypus-js-core

@Override
public JSObject getPublished() {
  if (published == null) {
    JSObject publisher = Scripts.getSpace().getPublisher(this.getClass().getName());
    if (publisher == null || !publisher.isFunction()) {
      throw new NoPublisherException();
    }
    published = (JSObject) publisher.call(null, new Object[]{this});
  }
  return published;
}

代码示例来源:origin: com.eas.platypus/platypus-js-core

@Override
public JSObject getPublished() {
  if (published == null) {
    JSObject publisher = Scripts.getSpace().getPublisher(this.getClass().getName());
    if (publisher == null || !publisher.isFunction()) {
      throw new NoPublisherException();
    }
    published = (JSObject) publisher.call(null, new Object[]{this});
  }
  return published;
}

代码示例来源:origin: com.eas.platypus/platypus-js-datamodel

@Override
public JSObject getPublished() {
  if (published == null) {
    JSObject publisher = Scripts.getSpace().getPublisher(this.getClass().getName());
    if (publisher == null || !publisher.isFunction()) {
      throw new NoPublisherException();
    }
    published = (JSObject) publisher.call(null, new Object[]{this});
  }
  return published;
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@Override
public JSObject getPublished() {
  if (published == null) {
    JSObject publisher = Scripts.getSpace().getPublisher(this.getClass().getName());
    if (publisher == null || !publisher.isFunction()) {
      throw new NoPublisherException();
    }
    published = (JSObject) publisher.call(null, new Object[]{this});
  }
  return published;
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@Override
public JSObject getPublished() {
  if (published == null) {
    JSObject publisher = Scripts.getSpace().getPublisher(this.getClass().getName());
    if (publisher == null || !publisher.isFunction()) {
      throw new NoPublisherException();
    }
    published = (JSObject) publisher.call(null, new Object[]{this});
  }
  return published;
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@Override
public JSObject getPublished() {
  if (published == null) {
    JSObject publisher = Scripts.getSpace().getPublisher(this.getClass().getName());
    if (publisher == null || !publisher.isFunction()) {
      throw new NoPublisherException();
    }
    published = (JSObject) publisher.call(null, new Object[]{this});
  }
  return published;
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@Override
public JSObject getPublished() {
  if (published == null) {
    JSObject publisher = Scripts.getSpace().getPublisher(this.getClass().getName());
    if (publisher == null || !publisher.isFunction()) {
      throw new NoPublisherException();
    }
    published = (JSObject) publisher.call(null, new Object[]{this});
  }
  return published;
}

代码示例来源:origin: com.eas.platypus/platypus-js-servlet

@Override
  public JSObject getPublished() {
    if (published == null) {
      JSObject publisher = Scripts.getSpace().getPublisher(this.getClass().getName());
      if (publisher == null || !publisher.isFunction()) {
        throw new NoPublisherException();
      }
      published = (JSObject) publisher.call(null, new Object[]{this});
    }
    return published;
  }
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@Override
public JSObject getPublished() {
  if (published == null) {
    JSObject publisher = Scripts.getSpace().getPublisher(this.getClass().getName());
    if (publisher == null || !publisher.isFunction()) {
      throw new NoPublisherException();
    }
    published = (JSObject) publisher.call(null, new Object[]{this});
  }
  return published;
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@Override
public JSObject getPublished() {
  if (published == null) {
    JSObject publisher = Scripts.getSpace().getPublisher(this.getClass().getName());
    if (publisher == null || !publisher.isFunction()) {
      throw new NoPublisherException();
    }
    published = (JSObject) publisher.call(null, new Object[]{this});
  }
  return published;
}

代码示例来源:origin: com.eas.platypus/platypus-js-forms

@Override
public JSObject getPublished() {
  if (published == null) {
    JSObject publisher = Scripts.getSpace().getPublisher(this.getClass().getName());
    if (publisher == null || !publisher.isFunction()) {
      throw new NoPublisherException();
    }
    published = (JSObject) publisher.call(null, new Object[]{this});
  }
  return published;
}

相关文章