@Override public JsonNode digest(final JsonNode schema) { final ObjectNode ret = FACTORY.objectNode(); ret.put(keyword, schema.get(keyword)); return ret; } }
@Override public final TextNode textNode(String text) { return _nodeFactory.textNode(text); }
protected final JsonNode _fromEmbedded(JsonParser p, DeserializationContext ctxt, JsonNodeFactory nodeFactory) throws IOException { Object ob = p.getEmbeddedObject(); if (ob == null) { // should this occur? return nodeFactory.nullNode(); } Class<?> type = ob.getClass(); if (type == byte[].class) { // most common special case return nodeFactory.binaryNode((byte[]) ob); } // [databind#743]: Don't forget RawValue if (ob instanceof RawValue) { return nodeFactory.rawValueNode((RawValue) ob); } if (ob instanceof JsonNode) { // [databind#433]: but could also be a JsonNode hiding in there! return (JsonNode) ob; } // any other special handling needed? return nodeFactory.pojoNode(ob); } }
private static String writeDependencies(List<DependencyItem> items) { ObjectNode json = JsonNodeFactory.instance.objectNode(); ArrayNode maps = JsonNodeFactory.instance.arrayNode(); items.forEach((dependency) -> maps.add(mapDependency(dependency))); json.set("dependencies", maps); return json.toString(); }
@Override public JsonNode digest(final JsonNode schema) { // TODO: return an array directly (same for "required" in v4) final ObjectNode ret = FACTORY.objectNode(); final ArrayNode required = FACTORY.arrayNode(); ret.put("required", required); final JsonNode node = schema.get(keyword); final List<String> list = Lists.newArrayList(node.fieldNames()); Collections.sort(list); for (final String field: list) if (node.get(field).path("required").asBoolean(false)) required.add(field); return ret; } }
@Override public MatrixResponse route(GHMRequest ghRequest) { ObjectNode requestJson = factory.objectNode(); ArrayNode outArrayListJson = factory.arrayNode(); for (String str : outArraysList) { outArrayListJson.add(str); requestJson.putArray("points").addAll(createPointList(ghRequest.getFromPoints())); requestJson.putArray("point_hints").addAll(createStringList(ghRequest.getFromPointHints())); } else { ArrayNode fromPointList = createPointList(ghRequest.getFromPoints()); ArrayNode toPointList = createPointList(ghRequest.getToPoints()); requestJson.putArray("from_points").addAll(fromPointList); requestJson.putArray("from_point_hints").addAll(createStringList(ghRequest.getFromPointHints())); requestJson.putArray("to_points").addAll(toPointList); if (responseJson.has("message")) { matrixResponse.addErrors(readErrors(responseJson)); return matrixResponse; if (!responseJson.has("job_id")) { throw new IllegalStateException("Response should contain job_id but was " + postResponseStr + ", json:" + requestJson + ",url:" + postUrl); final String id = responseJson.get("job_id").asText(); int i = 0; for (; i < maxIterations; i++) {
@Override public JsonNode digest(final JsonNode schema) final ObjectNode ret = FACTORY.objectNode(); final ArrayNode simpleTypes = FACTORY.arrayNode(); ret.put(keyword, simpleTypes); final ArrayNode schemas = FACTORY.arrayNode(); ret.put("schemas", schemas); final JsonNode node = schema.get(keyword); if (node.isTextual()) // Single type putType(set, node.textValue()); else { // More than one type, and possibly schemas final int size = node.size(); putType(set, element.textValue()); else schemas.add(index); schemas.removeAll(); simpleTypes.add(type.toString());
@Override public JsonNode digest(final JsonNode schema) final ObjectNode ret = FACTORY.objectNode(); final ObjectNode propertyDeps = FACTORY.objectNode(); ret.put("propertyDeps", propertyDeps); final ArrayNode schemaDeps = FACTORY.arrayNode(); ret.put("schemaDeps", schemaDeps); = JacksonUtils.asMap(schema.get(keyword)); case ARRAY: final JsonNode node = sortedSet(value); if (node.size() != 0) propertyDeps.put(key, node); break; case STRING: propertyDeps.put(key, FACTORY.arrayNode() .add(value.textValue())); schemaDeps.add(s);
@Override protected JsonNode generateDigest() { final ArrayNode schemaDeps = FACTORY.arrayNode(); schemaDeps.add("a"); schemaDeps.add("b"); final ObjectNode ret = FACTORY.objectNode(); ret.put("propertyDeps", FACTORY.objectNode()); ret.put("schemaDeps", schemaDeps); return ret; } }
@Override public JsonNode digest(final JsonNode schema) { final ObjectNode ret = FACTORY.objectNode(); final ArrayNode allowedTypes = FACTORY.arrayNode(); ret.put(keyword, allowedTypes); final JsonNode node = schema.get(keyword); final EnumSet<NodeType> typeSet = EnumSet.noneOf(NodeType.class); if (node.isTextual()) // Single type typeSet.add(NodeType.fromName(node.textValue())); else // More than one type for (final JsonNode element: node) typeSet.add(NodeType.fromName(element.textValue())); if (typeSet.contains(NodeType.NUMBER)) typeSet.add(NodeType.INTEGER); /* * Note that as this is an enumset, order is guaranteed */ for (final NodeType type: typeSet) allowedTypes.add(type.toString()); return ret; } }
private void collectVarargsFromNode(JsonNode node) { if (node.isArray()) { ArrayNode arrayNode = ArrayNode.class.cast(node); for (int i = 0; i < node.size(); i++) { addArgument(arrayNode.get(i)); } } if (node.isObject()) { ObjectNode objectNode = ObjectNode.class.cast(node); Iterator<Map.Entry<String,JsonNode>> items = objectNode.fields(); while (items.hasNext()) { Map.Entry<String,JsonNode> item = items.next(); JsonNode name = JsonNodeFactory.instance.objectNode().put(item.getKey(),item.getKey()); addArgument(name.get(item.getKey())); addArgument(item.getValue()); } } }
@Override public JsonNode digest(final JsonNode schema) { final ObjectNode ret = FACTORY.objectNode(); final ObjectNode propertyDeps = FACTORY.objectNode(); ret.put("propertyDeps", propertyDeps); final ArrayNode schemaDeps = FACTORY.arrayNode(); ret.put("schemaDeps", schemaDeps); final List<String> list = Lists.newArrayList(); final Map<String, JsonNode> map = JacksonUtils.asMap(schema.get(keyword)); String key; JsonNode value; for (final Map.Entry<String, JsonNode> entry: map.entrySet()) { key = entry.getKey(); value = entry.getValue(); if (value.isObject()) // schema dep list.add(key); else // property dep propertyDeps.put(key, sortedSet(value)); } for (final String s: Ordering.natural().sortedCopy(list)) schemaDeps.add(s); return ret; }
final JsonNode schemas = tree.getNode().get(keyword); final int size = schemas.size(); final ObjectNode fullReport = FACTORY.objectNode(); newData = data.withSchema(tree.setPointer(ptr)); processor.process(subReport, newData); fullReport.put(ptr.toString(), subReport.asJson()); if (subReport.isSuccess()) nrSuccess++;
protected final ObjectNode digestedNumberNode(final JsonNode schema) { final ObjectNode ret = FACTORY.objectNode(); final JsonNode node = schema.get(keyword); final boolean isLong = valueIsLong(node); ret.put("valueIsLong", isLong); if (isLong) { ret.put(keyword, node.canConvertToInt() ? FACTORY.numberNode(node.intValue()) : FACTORY.numberNode(node.longValue())); return ret; } final BigDecimal decimal = node.decimalValue(); ret.put(keyword, decimal.scale() == 0 ? FACTORY.numberNode(decimal.toBigIntegerExact()) : node); return ret; } }
@Override public JsonNode digest(final JsonNode schema) { final ObjectNode ret = FACTORY.objectNode(); ret.put("itemsSize", 0); ret.put("itemsIsArray", false); final JsonNode itemsNode = schema.path("items"); final JsonNode additionalNode = schema.path("additionalItems"); final boolean hasItems = !itemsNode.isMissingNode(); final boolean hasAdditional = additionalNode.isObject(); ret.put("hasItems", hasItems); ret.put("hasAdditional", hasAdditional); if (itemsNode.isArray()) { ret.put("itemsIsArray", true); ret.put("itemsSize", itemsNode.size()); } return ret; } }
@Override public JsonNode digest(final JsonNode schema) { final ObjectNode ret = FACTORY.objectNode(); final ArrayNode required = FACTORY.arrayNode(); ret.put(keyword, required); final List<JsonNode> list = Lists.newArrayList(schema.get(keyword)); Collections.sort(list, new Comparator<JsonNode>() { @Override public int compare(final JsonNode o1, final JsonNode o2) { return o1.textValue().compareTo(o2.textValue()); } }); required.addAll(list); return ret; } }
@Override public JsonNode digest(final JsonNode schema) { final ObjectNode ret = FACTORY.objectNode(); ret.put("hasAdditional", schema.path("additionalProperties").isObject()); Set<String> set; ArrayNode node; node = FACTORY.arrayNode(); ret.put("properties", node); set = Sets.newHashSet(schema.path("properties").fieldNames()); for (final String field: Ordering.natural().sortedCopy(set)) node.add(field); node = FACTORY.arrayNode(); ret.put("patternProperties", node); set = Sets.newHashSet(schema.path("patternProperties").fieldNames()); for (final String field: Ordering.natural().sortedCopy(set)) node.add(field); return ret; } }
JsonNode newValue = updateArray(p, ctxt, (ArrayNode) old); if (newValue != old) { node.set(key, newValue); JsonNodeFactory nodeFactory = ctxt.getNodeFactory(); switch (t.id()) { case JsonTokenId.ID_START_OBJECT: value = deserializeObject(p, ctxt, nodeFactory); break; case JsonTokenId.ID_STRING: value = nodeFactory.textNode(p.getText()); break; case JsonTokenId.ID_NUMBER_INT: break; case JsonTokenId.ID_TRUE: value = nodeFactory.booleanNode(true); break; case JsonTokenId.ID_FALSE: value = nodeFactory.booleanNode(false); break; case JsonTokenId.ID_NULL: value = nodeFactory.nullNode(); break; default:
private ProcessingMessage collectSyntaxErrors(final ProcessingReport report) { /* * OK, that's for issue #99 but that's ugly nevertheless. * * We want syntax error messages to appear in the exception text. */ final String msg = syntaxMessages.getMessage("core.invalidSchema"); final ArrayNode arrayNode = JacksonUtils.nodeFactory().arrayNode(); JsonNode node; for (final ProcessingMessage message: report) { node = message.asJson(); if ("syntax".equals(node.path("domain").asText())) arrayNode.add(node); } final StringBuilder sb = new StringBuilder(msg); sb.append("\nSyntax errors:\n"); sb.append(JacksonUtils.prettyPrint(arrayNode)); return new ProcessingMessage().setMessage(sb.toString()); } }