net.sf.json.JSONArray.isEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.6k)|赞(0)|评价(0)|浏览(102)

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

JSONArray.isEmpty介绍

暂无

代码示例

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

private void updateUpToDate() {
  // If we don't have any platform plugins, it's considered 'up to date' in terms
  // of the updater
  try {
    JSONArray platformPlugins = Jenkins.getInstance().getSetupWizard().getPlatformPluginUpdates();
    isUpToDate = platformPlugins.isEmpty();
  } catch(Exception e) {
    LOGGER.log(Level.WARNING, "Unable to get the platform plugin update list.", e);
  }
}

代码示例来源:origin: jenkinsci/configuration-as-code-plugin

public FormValidation doCheckNewSource(@QueryParameter String newSource){
  Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
  String normalized = Util.fixEmptyAndTrim(newSource);
  File f = new File(newSource);
  if (normalized == null) {
    return FormValidation.ok(); // empty, do nothing
  } else if (!f.exists() && !ConfigurationAsCode.isSupportedURI(normalized)) {
    return FormValidation.error("Configuration cannot be applied. File or URL cannot be parsed or do not exist.");
  }
  try {
    final Map<Source, String> issues = collectIssues(newSource);
    final JSONArray errors = collectProblems(issues, "error");
    if (!errors.isEmpty()) {
      return FormValidation.error(errors.toString());
    }
    final JSONArray warnings = collectProblems(issues, "warning");
    if (!warnings.isEmpty()) {
      return FormValidation.warning(warnings.toString());
    }
    return FormValidation.okWithMarkup("The configuration can be applied");
  } catch (ConfiguratorException e) {
    return FormValidation.error(e, e.getCause().getMessage());
  } catch (IllegalArgumentException e) {
    return FormValidation.error(e, e.getCause().getMessage());
  }
}

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

@Override
public void initializeState() {
  applyForcedChanges();
  
  // Initializing this state is directly related to 
  // running the detached plugin checks, these should be consolidated somehow
  updateUpToDate();
  
  // If there are no platform updates, proceed to running
  if (isUpToDate) {
    if (Jenkins.getInstance().getSetupWizard().getPlatformPluginUpdates().isEmpty()) {
      Jenkins.getInstance().setInstallState(InstallState.RUNNING);
    }
  }
}

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

