return true;
}
if (!AbstractNodeState.comparePropertiesAgainstBaseState(this, base, diff)) {
return false;
}
JsopTokenizer t = new JsopTokenizer(jsonDiff);
boolean continueComparison = true;
while (continueComparison) {
int r = t.read();
if (r == JsopReader.END) {
break;
}
switch (r) {
case '+': {
String path = t.readString();
t.read(':');
t.read('{');
while (t.read() != '}') {
// skip properties
}
String name = PathUtils.getName(path);
continueComparison = diff.childNodeAdded(name, getChildNode(name));
break;
}
case '-': {
String path = t.readString();
String name = PathUtils.getName(path);
continueComparison = diff.childNodeDeleted(name, base.getChildNode(name));
break;
}
case '^': {
String path = t.readString();
t.read(':');
if (t.matches('{')) {
t.read('}');
String name = PathUtils.getName(path);
continueComparison = diff.childNodeChanged(name,
base.getChildNode(name), getChildNode(name));
} else if (t.matches('[')) {
// ignore multi valued property
while (t.read() != ']') {
// skip values
}
} else {
// ignore single valued property
t.read();
}
break;
}
case '>': {
String from = t.readString();
t.read(':');
String to = t.readString();
String fromName = PathUtils.getName(from);
continueComparison = diff.childNodeDeleted(
fromName, base.getChildNode(fromName));
if (!continueComparison) {
break;
}
String toName = PathUtils.getName(to);
continueComparison = diff.childNodeAdded(
toName, getChildNode(toName));
break;
}
default:
throw new IllegalArgumentException("jsonDiff: illegal token '"
+ t.getToken() + "' at pos: " + t.getLastPos() + ' ' + jsonDiff);
}
}
return continueComparison;
}