org.kohsuke.stapler.StaplerRequest.bindJSONToList()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(94)

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

StaplerRequest.bindJSONToList介绍

[英]Data-bind from either JSONObject or JSONArray to a list, by using #bindJSON(Class,JSONObject) as the lower-level mechanism.

If the source is JSONObject, the returned list will contain a single item. If it is JSONArray, each item will be bound. If it is null, then the list will be empty.
[中]通过使用#bindJSON(类,JSONObject)作为低级机制,数据从JSONObject或JSONArray绑定到列表。
如果源是JSONObject,则返回的列表将包含单个项。如果是JSONArray,则每个项目都将被绑定。如果为空,则列表将为空。

代码示例

代码示例来源:origin: jenkinsci/jenkins

@Override
@SuppressWarnings("unchecked") // cast to T[]
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
  setInstallations(req.bindJSONToList(clazz, json.get("tool")).toArray((T[]) Array.newInstance(clazz, 0)));
  return true;
}

代码示例来源:origin: jenkinsci/jenkins

/**
 * Accepts submission from the configuration page.
 */
@RequirePOST
public synchronized void doConfigSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
  JSONObject src = req.getSubmittedForm();
  String newName = src.getString("name"), redirect = ".";
  XmlFile oldFile = null;
  if(!name.equals(newName)) {
    Jenkins.checkGoodName(newName);
    oldFile = getConfigFile();
    // rename
    getParent().logRecorders.remove(name);
    this.name = newName;
    getParent().logRecorders.put(name,this);
    redirect = "../" + Util.rawEncode(newName) + '/';
  }
  List<Target> newTargets = req.bindJSONToList(Target.class, src.get("targets"));
  for (Target t : newTargets)
    t.enable();
  targets.replaceBy(newTargets);
  save();
  if (oldFile!=null) oldFile.delete();
  rsp.sendRedirect2(redirect);
}

代码示例来源:origin: jenkinsci/gitlab-plugin

@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
  connections = req.bindJSONToList(GitLabConnection.class, json.get("connections"));
  useAuthenticatedEndpoint = json.getBoolean("useAuthenticatedEndpoint");
  refreshConnectionMap();
  save();
  return super.configure(req, json);
}

代码示例来源:origin: jenkinsci/email-ext-plugin

@Override
  public UserProperty newInstance(StaplerRequest req, JSONObject json) throws FormException {
    List<EmailTrigger> triggers = req != null ? req.bindJSONToList(EmailTrigger.class, json) : Collections.<EmailTrigger>emptyList();
    return new UserProperty(triggers);
  }
}

代码示例来源:origin: hudson/hudson-2.x

@Override
@SuppressWarnings("unchecked") // cast to T[]
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
  setInstallations(req.bindJSONToList(clazz, json.get("tool")).toArray((T[]) Array.newInstance(clazz, 0)));
  return true;
}

代码示例来源:origin: org.jenkins-ci.main/jenkins-core

@Override
@SuppressWarnings("unchecked") // cast to T[]
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
  setInstallations(req.bindJSONToList(clazz, json.get("tool")).toArray((T[]) Array.newInstance(clazz, 0)));
  return true;
}

代码示例来源:origin: org.jvnet.hudson.main/hudson-core

@Override
@SuppressWarnings("unchecked") // cast to T[]
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
  setInstallations(req.bindJSONToList(clazz, json.get("tool")).toArray((T[]) Array.newInstance(clazz, 0)));
  return true;
}

代码示例来源:origin: org.eclipse.hudson/hudson-core

@Override
  @SuppressWarnings("unchecked") // cast to T[]
  public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
    setInstallations(req.bindJSONToList(clazz, json.get("tool")).toArray((T[]) Array.newInstance(clazz, 0)));
    return true;
  }
}

代码示例来源:origin: org.eclipse.hudson.main/hudson-core

@Override
@SuppressWarnings("unchecked") // cast to T[]
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
  setInstallations(req.bindJSONToList(clazz, json.get("tool")).toArray((T[]) Array.newInstance(clazz, 0)));
  return true;
}

