Sets the given field to the given value. This is an alternative to
invoking a set method.

@param fieldName
Name of the field to set
@param mojo
Mojo
@param value
New value for the field
@throws Exception
If setting the field using reflection goes wrong
9908
protected static void setField(String fieldName, Object mojo, Object value) throws Exception {
        Field field = null;
        try {
            field = mojo.getClass().getDeclaredField(fieldName);
        } catch (NoSuchFieldException ex) {
            // Ignore exception and try superclass.
            field = mojo.getClass().getSuperclass().getDeclaredField(fieldName);
        }
        field.setAccessible(true);
        field.set(mojo, value);
    }
72438
public static void addFieldValue(List<FieldMeta> fieldValues,String fieldName,Object value){
		FieldMeta fieldMeta = new FieldMeta();
		fieldMeta.setEsFieldName(fieldName);
		fieldMeta.setValue(value);
		fieldValues.add(fieldMeta);
	}
957711
@SuppressWarnings({ "unchecked", "rawtypes" })
	public static void setFieldValue(Object bean, String fieldNameOrIndex, Object value) {
		if (bean instanceof Map) {
			((Map) bean).put(fieldNameOrIndex, value);
		} else if (bean instanceof List) {
			CollUtil.setOrAppend((List) bean, Convert.toInt(fieldNameOrIndex), value);
		} else if (ArrayUtil.isArray(bean)) {
			ArrayUtil.setOrAppend(bean, Convert.toInt(fieldNameOrIndex), value);
		} else {
			// 普通Bean对象
			ReflectUtil.setFieldValue(bean, fieldNameOrIndex, value);
		}
	}
659906
protected void doUpdateBeanValue(final Object value) {
		String beanProperty = getBeanProperty();
		if (beanProperty != null && beanProperty.length() > 0 && !".".equals(beanProperty)) {
			Object bean = getBean();
			if (bean != null) {
				try {
					Object beanValue = getBeanValue();
					if (!Util.equals(beanValue, value)) {
						PropertyUtils.setProperty(bean, beanProperty, value);
					}
				} catch (Exception e) {
					LOG.error("Failed to set bean property " + beanProperty + " on " + bean);
				}
			}
		}
	}
230551
public function setValue($key, $value) {
		if( !isset($key) ) {
			// Invalid key
			throw new Exception("nullKey");
			
		} else if( !in_array($key, static::$fields) ) {
			// Unknown key
			throw new FieldNotFoundException($key, static::getClass());
			
		} else if( $key === static::$IDFIELD ) {
			// ID is not editable
			throw new Exception("idNotEditable");
			
		} else if( $value !== $this->data[$key] ) {
			// The value is different
			$this->addModFields($key);
			$this->data[$key] = $value;
		}
		return $this;
	}
1074337
def set(self, name, value, **kw):
        

        # fetch the field by name
        field = api.get_field(self.context, name)

        # bail out if we have no field
        if not field:
            return False

        # call the field adapter and set the value
        fieldmanager = IFieldManager(field)
        return fieldmanager.set(self.context, value, **kw)
170336
public function setFieldValue($fieldName, $value)
    {
        if ($this->hasField($fieldName) == false) {
            throw new SolrMappingException(sprintf('Field %s does not exist', $fieldName));
        }

        $field = $this->getField($fieldName);
        $field->value = $value;
    }
933313
private static void setProperty( Object bean, String key, Object value, JsonConfig jsonConfig )
         throws Exception {
      PropertySetStrategy propertySetStrategy = jsonConfig.getPropertySetStrategy() != null ? jsonConfig.getPropertySetStrategy()
            : PropertySetStrategy.DEFAULT;
      propertySetStrategy.setProperty( bean, key, value, jsonConfig );
   }
329229
protected void setBeanPropertyValue(final String property, final Object bean,
			final Serializable value) {
		if (bean == null) {
			return;
		}

		if (".".equals(property)) {
			LOG.error("Set of entire bean is not supported by this model");
			return;
		}
		try {
			PropertyUtils.setProperty(bean, property, value);
		} catch (Exception e) {
			LOG.error("Failed to set bean property " + property + " on " + bean, e);
		}
	}
717195
public void setValueOfField(String fieldName, Object value) {
		add(new SimpleUpdateField(fieldName, value, UpdateAction.SET));
	}
