use of com.yahoo.document.json.TokenBuffer in project vespa by vespa-engine.
the class MapReader method createMapUpdate.
@SuppressWarnings({ "rawtypes", "unchecked" })
public static ValueUpdate createMapUpdate(TokenBuffer buffer, DataType currentLevel, FieldValue keyParent, FieldValue topLevelKey) {
TokenBuffer.Token element = buffer.prefetchScalar(UPDATE_ELEMENT);
if (UPDATE_ELEMENT.equals(buffer.currentName())) {
buffer.next();
}
FieldValue key = keyTypeForMapUpdate(element, currentLevel);
if (keyParent != null) {
((CollectionFieldValue) keyParent).add(key);
}
// match will always have element, and either match or action
if (!UPDATE_MATCH.equals(buffer.currentName())) {
// we have reached an action...
if (topLevelKey == null) {
return ValueUpdate.createMap(key, readSingleUpdate(buffer, valueTypeForMapUpdate(currentLevel), buffer.currentName()));
} else {
return ValueUpdate.createMap(topLevelKey, readSingleUpdate(buffer, valueTypeForMapUpdate(currentLevel), buffer.currentName()));
}
} else {
// next level of matching
if (topLevelKey == null) {
return createMapUpdate(buffer, valueTypeForMapUpdate(currentLevel), key, key);
} else {
return createMapUpdate(buffer, valueTypeForMapUpdate(currentLevel), key, topLevelKey);
}
}
}
Aggregations