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

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

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

JSObject.keySet介绍

暂无

代码示例

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

@Override
public Set<String> getKeys()
{
  return this.value.keySet();
}

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

@Override
public Set<String> keySet() {
  return delegate.keySet();
}

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

@Override
public DynaProperty[] getDynaProperties() {
  if (properties.isEmpty()) {
    delegate.keySet().forEach((String key) -> {
      Object oMember = delegate.getMember(key);
      if (!(oMember instanceof JSObject) || !((JSObject) oMember).isFunction()) {
        properties.put(key, new DynaProperty(key));
      }
    });
  }
  return properties.values().toArray(new DynaProperty[]{});
}

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

protected void generateDataNamedMap(XLSTransformer aTransformer) throws Exception {
    generated = new HashMap<>();
    if (scriptData != null) {
      scriptData.keySet().stream().forEach((sid) -> {
        Object subject = scriptData.getMember(sid);
        generated.put(sid, JSDynaBean.wrap(subject, template.getTimezoneOffset()));
      });
    }
  }
}

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

protected List<ChangeValue> parseObjectProperties(Object oData) throws Exception {
  List<ChangeValue> data = new ArrayList<>();
  if (oData instanceof JSObject) {
    JSObject sValue = (JSObject) oData;
    sValue.keySet().stream().forEach((sValueName) -> {
      Object oValueValue = sValue.getMember(sValueName);
      Object convertedValueValue = space.toJava(oValueValue);
      data.add(new ChangeValue(sValueName, convertedValueValue));
    });
  }
  return data;
}

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

Map<String, Object> headers = new HashMap<>();
if (aHeaders != null) {
  aHeaders.keySet().stream().forEach((String aKey) -> {
    Object oValue = space.toJava(aHeaders.getMember(aKey));
    if (oValue != null) {

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

@ScriptFunction(jsDoc = ENQUEUE_UPDATE_JSDOC, params = {"params"})
@Override
public void enqueueUpdate(JSObject aParams) throws Exception {
  if (aParams != null) {
    PlatypusQuery copied = query.copy();
    aParams.keySet().forEach((String pName) -> {
      Parameter p = copied.getParameters().get(pName);
      if (p != null) {
        Object jsValue = aParams.getMember(pName);
        p.setValue(jsValue);// .toJava is inside prepreCommand()
      }
    });
    model.getChangeLog().add(copied.prepareCommand());
  } else {
    model.getChangeLog().add(query.prepareCommand());
  }
}

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

@ScriptFunction(jsDoc = ENQUEUE_UPDATE_JSDOC, params = {"params"})
@Override
public void enqueueUpdate(JSObject aParams) throws Exception {
  SqlQuery copied = query.copy();
  if (aParams != null) {
    aParams.keySet().forEach((String pName) -> {
      Parameter p = copied.getParameters().get(pName);
      if (p != null) {
        Object jsValue = aParams.getMember(pName);
        // .toJava() call is inside compile().
        p.setValue(jsValue);
      }
    });
  }
  // WARNING! Don't change copied.compile(Scripts.getSpace()) to copied.compile().
  // Not all parameters may be metioned in aParams object, so entity.params will be taken partially.
  // aParams argument may be omitted, and so, all parameters will be taken from entity.params.
  SqlCompiledQuery compiled = copied.compile(Scripts.getSpace());
  Command command = compiled.prepareCommand();
  List<Change> log = getChangeLog();
  log.add(command);
}

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

@ScriptFunction(jsDoc = QUERY_JSDOC, params = {"params", "onSuccess", "onFailure"})
public JSObject query(JSObject aParams, JSObject aOnSuccess, JSObject aOnFailure) throws Exception {
  Query copied = query.copy();
  aParams.keySet().forEach((String pName) -> {
    Parameter p = copied.getParameters().get(pName);
    if (p != null) {
      Object jsValue = aParams.getMember(pName);
      p.setValue(Scripts.getSpace().toJava(jsValue));
    }
  });
  return copied.execute(Scripts.getSpace(), aOnSuccess != null ? (JSObject v) -> {
    aOnSuccess.call(null, new Object[]{v});
  } : null, aOnFailure != null ? (Exception ex) -> {
    aOnFailure.call(null, new Object[]{ex.getMessage()});
  } : null);
}

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

@ScriptFunction(jsDoc = UPDATE_JSDOC, params = {"params", "onSuccess", "onFailure"})
@Override
public int update(JSObject aParams, JSObject aOnSuccess, JSObject aOnFailure) throws Exception {
  PlatypusQuery copied = query.copy();
  aParams.keySet().forEach((String pName) -> {
    Parameter p = copied.getParameters().get(pName);
    if (p != null) {
      Object jsValue = aParams.getMember(pName);
      p.setValue(Scripts.getSpace().toJava(jsValue));
    }
  });
  List<Change> localLog = new ArrayList<>();
  localLog.add(copied.prepareCommand());
  if (aOnSuccess != null) {
    return model.serverProxy.commit(localLog, Scripts.getSpace(), (Integer aUpdated) -> {
      aOnSuccess.call(null, new Object[]{aUpdated});
    }, (Exception ex) -> {
      if (aOnFailure != null) {
        aOnFailure.call(null, new Object[]{ex.getMessage()});
      }
    });
  } else {
    return model.serverProxy.commit(localLog, Scripts.getSpace(), null, null);
  }
}

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

@ScriptFunction(jsDoc = UPDATE_JSDOC, params = {"params", "onSuccess", "onFailure"})
@Override
public int update(JSObject aParams, JSObject onSuccess, JSObject onFailure) throws Exception {
  SqlQuery copied = query.copy();
  aParams.keySet().forEach((String pName) -> {
    Parameter p = copied.getParameters().get(pName);
    if (p != null) {
      Object jsValue = aParams.getMember(pName);
      p.setValue(Scripts.getSpace().toJava(jsValue));
    }
  });
  SqlCompiledQuery compiled = copied.compile();
  if (onSuccess != null) {
    model.getBasesProxy().executeUpdate(compiled, (Integer aUpdated) -> {
      onSuccess.call(null, new Object[]{aUpdated});
    }, (Exception ex) -> {
      if (onFailure != null) {
        onFailure.call(null, new Object[]{ex.getMessage()});
      }
    });
    return 0;
  } else {
    return model.getBasesProxy().executeUpdate(compiled, null, null);
  }
}

相关文章