985966
@ResponseOverride(
            description = "Set a JSON value.",
            parameters = {"name", "value", "path"}
    )
    public static void set_json_value(PluginArguments args, String name, String value, String path) throws Exception {
        HttpServletResponse response = args.getResponse();
        String content = PluginHelper.readResponseContent(response);
        JSONObject jsonContent = new JSONObject(content);

        process_json_value(jsonContent, name, value, path, true);
        PluginHelper.writeResponseContent(response, jsonContent.toString());
    }
50471
public static void setFieldValue(final Object object, final String fieldName, final Object value) {

        final boolean success = new DerivedClassIterator(object.getClass()) {

            @Override
            protected boolean handleClass(final Class<?> clazz) {
                try {
                    setFieldValue(object, clazz, fieldName, value);
                    return true;
                } catch (final NoSuchFieldException e) {
                    LOG.debug("could not set field " + fieldName + " value " + value, e);

                }
                return false;
            }
        }.iterate();

        if (!success) {
            LOG.warn("could not set field " + fieldName + " value " + value);
        }
    }
303640
@SuppressWarnings("unchecked")
  private void setValue(Object instance, Field field, String value) throws IllegalAccessException {
    if (!field.isAccessible()) {
      field.setAccessible(true);
    }

    Class<?> fieldType = field.getType();

    // Currently only String, primitive (or boxed type) and Enum type are supported.
    if (String.class.equals(fieldType)) {
      field.set(instance, value);
      return;
    }
    if (fieldType.isEnum()) {
      field.set(instance, Enum.valueOf((Class<? extends Enum>) fieldType, value));
      return;
    }

    if (fieldType.isPrimitive()) {
      fieldType = com.google.common.primitives.Primitives.wrap(fieldType);
    }

    try {
      // All box type has the valueOf(String) method.
      field.set(instance, fieldType.getMethod("valueOf", String.class).invoke(null, value));
    } catch (NoSuchMethodException e) {
      // Should never happen, as boxed type always have the valueOf(String) method.
      throw Throwables.propagate(e);
    } catch (InvocationTargetException e) {
      // Also should never happen, as calling method on Java bootstrap classes should always succeed.
      throw Throwables.propagate(e);
    }
  }
743627
private static void setValue(Object target, String field, Object value) {
        // TODO: Should we do this for all numbers, not just '0'?
        if ("0".equals(field)) {

            if (!(target instanceof Collection)) {
                throw new IllegalArgumentException(
                        "Cannot evaluate '0' on object " + target);
            }

            @SuppressWarnings("unchecked")
            Collection<Object> collection = (Collection<Object>) target;
            collection.add(value);

        } else {

            Method setter = findMethod(target, "set" + field, value.getClass());

            try {
                setter.invoke(target, value);

            } catch (IllegalAccessException exception) {
                throw new IllegalStateException(
                        "Unable to access setter method",
                        exception);

            } catch(InvocationTargetException exception) {
                if (exception.getCause() instanceof RuntimeException) {
                    throw (RuntimeException) exception.getCause();
                }
                throw new IllegalStateException(
                        "Checked exception thrown from setter method",
                        exception);
            }
        }
    }
805770
public static void copyProperty(Object bean, String name, Object value)
            throws Excel4JException {

        if (null == name || null == value)
            return;
        Field field = matchClassField(bean.getClass(), name);
        if (null == field)
            return;
        Method method;
        try {
            method = getterOrSetter(bean.getClass(), name, FieldAccessType.SETTER);

            if (value.getClass() == field.getType()) {
                method.invoke(bean, value);
            } else {
                method.invoke(bean, str2TargetClass(value.toString(), field.getType()));
            }
        } catch (IntrospectionException | IllegalAccessException | InvocationTargetException e) {
            throw new Excel4JException(e);
        }

    }
696953
public static void setFieldValue(final Object target, final String name, final Object value) {
		Field field = FieldUtils.getDeclaredField(target.getClass(), name, true);

		if (field == null) {
			throw new IllegalArgumentException("Could not find field [" + name + "] on target [" + target + ']');
		}

		try {
			field.set(target, value);
		} catch (IllegalAccessException e) {
			throw new ImpossibleException(e);
		}
	}
238511
public static void setField(final Object obj, Field field, final Object value) {
		try {
			field.set(obj, value);
		} catch (Exception e) {
			throw convertReflectionExceptionToUnchecked(e);
		}
	}