protected JsonPointer _constructHead() { // ok; find out who we are to drop JsonPointer last = last(); if (last == this) { return EMPTY; } // and from that, length of suffix to drop int suffixLength = last._asString.length(); JsonPointer next = _nextSegment; return new JsonPointer(_asString.substring(0, _asString.length() - suffixLength), _matchingPropertyName, _matchingElementIndex, next._constructHead(suffixLength, last)); }
protected JsonPointer _constructHead() { // ok; find out who we are to drop JsonPointer last = last(); if (last == this) { return EMPTY; } // and from that, length of suffix to drop int suffixLength = last._asString.length(); JsonPointer next = _nextSegment; return new JsonPointer(_asString.substring(0, _asString.length() - suffixLength), _matchingPropertyName, _matchingElementIndex, next._constructHead(suffixLength, last)); }
protected JsonPointer _constructHead() { // ok; find out who we are to drop JsonPointer last = last(); if (last == this) { return EMPTY; } // and from that, length of suffix to drop int suffixLength = last._asString.length(); JsonPointer next = _nextSegment; return new JsonPointer(_asString.substring(0, _asString.length() - suffixLength), _matchingPropertyName, _matchingElementIndex, next._constructHead(suffixLength, last)); }
protected JsonPointer _constructHead() { // ok; find out who we are to drop JsonPointer last = last(); if (last == this) { return EMPTY; } // and from that, length of suffix to drop int suffixLength = last._asString.length(); JsonPointer next = _nextSegment; return new JsonPointer(_asString.substring(0, _asString.length() - suffixLength), _matchingPropertyName, _matchingElementIndex, next._constructHead(suffixLength, last)); }
protected JsonPointer _constructHead() { // ok; find out who we are to drop JsonPointer last = last(); if (last == this) { return EMPTY; } // and from that, length of suffix to drop int suffixLength = last._asString.length(); JsonPointer next = _nextSegment; return new JsonPointer(_asString.substring(0, _asString.length() - suffixLength), _matchingPropertyName, _matchingElementIndex, next._constructHead(suffixLength, last)); }
protected JsonPointer _constructHead() { // ok; find out who we are to drop JsonPointer last = last(); if (last == this) { return EMPTY; } // and from that, length of suffix to drop int suffixLength = last._asString.length(); JsonPointer next = _nextSegment; return new JsonPointer(_asString.substring(0, _asString.length() - suffixLength), _matchingPropertyName, _matchingElementIndex, next._constructHead(suffixLength, last)); }
static JsonNode addToObject(final JsonPointer path, final JsonNode node, final JsonNode value) { final ObjectNode target = (ObjectNode) node.at(path.head()); target.set(path.last().getMatchingProperty(), value); return node; } }
static JsonNode addToObject(final JsonPointer path, final JsonNode node, final JsonNode value) { final ObjectNode target = (ObjectNode) node.at(path.head()); target.set(path.last().getMatchingProperty(), value); return node; } }
static JsonNode addToObject(final JsonPointer path, final JsonNode node, final JsonNode value) { final ObjectNode target = (ObjectNode) node.at(path.head()); target.set(path.last().getMatchingProperty(), value); return node; } }
@Override JsonNode apply(final JsonNode node) { ensureExistence(node); final JsonNode replacement = valueCopy(); if (path.toString().isEmpty()) { return replacement; } final JsonNode parent = node.at(path.head()); final String rawToken = path.last().getMatchingProperty(); if (parent.isObject()) { ((ObjectNode) parent).set(rawToken, replacement); } else { ((ArrayNode) parent).set(Integer.parseInt(rawToken), replacement); } return node; } }
@Override JsonNode apply(final JsonNode node) { ensureExistence(node); final JsonNode replacement = valueCopy(); if (path.toString().isEmpty()) { return replacement; } final JsonNode parent = node.at(path.head()); final String rawToken = path.last().getMatchingProperty(); if (parent.isObject()) { ((ObjectNode) parent).set(rawToken, replacement); } else { ((ArrayNode) parent).set(Integer.parseInt(rawToken), replacement); } return node; } }
@Override JsonNode apply(final JsonNode node) { ensureExistence(node); final JsonNode replacement = valueCopy(); if (path.toString().isEmpty()) { return replacement; } final JsonNode parent = node.at(path.head()); final String rawToken = path.last().getMatchingProperty(); if (parent.isObject()) { ((ObjectNode) parent).set(rawToken, replacement); } else { ((ArrayNode) parent).set(Integer.parseInt(rawToken), replacement); } return node; } }
@Override JsonNode apply(final JsonNode node) { if (path.toString().isEmpty()) { return MissingNode.getInstance(); } ensureExistence(node); final JsonNode parentNode = node.at(path.head()); final String raw = path.last().getMatchingProperty(); if (parentNode.isObject()) { ((ObjectNode) parentNode).remove(raw); } else { ((ArrayNode) parentNode).remove(Integer.parseInt(raw)); } return node; }
@Override JsonNode apply(final JsonNode node) { if (path.toString().isEmpty()) { return MissingNode.getInstance(); } ensureExistence(node); final JsonNode parentNode = node.at(path.head()); final String raw = path.last().getMatchingProperty(); if (parentNode.isObject()) { ((ObjectNode) parentNode).remove(raw); } else { ((ArrayNode) parentNode).remove(Integer.parseInt(raw)); } return node; }
@Override JsonNode apply(final JsonNode node) { if (path.toString().isEmpty()) { return MissingNode.getInstance(); } ensureExistence(node); final JsonNode parentNode = node.at(path.head()); final String raw = path.last().getMatchingProperty(); if (parentNode.isObject()) { ((ObjectNode) parentNode).remove(raw); } else { ((ArrayNode) parentNode).remove(Integer.parseInt(raw)); } return node; }
@Override JsonNode apply(final JsonNode node) { if (path.toString().isEmpty()) { return MissingNode.getInstance(); } final JsonNode found = node.at(path); if (found.isMissingNode()) { return node; } final JsonNode parentNode = node.at(path.head()); final String raw = path.last().getMatchingProperty(); if (parentNode.isObject()) { ((ObjectNode) parentNode).remove(raw); } else if (parentNode.isArray()) { ((ArrayNode) parentNode).remove(Integer.parseInt(raw)); } return node; }
@Override JsonNode apply(final JsonNode node) { if (path.toString().isEmpty()) { return MissingNode.getInstance(); } final JsonNode found = node.at(path); if (found.isMissingNode()) { return node; } final JsonNode parentNode = node.at(path.head()); final String raw = path.last().getMatchingProperty(); if (parentNode.isObject()) { ((ObjectNode) parentNode).remove(raw); } else if (parentNode.isArray()) { ((ArrayNode) parentNode).remove(Integer.parseInt(raw)); } return node; }
@Override JsonNode apply(final JsonNode node) { if (path.toString().isEmpty()) { return MissingNode.getInstance(); } final JsonNode found = node.at(path); if (found.isMissingNode()) { return node; } final JsonNode parentNode = node.at(path.head()); final String raw = path.last().getMatchingProperty(); if (parentNode.isObject()) { ((ObjectNode) parentNode).remove(raw); } else if (parentNode.isArray()) { ((ArrayNode) parentNode).remove(Integer.parseInt(raw)); } return node; }
@Override JsonNode apply(JsonNode node) { final JsonNode actual = ensureExistence(node); if (!EQUIVALENCE.equivalent(actual, oldValue)) { throw new JsonPatchException("mismatching value at '" + path + "': " + actual + " (expected: " + oldValue + ')'); } final JsonNode replacement = newValue.deepCopy(); if (path.toString().isEmpty()) { return replacement; } final JsonNode parent = node.at(path.head()); final String rawToken = path.last().getMatchingProperty(); if (parent.isObject()) { ((ObjectNode) parent).set(rawToken, replacement); } else { ((ArrayNode) parent).set(Integer.parseInt(rawToken), replacement); } return node; }
@Override JsonNode apply(JsonNode node) { final JsonNode actual = ensureExistence(node); if (!EQUIVALENCE.equivalent(actual, oldValue)) { throw new JsonPatchException("mismatching value at '" + path + "': " + actual + " (expected: " + oldValue + ')'); } final JsonNode replacement = newValue.deepCopy(); if (path.toString().isEmpty()) { return replacement; } final JsonNode parent = node.at(path.head()); final String rawToken = path.last().getMatchingProperty(); if (parent.isObject()) { ((ObjectNode) parent).set(rawToken, replacement); } else { ((ArrayNode) parent).set(Integer.parseInt(rawToken), replacement); } return node; }