當前位置: 首頁>>代碼示例>>Java>>正文


Java ProcessingReport.iterator方法代碼示例

本文整理匯總了Java中com.github.fge.jsonschema.core.report.ProcessingReport.iterator方法的典型用法代碼示例。如果您正苦於以下問題:Java ProcessingReport.iterator方法的具體用法?Java ProcessingReport.iterator怎麽用?Java ProcessingReport.iterator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.github.fge.jsonschema.core.report.ProcessingReport的用法示例。


在下文中一共展示了ProcessingReport.iterator方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: jsonSchemaValidation

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入方法依賴的package包/類
/**
 * Validates input node against given schema. Returns NULL if no errors
 * reported, else returns string representing violations.
 *
 * @param schema the json schema (see #loadSchema)
 * @param node the json node to validate
 * @return null if there are no errors, else string with all errors and
 * warnings
 * @throws ProcessingException
 */
public static String jsonSchemaValidation(JsonSchema schema, JsonNode node) throws ProcessingException, JsonProcessingException {
    ProcessingReport report = schema.validate(node);
    Iterator<ProcessingMessage> i = report.iterator();
    StringBuilder buff = new StringBuilder();
    while (!report.isSuccess() && i != null && i.hasNext()) {
        ProcessingMessage pm = i.next();

        // attempting to pretty print the json
        ObjectMapper mapper = new ObjectMapper();
        String prettyPrintJson = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(pm.asJson());

        buff.append(prettyPrintJson).append("\n\n");
    }

    return report.isSuccess() ? null : buff.toString();
}
 
開發者ID:lightblue-platform,項目名稱:lightblue-core,代碼行數:27,代碼來源:JsonUtils.java

示例2: validateJson

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入方法依賴的package包/類
protected void validateJson(String jsonFileName) throws IOException, ProcessingException, JsonLdError {

        JsonNode schema = getSchema();
        assertNotNull(schema);

        String jsonStr = getJson(jsonFileName);
        assertNotNull(jsonStr);

        Object jsonObj = JsonUtils.fromString(jsonStr);
        List<Object> expandedJson = JsonLdProcessor.expand(jsonObj);
        jsonStr = JsonUtils.toString(expandedJson);
        JsonNode json = JsonLoader.fromString(jsonStr);

        JsonValidator jsonValidator = JsonSchemaFactory.byDefault().getValidator();
        ProcessingReport processingReport = jsonValidator.validate(schema, json);
        assertNotNull(processingReport);
        if (!processingReport.isSuccess()) {

            ArrayNode jsonArray = JsonNodeFactory.instance.arrayNode();
            assertNotNull(jsonArray);

            Iterator<ProcessingMessage> iterator = processingReport.iterator();
            while (iterator.hasNext()) {
                ProcessingMessage processingMessage = iterator.next();
                jsonArray.add(processingMessage.asJson());
            }

            String errorJson = JsonUtils.toPrettyString(jsonArray);
            assertNotNull(errorJson);

            fail(errorJson);
        }
    }
 
開發者ID:dlcs,項目名稱:elucidate-server,代碼行數:34,代碼來源:AbstractSchemaValidatorTest.java

示例3: validate

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入方法依賴的package包/類
public void validate(File ConfigurationFile) throws IOException, ProcessingException, IllegalSchemaException {
    JsonNode Configuration = JsonLoader.fromFile(ConfigurationFile);

    ProcessingReport r1 = VALIDATOR.validate(
            ConfigurationSchema,
            Configuration
    );

    if (!r1.isSuccess()) {
        Iterator<ProcessingMessage> it = r1.iterator();
        ProcessingMessage pm = it.next();
        JSONObject o = new JSONObject(pm.asJson().toString());
        throw new IllegalSchemaException(o.toString(4));
    }
}
 
開發者ID:MKLab-ITI,項目名稱:easIE,代碼行數:16,代碼來源:ConfigurationValidator.java

示例4: processReport

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入方法依賴的package包/類
/**
 * Returns set of {@link SwaggerError} created from a validation report.
 * 
 * @param report
 *            to process
 * @return set of validation errors
 */
public Set<SwaggerError> processReport(ProcessingReport report) {
    final Set<SwaggerError> errors = new HashSet<>();
    if (report != null) {
        for (Iterator<ProcessingMessage> it = report.iterator(); it.hasNext();) {
            errors.addAll(processMessage(it.next()));
        }
    }
    return errors;
}
 
開發者ID:RepreZen,項目名稱:KaiZen-OpenAPI-Editor,代碼行數:17,代碼來源:ErrorProcessor.java

示例5: processTuple

import com.github.fge.jsonschema.core.report.ProcessingReport; //導入方法依賴的package包/類
@Override
public void processTuple(byte[] tuple)
{
  if (tuple == null) {
    if (err.isConnected()) {
      err.emit(new KeyValPair<String, String>(null, "null tuple"));
    }
    errorTupleCount++;
    return;
  }
  String incomingString = new String(tuple);
  try {
    if (schema != null) {
      ProcessingReport report = null;
      JsonNode data = JsonLoader.fromString(incomingString);
      report = schema.validate(data);
      if (report != null && !report.isSuccess()) {
        Iterator<ProcessingMessage> iter = report.iterator();
        StringBuilder s = new StringBuilder();
        while (iter.hasNext()) {
          ProcessingMessage pm = iter.next();
          s.append(pm.asJson().get("instance").findValue("pointer")).append(":").append(pm.asJson().get("message"))
              .append(",");
        }
        s.setLength(s.length() - 1);
        errorTupleCount++;
        if (err.isConnected()) {
          err.emit(new KeyValPair<String, String>(incomingString, s.toString()));
        }
        return;
      }
    }
    if (parsedOutput.isConnected()) {
      parsedOutput.emit(new JSONObject(incomingString));
      parsedOutputCount++;
    }
    if (out.isConnected()) {
      out.emit(objMapper.readValue(tuple, clazz));
      emittedObjectCount++;
    }
  } catch (JSONException | ProcessingException | IOException e) {
    errorTupleCount++;
    if (err.isConnected()) {
      err.emit(new KeyValPair<String, String>(incomingString, e.getMessage()));
    }
    logger.error("Failed to parse json tuple {}, Exception = {} ", tuple, e);
  }
}
 
開發者ID:apache,項目名稱:apex-malhar,代碼行數:49,代碼來源:JsonParser.java


注:本文中的com.github.fge.jsonschema.core.report.ProcessingReport.iterator方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。