代码示例来源:origin: org.jenkins-ci.plugins/metrics

@Override
public synchronized boolean configure(StaplerRequest req, JSONObject json) throws FormException {
  accessKeys = req.bindJSONToList(MetricsAccessKey.class, json.get("accessKeys"));
  accessKeySet = null;
  save();
  return true;
}

代码示例来源:origin: SonarSource/sonar-scanner-jenkins

@Override
public boolean configure(StaplerRequest req, JSONObject json) {
 List<SonarInstallation> list = req.bindJSONToList(SonarInstallation.class, json.get("inst"));
 boolean enableBuildWrapper = json.getBoolean("enableBuildWrapper");
 setInstallations(list.toArray(new SonarInstallation[list.size()]));
 setBuildWrapperEnabled(enableBuildWrapper);
 return true;
}

代码示例来源:origin: org.hudsonci.plugins/warnings

@Override
public boolean configure(final StaplerRequest req, final JSONObject formData) {
  groovyParsers.replaceBy(req.bindJSONToList(GroovyParser.class, formData.get("parsers")));
  save();
  return true;
}

代码示例来源:origin: org.jenkins-ci.plugins/ansicolor

@Override
public boolean configure(final StaplerRequest req, final JSONObject formData) throws FormException {
  try {
    setColorMaps(req.bindJSONToList(AnsiColorMap.class,
        req.getSubmittedForm().get("colorMap")).toArray(new AnsiColorMap[1]));
    return true;
  } catch (ServletException e) {
    throw new FormException(e, "");
  }
}

代码示例来源:origin: org.jvnet.hudson.plugins/jira

@Override
  public boolean configure(StaplerRequest req, JSONObject formData) {
    sites.replaceBy(req.bindJSONToList(JiraSite.class, formData.get("sites")));
    save();
    return true;
  }
}

代码示例来源:origin: jenkinsci/jclouds-plugin

@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
  setProfiles(req.bindJSONToList(BlobStoreProfile.class, formData.get("profiles")));
  save();
  return true;
}

代码示例来源:origin: jenkinsci/debian-package-builder-plugin

@Override
public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
  repos = req.bindJSONToList(DebianPackageRepo.class, formData.get("repositories"));
  save();
  return super.configure(req,formData);
}

代码示例来源:origin: org.jvnet.hudson.plugins/ansicolor

@Override
public boolean configure(final StaplerRequest req, final JSONObject formData) throws FormException {
  try {
    setColorMaps(req.bindJSONToList(AnsiColorMap.class,
      req.getSubmittedForm().get("colorMap")).toArray(new AnsiColorMap[0]));
    return true;
  } catch (ServletException e) {
    throw new FormException(e, "");
  }
}

代码示例来源:origin: Diabol/delivery-pipeline-plugin

@Override
protected void submit(StaplerRequest req) throws IOException, ServletException, Descriptor.FormException {
  req.bindJSON(this, req.getSubmittedForm());
  componentSpecs = req.bindJSONToList(ComponentSpec.class, req.getSubmittedForm().get("componentSpecs"));
  regexpFirstJobs = req.bindJSONToList(RegExpSpec.class, req.getSubmittedForm().get("regexpFirstJobs"));
}

代码示例来源:origin: jenkinsci/ansicolor-plugin

@Override
public boolean configure(final StaplerRequest req, final JSONObject formData) throws FormException {
  try {
    setColorMaps(req.bindJSONToList(AnsiColorMap.class,
        req.getSubmittedForm().get("colorMap")).toArray(new AnsiColorMap[1]));
    return true;
  } catch (ServletException e) {
    throw new FormException(e, "");
  }
}

代码示例来源:origin: Diabol/delivery-pipeline-plugin

@Override
protected void submit(StaplerRequest req) throws IOException, ServletException, Descriptor.FormException {
  req.bindJSON(this, req.getSubmittedForm());
  componentSpecs = req.bindJSONToList(ComponentSpec.class, req.getSubmittedForm().get("componentSpecs"));
}

相关文章

微信公众号

最新文章

更多

StaplerRequest类方法