use of com.yahoo.document.FieldPath in project vespa by vespa-engine.
the class ProxyDocument method getField.
/**
* note that the returned Field may not be in this Document
* directly, but may refer to a field in a struct contained in it,
* in which case the returned Field is only useful for obtaining
* the field type; it can't be used for get() and set().
*/
@Override
public Field getField(String fieldName) {
if (fieldMap != null && fieldMap.containsKey(fieldName)) {
fieldName = fieldMap.get(fieldName);
}
FieldPath path = getFieldPath(fieldName);
Field ret = path.get(path.size() - 1).getFieldRef();
checkAccess(ret);
return ret;
}
use of com.yahoo.document.FieldPath in project vespa by vespa-engine.
the class ProxyDocument method removeFieldValue.
@Override
public FieldValue removeFieldValue(String fieldName) {
RemoveHandler handler = new RemoveHandler();
FieldPath path = getFieldPath(fieldName);
iterateNested(path, 0, handler);
if (!handler.doModifyCalled) {
// the value in question was not found
throw new IllegalArgumentException("Field '" + fieldName + "' mapped by '" + path + "' was not found.");
}
return handler.prevVal;
}
use of com.yahoo.document.FieldPath in project vespa by vespa-engine.
the class ProxyDocument method getFieldPath.
private FieldPath getFieldPath(String fieldName) {
if (fieldMap != null && fieldMap.containsKey(fieldName)) {
fieldName = fieldMap.get(fieldName);
}
checkAccess(new Field(fieldName));
FieldPath path = FieldPath.newInstance(getDataType(), fieldName);
if (path == null || path.size() == 0) {
throw new IllegalArgumentException("Malformed schema mapping '" + fieldName + "'.");
}
return path;
}
use of com.yahoo.document.FieldPath in project vespa by vespa-engine.
the class ProxyDocument method setFieldValue.
@Override
public FieldValue setFieldValue(String fieldName, FieldValue fieldValue) {
SetHandler handler = new SetHandler(fieldValue);
FieldPath path = getFieldPath(fieldName);
iterateNested(path, 0, handler);
if (!handler.doModifyCalled) {
// the value in question was not found
throw new IllegalArgumentException("Field '" + fieldName + "' mapped by '" + path + "' was not found.");
}
return handler.prevVal;
}