Search in sources :

Example 1 with FieldPath

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;
}
Also used : Field(com.yahoo.document.Field) FieldPath(com.yahoo.document.FieldPath)

Example 2 with FieldPath

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;
}
Also used : FieldPath(com.yahoo.document.FieldPath)

Example 3 with FieldPath

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;
}
Also used : Field(com.yahoo.document.Field) FieldPath(com.yahoo.document.FieldPath)

Example 4 with FieldPath

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;
}
Also used : FieldPath(com.yahoo.document.FieldPath)

Aggregations

FieldPath (com.yahoo.document.FieldPath)4 Field (com.yahoo.document.Field)2