/* sets a field with a fairly basic strategy
356036
private static void set(Field field, Object obj, String value) throws Exception {
        Class<?> clazz = field.getType();
        field.setAccessible(true);
        if (clazz.equals(Double.class) || clazz.equals(double.class)) {
            double val = Double.valueOf(value);
            field.set(obj, val);
        } else if (clazz.equals(String.class)) {
            field.set(obj, value);
        } else if (clazz.equals(Integer.class) || clazz.equals(int.class)) {
            int val = Integer.parseInt(value);
            field.set(obj, val);
        } else if (clazz.equals(Float.class) || clazz.equals(float.class)) {
            float f = Float.parseFloat(value);
            field.set(obj, f);
        }
    }
1252361
def apply_strategy(rule, table, column, primary_key)
      if rule.is_a?(Hash)
        if rule.key?("value")
          escape(rule["value"])
        elsif rule.key?("statement")
          rule["statement"]
        else
          raise PgSync::Error, "Unknown rule #{rule.inspect} for column #{column}"
        end
      else
        case rule
        when "untouched"
          quote_ident(column)
        when "unique_email"
          "'email' || #{quoted_primary_key(table, primary_key, rule)}::text || '@example.org'"
        when "unique_phone"
          "(#{quoted_primary_key(table, primary_key, rule)}::bigint + 1000000000)::text"
        when "unique_secret"
          "'secret' || #{quoted_primary_key(table, primary_key, rule)}::text"
        when "random_int", "random_number"
          "(RANDOM() * 100)::int"
        when "random_date"
          "date '1970-01-01' + (RANDOM() * 10000)::int"
        when "random_time"
          "NOW() - (RANDOM() * 100000000)::int * INTERVAL '1 second'"
        when "random_ip"
          "(1 + RANDOM() * 254)::int::text || '.0.0.1'"
        when "random_letter"
          "chr(65 + (RANDOM() * 26)::int)"
        when "random_string"
          "RIGHT(MD5(RANDOM()::text), 10)"
        when "null", nil
          "NULL"
        else
          raise PgSync::Error, "Unknown rule #{rule} for column #{column}"
        end
      end
    end
184274
public static void setField(Object obj, Field field, Object value) {
        boolean accessible = field.isAccessible();
        //hack accessibility
        if (!accessible) {
            field.setAccessible(true);
        }
        try {
            field.set(obj, value);
        } catch (IllegalAccessException e) {
            //ignore should not happen as accessibility has been updated to suit assignment
            e.printStackTrace(); // $COVERAGE-IGNORE$
        }
        //restore accessibility
        field.setAccessible(accessible);
    }
1200329
private AssignmentField selectField(AssignmentField[] fields, int index)
   {
      if (index < 1 || index > fields.length)
      {
         throw new IllegalArgumentException(index + " is not a valid field index");
      }
      return (fields[index - 1]);
   }
936845
private void storeField(Field field, StructImpl fieldsMap) {
	String fieldName = field.getName();
	Object o = fieldsMap.get(fieldName, null);
	Field[] args;
	if (o == null) {
	    args = new Field[1];
	    fieldsMap.setEL(fieldName, args);
	}
	else {
	    Field[] fs = (Field[]) o;
	    args = new Field[fs.length + 1];
	    for (int i = 0; i < fs.length; i++) {
		fs[i].setAccessible(true);
		args[i] = fs[i];
	    }
	    fieldsMap.setEL(fieldName, args);
	}
	args[args.length - 1] = field;
    }
412106
@JsonAnySetter
	public void setAdditionalField(final String key, final Object value) {
		this.additionalFields.put(key, value);
	}
122648
public static void setField(Object instance, Class<?> type, String fieldName, Object fieldValue) {
		try {
			final Field field = type.getDeclaredField(fieldName);
			field.setAccessible(true);
			field.set(instance, fieldValue);
		} catch (Exception exception) {
			throw new Error(exception);
		}
	}
232908
public function setField(Field $field, $index = 0)
    {
        $this->field = $field;
        $this->valueIndex = $index;
    }
1254117
def _setField(self, value, field, check=1):
        """"""
        try:
            # expand field name using minimum match
            field = _setFieldDict[field]
        except KeyError as e:
            raise SyntaxError("Cannot set field " + field +
                    " for parameter " + self.name + "\n" + str(e))
        if field == "p_prompt":
            self.prompt = irafutils.removeEscapes(irafutils.stripQuotes(value))
        elif field == "p_value":
            self.set(value,check=check)
        elif field == "p_filename":
            # this is only relevant for list parameters (*imcur, *gcur, etc.)
            self.set(value,check=check)
        elif field == "p_scope":
            self.scope = value
        elif field == "p_maximum":
            self.max = self._coerceOneValue(value)
        elif field == "p_minimum":
            if isinstance(value,str) and '|' in value:
                self._setChoice(irafutils.stripQuotes(value))
            else:
                self.min = self._coerceOneValue(value)
        elif field == "p_mode":
            # not doing any type or value checking here -- setting mode is
            # rare, so assume that it is being done correctly
            self.mode = irafutils.stripQuotes(value)
        else:
            raise RuntimeError("Program bug in IrafPar._setField()" +
                    "Requested field " + field + " for parameter " + self.name)
849172
private Method[] settersMethodForField(Field field) {
    List<Method> methods = new ArrayList<>();
    for (Method method : field.getDeclaringClass().getDeclaredMethods()) {
      if (Ascii.toLowerCase(method.getName()).equals("set" + Ascii.toLowerCase(field.getName()))
          && method.getParameterTypes().length == 1) {
        methods.add(method);
      }
    }
    return methods.toArray(new Method[0]);
  }
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);
            }
        }
    }
341843
public function set($field, $value = UNDEFINED)
    {
        if ($value === false) {
            throw $this->exception('Value "false" is not supported by SQL')
                ->addMoreInfo('field', $field);
        }
        if (is_array($field)) {
            foreach ($field as $key => $value) {
                $this->set($key, $value);
            }

            return $this;
        }

        if ($value === UNDEFINED) {
            throw $this->exception('Specify value when calling set()');
        }

        $this->args['set'][$field] = $value;

        return $this;
    }
335247
private static Field findField(Object object, FieldMatcherStrategy strategy, Class<?> where) {
        return findSingleFieldUsingStrategy(strategy, object, false, where);
    }
714514
protected function setFieldKey()
    {
        if (! $this->fieldValue || ! $this->rootValue) {
            return;
        }

        $cacheFieldKey = $this->fieldValue
            ->getParent()
            ->getCacheKey();

        if ($cacheFieldKey) {
            $this->fieldKey = data_get($this->rootValue, $cacheFieldKey);
        }
    }
819908
def set_field(self, state, field_name, field_type, value):
        
        field_ref = SimSootValue_InstanceFieldRef.get_ref(state=state,
                                                          obj_alloc_id=self.heap_alloc_id,
                                                          field_class_name=self.type,
                                                          field_name=field_name,
                                                          field_type=field_type)
        # store value in java memory
        state.memory.store(field_ref, value)
871242
public static void setField(Class<?> targetClass, Object target, String field, Object value) {
        try {
            Field classField = targetClass.getDeclaredField(field);

            AccessController.doPrivileged(
                    new SetFieldPrivilegedAction(classField, target, value));

        } catch (NoSuchFieldException e) {
            throw new TransfuseInjectionException(
                    "NoSuchFieldException Exception during field injection: " + field + " in " + target.getClass(), e);
        } catch (PrivilegedActionException e) {
            throw new TransfuseInjectionException("PrivilegedActionException Exception during field injection", e);
        } catch (Exception e) {
            throw new TransfuseInjectionException("Exception during field injection", e);
        }
    }
885715
function setField($field, $value, $repetition = 0)
    {
        return $this->_impl->setField($field, $value, $repetition);
    }