/** * Convenience method to return the value of a named field. This is the same as calling {@link #getField(String)}, * and using the returned value to call {@link #getFieldValue(Field)}. If the named field does not exist, this * method returns null. * * @param fieldName The name of the field whose value to return. * @return The value of the field, or null. */ public FieldValue getFieldValue(String fieldName) { Field field = getField(fieldName); if (field == null) { return null; } return getFieldValue(field); }
/** * Convenience method to remove the value of a named field. This is the same as calling {@link #getField(String)}, * and using the returned value to call {@link #removeFieldValue(Field)}. If the named field does not exist, this * method returns null. * * @param fieldName The name of the field whose value to remove. * @return The previous value of the field, or null. */ public FieldValue removeFieldValue(String fieldName) { Field field = getField(fieldName); if (field == null) { return null; } return removeFieldValue(field); }
@Override protected void doExecute(ExecutionContext ctx) { FieldValue input = ctx.getValue(); if (!(input instanceof StructuredFieldValue)) { throw new IllegalArgumentException("Expected structured input, got " + input.getDataType().getName() + "."); } StructuredFieldValue struct = (StructuredFieldValue)input; Field field = struct.getField(fieldName); if (field == null) { throw new IllegalArgumentException("Field '" + fieldName + "' not found in struct type '" + struct.getDataType().getName() + "'"); } ctx.setValue(struct.getFieldValue(field)); }
/** * Convenience method to set the value of a named field. This is the same as calling {@link #getField(String)}, and * using the returned value to call {@link #setFieldValue(Field, FieldValue)}. If the named field does not exist, * this method returns null. * * @param fieldName The name of the field whose value to set. * @param value The value to set. * @return The previous value of the field, or null. */ public FieldValue setFieldValue(String fieldName, FieldValue value) { Field field = getField(fieldName); if (field == null) { return null; } return setFieldValue(field, value); }
public static Field getField(TokenBuffer buffer, StructuredFieldValue parent) { Field f = parent.getField(buffer.currentName()); if (f == null) { throw new NullPointerException("Could not get field \"" + buffer.currentName() + "\" in the structure of type \"" + parent.getDataType().getDataTypeName() + "\"."); } return f; }
throw new UnsupportedOperationException("Can not map into a " + val.getClass().getName() + "."); } else if (val instanceof StructuredFieldValue) { Field field = ((StructuredFieldValue)val).getField(String.valueOf(upd.getValue())); if (field == null) { throw new IllegalArgumentException("Field '" + upd.getValue() + "' not found.");