if (plugins.isEmpty()) {
  categoryIterator.remove();

代码示例来源:origin: aliyun/aliyun-log-java-sdk

public static <T> List<T> readList(JSONArray list, Unmarshaller<T> unmarshaller) {
  if (list == null || list.isEmpty()) {
    return Collections.emptyList();
  }
  List<T> values = new ArrayList<T>(list.size());
  for (int i = 0; i < list.size(); i++) {
    values.add(unmarshaller.unmarshal(list, i));
  }
  return values;
}

代码示例来源:origin: com.aliyun.openservices/aliyun-log

public static <T> List<T> readList(JSONArray list, Unmarshaller<T> unmarshaller) {
  if (list == null || list.isEmpty()) {
    return Collections.emptyList();
  }
  List<T> values = new ArrayList<T>(list.size());
  for (int i = 0; i < list.size(); i++) {
    values.add(unmarshaller.unmarshal(list, i));
  }
  return values;
}

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

private void updateUpToDate() {
  // If we don't have any platform plugins, it's considered 'up to date' in terms
  // of the updater
  try {
    JSONArray platformPlugins = Jenkins.getInstance().getSetupWizard().getPlatformPluginUpdates();
    isUpToDate = platformPlugins.isEmpty();
  } catch(Exception e) {
    LOGGER.log(Level.WARNING, "Unable to get the platform plugin update list.", e);
  }
}

代码示例来源:origin: com.blazemeter/blazemeter-api-client

protected BuildResult checkFailsAndError(JSONObject ciStatus) {
  if (ciStatus.has("failures")) {
    JSONArray failures = ciStatus.getJSONArray("failures");
    if (!failures.isEmpty()) {
      return notifyAboutFailed(failures);
    }
  }
  if (ciStatus.has("errors")) {
    JSONArray errors = ciStatus.getJSONArray("errors");
    if (!errors.isEmpty()) {
      return notifyAboutErrors(errors);
    }
  }
  return BuildResult.SUCCESS;
}

代码示例来源:origin: io.jenkins/configuration-as-code

public FormValidation doCheckNewSource(@QueryParameter String newSource){
  Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
  String normalized = Util.fixEmptyAndTrim(newSource);
  File f = new File(newSource);
  if (normalized == null) {
    return FormValidation.ok(); // empty, do nothing
  } else if (!f.exists() && !ConfigurationAsCode.isSupportedURI(normalized)) {
    return FormValidation.error("Configuration cannot be applied. File or URL cannot be parsed or do not exist.");
  }
  try {
    final Map<Source, String> issues = collectIssues(newSource);
    final JSONArray errors = collectProblems(issues, "error");
    if (!errors.isEmpty()) {
      return FormValidation.error(errors.toString());
    }
    final JSONArray warnings = collectProblems(issues, "warning");
    if (!warnings.isEmpty()) {
      return FormValidation.warning(warnings.toString());
    }
    return FormValidation.okWithMarkup("The configuration can be applied");
  } catch (ConfiguratorException e) {
    return FormValidation.error(e, e.getCause().getMessage());
  } catch (IllegalArgumentException e) {
    return FormValidation.error(e, e.getCause().getMessage());
  }
}

代码示例来源:origin: com.blazemeter/blazemeter-api-client

protected boolean checkFileValidation(String fileName, JSONObject object) {
  int status = object.getInt("status");
  if (status >= 100) {
    JSONArray errors = object.getJSONArray("errors");
    if (!errors.isEmpty()) {
      notifier.notifyError(String.format("Validation error: file=%s; errors=%s", fileName, errors));
      logger.error(String.format("Validation error: file=%s; errors=%s", fileName, errors));
      throw new ValidationException(String.format("Validation error: file=%s; errors=%s", fileName, errors));
    }
    logger.info("File " + fileName + " successfully validated");
    return true;
  } else {
    logger.info("Validation for file=" + fileName + " is not ready. status=" + status);
    return false;
  }
}

代码示例来源:origin: com.blazemeter/blazemeter-api-client

protected boolean checkErrorCode(JSONObject ciStatus) {
  if (ciStatus.has("errors")) {
    JSONArray errors = ciStatus.getJSONArray("errors");
    if (!errors.isEmpty()) {
      for (int i = 0; i < errors.size(); i++) {
        if (errors.getJSONObject(i).getInt("code") == 70404) {
          return false;
        }
      }
    }
  }
  return true;
}

代码示例来源:origin: Aresyi/smart-api

if(versionList!=null && !versionList.isEmpty()){
  Collections.sort(versionList, new Comparator() {
    @Override

代码示例来源:origin: gooddata/GoodData-CL

JSONObject parsedResp = JSONObject.fromObject(resp);
JSONArray idents = parsedResp.getJSONArray("identifiers");
if (idents != null && !idents.isEmpty()) {
  for (int i = 0; i < idents.size(); i++) {
    JSONObject ident = idents.getJSONObject(i);

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

@Override
public void initializeState() {
  // Initializing this state is directly related to 
  // running the detached plugin checks, these should be consolidated somehow
  updateUpToDate();
  
  // If there are no platform updates, proceed to running
  if (isUpToDate) {
    if (Jenkins.getInstance().getSetupWizard().getPlatformPluginUpdates().isEmpty()) {
      Jenkins.getInstance().setInstallState(InstallState.RUNNING);
    }
  }
}

代码示例来源:origin: gooddata/GoodData-CL

JSONObject projectUsersUpdateResult = responseObject.getJSONObject("projectUsersUpdateResult");
JSONArray failed = projectUsersUpdateResult.getJSONArray("failed");
if (!failed.isEmpty()) {
  String errMsg = "Following users can't be added to the project:";
  for (Object uri : failed.toArray()) {

代码示例来源:origin: gooddata/GoodData-CL

if (c.containsKey("fk")) {
  JSONArray pks = c.getJSONArray("fk");
  if (pks != null && !pks.isEmpty()) {
    Object[] p = pks.toArray();
    for (Object pko : p) {

代码示例来源:origin: gooddata/GoodData-CL

JSONObject projectUsersUpdateResult = responseObject.getJSONObject("projectUsersUpdateResult");
JSONArray failed = projectUsersUpdateResult.getJSONArray("failed");
if (!failed.isEmpty()) {
  String errMsg = "Following users can't be disabled in the project:";
  for (Object uri : failed.toArray()) {

代码示例来源:origin: gooddata/GoodData-CL

if (c != null && !c.isEmpty() && !c.isEmpty()) {
  JSONArray pks = c.getJSONArray("pk");
  if (pks != null && !pks.isEmpty()) {
    Object[] p = pks.toArray();
    for (Object pko : p) {

代码示例来源:origin: com.blazemeter/blazemeter-api-client

/**
 * GET request to 'https://a.blazemeter.com/api/v4/masters/{masterId}/reports/main/summary'
 *
 * @return summary as JSON object
 */
public JSONObject getSummary() throws IOException {
  logger.info("Get summary for master id=" + getId());
  String uri = utils.getAddress() + String.format("/api/v4/masters/%s/reports/main/summary", encode(getId()));
  JSONObject result = utils.execute(utils.createGet(uri)).getJSONObject("result");
  JSONArray summary = result.getJSONArray("summary");
  if (!summary.isEmpty()) {
    return extractSummary(summary.getJSONObject(0));
  }
  return new JSONObject();
}

代码示例来源:origin: net.sf.mbus4j/mbus4j-core

@Override
public void fromJSON(JSONObject json) {
  setManufacturer(json.containsKey("manufacturer") ? json.getString("manufacturer") : "");
  setMedium(json.containsKey("medium") ? MBusMedium.fromLabel(json.getString("medium"))
      : MBusMedium.UNKNOWN_MEDIUM);
  setVersion(JSONFactory.decodeHexByte(json, "version", (byte) 0));
  setIdentNumber(json.containsKey("identNumber") ? json.getInt("identNumber") : 0);
  setAddress(JSONFactory.decodeHexByte(json, "address", (byte) 0));
  setAccessNumber(JSONFactory.getShort(json, "accessNumber", (short) 0));
  setAcd(JSONFactory.getBoolean(json, "acd", false));
  setDfc(JSONFactory.getBoolean(json, "dfc", false));
  setSignature(JSONFactory.decodeHexShort(json, "signature", (short) 0));
  if (json.containsKey("status")) {
    JSONArray statusArray = json.getJSONArray("status");
    if (statusArray.isEmpty()) {
      setStatus(new StatusCode[0]);
    } else {
      status = new StatusCode[statusArray.size()];
      for (int i = 0; i < status.length; i++) {
        status[i] = StatusCode.fromLabel(statusArray.getString(i));
      }
    }
  }
  JSONFactory.readDataBlocks(this, json);
}

相关文章