Reads non outline code custom field values and populates container.
491817
private void processCustomFieldValues()
   {
      byte[] data = m_projectProps.getByteArray(Props.TASK_FIELD_ATTRIBUTES);
      if (data != null)
      {
         int index = 0;
         int offset = 0;
         // First the length
         int length = MPPUtility.getInt(data, offset);
         offset += 4;
         // Then the number of custom value lists
         int numberOfValueLists = MPPUtility.getInt(data, offset);
         offset += 4;

         // Then the value lists themselves
         FieldType field;
         int valueListOffset = 0;
         while (index < numberOfValueLists && offset < length)
         {
            // Each item consists of the Field ID (4 bytes) and the offset to the value list (4 bytes)

            // Get the Field
            field = FieldTypeHelper.getInstance(MPPUtility.getInt(data, offset));
            offset += 4;

            // Get the value list offset
            valueListOffset = MPPUtility.getInt(data, offset);
            offset += 4;
            // Read the value list itself
            if (valueListOffset < data.length)
            {
               int tempOffset = valueListOffset;
               tempOffset += 8;
               // Get the data offset
               int dataOffset = MPPUtility.getInt(data, tempOffset) + valueListOffset;
               tempOffset += 4;
               // Get the end of the data offset
               int endDataOffset = MPPUtility.getInt(data, tempOffset) + valueListOffset;
               tempOffset += 4;
               // Get the end of the description
               int endDescriptionOffset = MPPUtility.getInt(data, tempOffset) + valueListOffset;

               // Get the values themselves
               int valuesLength = endDataOffset - dataOffset;
               byte[] values = new byte[valuesLength];
               MPPUtility.getByteArray(data, dataOffset, valuesLength, values, 0);

               // Get the descriptions
               int descriptionsLength = endDescriptionOffset - endDataOffset;
               byte[] descriptions = new byte[descriptionsLength];
               MPPUtility.getByteArray(data, endDataOffset, descriptionsLength, descriptions, 0);

               populateContainer(field, values, descriptions);
            }
            index++;
         }
      }
   }
277485
private void parseField()
    throws IOException
  {
    int accessFlags = readShort();
    int nameIndex = readShort();
    int descriptorIndex = readShort();

    JavaField field = new JavaField();
    field.setJavaClass(_class);
    field.setName(_cp.getUtf8(nameIndex).getValue());
    field.setDescriptor(_cp.getUtf8(descriptorIndex).getValue());
    field.setAccessFlags(accessFlags);

    int attributesCount = readShort();

    for (int i = 0; i < attributesCount; i++) {
      Attribute attr = parseAttribute();

      field.addAttribute(attr);
    }

    _class.addField(field);
  }
1042030
private static void readField(DatabaseFieldConfig config, String field, String value) {
		if (field.equals(FIELD_NAME_FIELD_NAME)) {
			config.setFieldName(value);
		} else if (field.equals(FIELD_NAME_COLUMN_NAME)) {
			config.setColumnName(value);
		} else if (field.equals(FIELD_NAME_DATA_PERSISTER)) {
			config.setDataPersister(DataType.valueOf(value).getDataPersister());
		} else if (field.equals(FIELD_NAME_DEFAULT_VALUE)) {
			config.setDefaultValue(value);
		} else if (field.equals(FIELD_NAME_WIDTH)) {
			config.setWidth(Integer.parseInt(value));
		} else if (field.equals(FIELD_NAME_CAN_BE_NULL)) {
			config.setCanBeNull(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_ID)) {
			config.setId(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_GENERATED_ID)) {
			config.setGeneratedId(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_GENERATED_ID_SEQUENCE)) {
			config.setGeneratedIdSequence(value);
		} else if (field.equals(FIELD_NAME_FOREIGN)) {
			config.setForeign(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_USE_GET_SET)) {
			config.setUseGetSet(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_UNKNOWN_ENUM_VALUE)) {
			String[] parts = value.split("#", -2);
			if (parts.length != 2) {
				throw new IllegalArgumentException(
						"Invalid value for unknownEnumValue which should be in class#name format: " + value);
			}
			Class<?> enumClass;
			try {
				enumClass = Class.forName(parts[0]);
			} catch (ClassNotFoundException e) {
				throw new IllegalArgumentException("Unknown class specified for unknownEnumValue: " + value);
			}
			Object[] consts = enumClass.getEnumConstants();
			if (consts == null) {
				throw new IllegalArgumentException("Invalid class is not an Enum for unknownEnumValue: " + value);
			}
			@SuppressWarnings("rawtypes")
			Enum[] enumConstants = (Enum[]) consts;
			boolean found = false;
			for (Enum<?> enumInstance : enumConstants) {
				if (enumInstance.name().equals(parts[1])) {
					config.setUnknownEnumValue(enumInstance);
					found = true;
				}
			}
			if (!found) {
				throw new IllegalArgumentException("Invalid enum value name for unknownEnumvalue: " + value);
			}
		} else if (field.equals(FIELD_NAME_THROW_IF_NULL)) {
			config.setThrowIfNull(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_FORMAT)) {
			config.setFormat(value);
		} else if (field.equals(FIELD_NAME_UNIQUE)) {
			config.setUnique(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_UNIQUE_COMBO)) {
			config.setUniqueCombo(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_INDEX)) {
			config.setIndex(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_INDEX_NAME)) {
			config.setIndex(true);
			config.setIndexName(value);
		} else if (field.equals(FIELD_NAME_UNIQUE_INDEX)) {
			config.setUniqueIndex(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_UNIQUE_INDEX_NAME)) {
			config.setUniqueIndex(true);
			config.setUniqueIndexName(value);
		} else if (field.equals(FIELD_NAME_FOREIGN_AUTO_REFRESH)) {
			config.setForeignAutoRefresh(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_MAX_FOREIGN_AUTO_REFRESH_LEVEL)) {
			config.setMaxForeignAutoRefreshLevel(Integer.parseInt(value));
		} else if (field.equals(FIELD_NAME_PERSISTER_CLASS)) {
			try {
				@SuppressWarnings("unchecked")
				Class<? extends DataPersister> clazz = (Class<? extends DataPersister>) Class.forName(value);
				config.setPersisterClass(clazz);
			} catch (ClassNotFoundException e) {
				throw new IllegalArgumentException("Could not find persisterClass: " + value);
			}
		} else if (field.equals(FIELD_NAME_ALLOW_GENERATED_ID_INSERT)) {
			config.setAllowGeneratedIdInsert(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_COLUMN_DEFINITION)) {
			config.setColumnDefinition(value);
		} else if (field.equals(FIELD_NAME_FULL_COLUMN_DEFINITION)) {
			config.setFullColumnDefinition(value);
		} else if (field.equals(FIELD_NAME_FOREIGN_AUTO_CREATE)) {
			config.setForeignAutoCreate(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_VERSION)) {
			config.setVersion(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_FOREIGN_COLUMN_NAME)) {
			config.setForeignColumnName(value);
		} else if (field.equals(FIELD_NAME_READ_ONLY)) {
			config.setReadOnly(Boolean.parseBoolean(value));
		}
		/**
		 * foreign collection field information
		 */
		else if (field.equals(FIELD_NAME_FOREIGN_COLLECTION)) {
			config.setForeignCollection(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_FOREIGN_COLLECTION_EAGER)) {
			config.setForeignCollectionEager(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_MAX_EAGER_FOREIGN_COLLECTION_LEVEL_OLD)) {
			config.setForeignCollectionMaxEagerLevel(Integer.parseInt(value));
		} else if (field.equals(FIELD_NAME_MAX_EAGER_FOREIGN_COLLECTION_LEVEL)) {
			config.setForeignCollectionMaxEagerLevel(Integer.parseInt(value));
		} else if (field.equals(FIELD_NAME_FOREIGN_COLLECTION_COLUMN_NAME)) {
			config.setForeignCollectionColumnName(value);
		} else if (field.equals(FIELD_NAME_FOREIGN_COLLECTION_ORDER_COLUMN_NAME_OLD)) {
			config.setForeignCollectionOrderColumnName(value);
		} else if (field.equals(FIELD_NAME_FOREIGN_COLLECTION_ORDER_COLUMN_NAME)) {
			config.setForeignCollectionOrderColumnName(value);
		} else if (field.equals(FIELD_NAME_FOREIGN_COLLECTION_ORDER_ASCENDING)) {
			config.setForeignCollectionOrderAscending(Boolean.parseBoolean(value));
		} else if (field.equals(FIELD_NAME_FOREIGN_COLLECTION_FOREIGN_FIELD_NAME_OLD)) {
			config.setForeignCollectionForeignFieldName(value);
		} else if (field.equals(FIELD_NAME_FOREIGN_COLLECTION_FOREIGN_FIELD_NAME)) {
			config.setForeignCollectionForeignFieldName(value);
		}
	}
821838
def get_prepopulated_value(field, instance):
    
    if hasattr(field.populate_from, '__call__'):
        # AutoSlugField(populate_from=lambda instance: ...)
        return field.populate_from(instance)
    else:
        # AutoSlugField(populate_from='foo')
        attr = getattr(instance, field.populate_from)
        return callable(attr) and attr() or attr
1218743
private static void generateProtobufDefinedForField(StringBuilder code, FieldElement field, Set<String> enumNames) {
        code.append("@").append(Protobuf.class.getSimpleName()).append("(");

        String fieldType = fieldTypeMapping.get(getTypeName(field));
        if (fieldType == null) {
            if (enumNames.contains(getTypeName(field))) {
                fieldType = "FieldType.ENUM";
            } else {
                if (field.type().kind() == DataType.Kind.MAP) {
                    fieldType = "FieldType.MAP";
                } else {
                    fieldType = "FieldType.OBJECT";
                }

            }
        }

        code.append("fieldType=").append(fieldType);
        code.append(", order=").append(field.tag());
        if (FieldElement.Label.OPTIONAL == field.label()) {
            code.append(", required=false");
        } else if (Label.REQUIRED == field.label()) {
            code.append(", required=true");
        }
        code.append(")\n");

    }
874595
def process_form(self, instance, field, form, empty_marker=None,
                     emptyReturnsMarker=False):
        

        name = field.getName()
        otherName = "%s_other" % name
        value = form.get(otherName, empty_marker)
        regex = field.widget.field_regex

        # validate the custom value against the given regex
        if value and not re.match(regex, value):
            value = None
        # If value is an empty string we check if the selection box
        # has a usable value.
        if value is empty_marker or not value:
            value = form.get(name, empty_marker)
        if value is empty_marker:
            return empty_marker
        if not value and emptyReturnsMarker:
            return empty_marker
        return value, {}
1074826
private String convertFieldValue(final Field field,
                                     final ExportContainer container) {
        final boolean isArray2D = (container.getType() == FieldContainer.Type.ARRAY_2D);
        if (field.getType().equals(String.class)) {
            return wrapWithComma(container.getExportValue());
        } else if (isTypeTimestampConvertible(field)) {
            return wrapWithComma(String.valueOf(convertFieldValueToTimestamp(field, container)));
        } else if (container.getType() == FieldContainer.Type.ARRAY
                || isArray2D
                || container.getType() == FieldContainer.Type.COLLECTION) {

            final Class<?> componentType = extractType(container.getType(), field);
            final String sqlType = dataTypes.getOrDefault(componentType, "VARCHAR");
            final String result = (sqlType.equals("VARCHAR") || sqlType.equals("CHAR"))
                    ? container.getExportValue().replace("[", "{\"").replace("]", "\"}").replace(",", "\",\"").replace(" ", "")
                    : container.getExportValue().replace("[", "{").replace("]", "}");
            return wrapWithComma(result);
        }

        return container.getExportValue();
    }
914101
private void processCustomValueLists() throws IOException
   {
      CustomFieldValueReader9 reader = new CustomFieldValueReader9(m_projectDir, m_file.getProjectProperties(), m_projectProps, m_file.getCustomFields());
      reader.process();
   }
408111
function setFieldValuesNestedArray (field, items) {
    // do not process unless value
    if (!defined(items)) {
        return
    }
    // property value must be array of items
    assert.ok(Array.isArray(items), 'expected array for '+field.property)
    // index of item in values array
    var idx = 0
    // create entry in field values for each item in array
    _.each(items, item => {
        // index string for field name
        var nameIdx = '['+idx+']'
        // each entry in values is an array of fields with values
        var values = []
        // add each sub field to values with value from record item
        _.each(field.fields, field => {
            // clone field to change properties for local version
            field = _.cloneDeep(field)
            // set value from item
            setFieldValue(item, field)
            // replace index in field name
            field.name = field.name.replace('[0]', nameIdx)
            // add field to list of values for item
            values.push(field)
        })
        // add row to values
        field.values.push(values)
        // increment row count
        idx++
    })
    // get index string for new row
    var nameIdx = '['+idx+']'
    // update row index for field names that will be used for a new row
    _.each(field.fields, field => {
        field.name = field.name.replace('[0]', nameIdx)
    })
}
402605
private Object extractCurrentField(JsonParser p, HCatFieldSchema hcatFieldSchema,
                                     boolean isTokenCurrent) throws IOException {
    Object val = null;
    JsonToken valueToken;
    if (isTokenCurrent) {
      valueToken = p.getCurrentToken();
    } else {
      valueToken = p.nextToken();
    }
    switch (hcatFieldSchema.getType()) {
    case INT:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : p.getIntValue();
      break;
    case TINYINT:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : p.getByteValue();
      break;
    case SMALLINT:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : p.getShortValue();
      break;
    case BIGINT:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : p.getLongValue();
      break;
    case BOOLEAN:
      String bval = (valueToken == JsonToken.VALUE_NULL) ? null : p.getText();
      if (bval != null) {
        val = Boolean.valueOf(bval);
      } else {
        val = null;
      }
      break;
    case FLOAT:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : p.getFloatValue();
      break;
    case DOUBLE:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : p.getDoubleValue();
      break;
    case STRING:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : p.getText();
      break;
    case BINARY:
      throw new IOException("JsonSerDe does not support BINARY type");
    case DATE:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : Date.valueOf(p.getText());
      break;
    case TIMESTAMP:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : tsParser.parseTimestamp(p.getText());
      break;
    case DECIMAL:
      val = (valueToken == JsonToken.VALUE_NULL) ? null : HiveDecimal.create(p.getText());
      break;
    case VARCHAR:
      int vLen = ((BaseCharTypeInfo)hcatFieldSchema.getTypeInfo()).getLength();
      val = (valueToken == JsonToken.VALUE_NULL) ? null : new HiveVarchar(p.getText(), vLen);
      break;
    case CHAR:
      int cLen = ((BaseCharTypeInfo)hcatFieldSchema.getTypeInfo()).getLength();
      val = (valueToken == JsonToken.VALUE_NULL) ? null : new HiveChar(p.getText(), cLen);
      break;
    case ARRAY:
      if (valueToken == JsonToken.VALUE_NULL) {
        val = null;
        break;
      }
      if (valueToken != JsonToken.START_ARRAY) {
        throw new IOException("Start of Array expected");
      }
      List<Object> arr = new ArrayList<Object>();
      while ((valueToken = p.nextToken()) != JsonToken.END_ARRAY) {
        arr.add(extractCurrentField(p, hcatFieldSchema.getArrayElementSchema().get(0), true));
      }
      val = arr;
      break;
    case MAP:
      if (valueToken == JsonToken.VALUE_NULL) {
        val = null;
        break;
      }
      if (valueToken != JsonToken.START_OBJECT) {
        throw new IOException("Start of Object expected");
      }
      Map<Object, Object> map = new LinkedHashMap<Object, Object>();
      HCatFieldSchema valueSchema = hcatFieldSchema.getMapValueSchema().get(0);
      while ((valueToken = p.nextToken()) != JsonToken.END_OBJECT) {
        Object k = getObjectOfCorrespondingPrimitiveType(p.getCurrentName(), hcatFieldSchema.getMapKeyTypeInfo());
        Object v = extractCurrentField(p, valueSchema, false);
        map.put(k, v);
      }
      val = map;
      break;
    case STRUCT:
      if (valueToken == JsonToken.VALUE_NULL) {
        val = null;
        break;
      }
      if (valueToken != JsonToken.START_OBJECT) {
        throw new IOException("Start of Object expected");
      }
      HCatSchema subSchema = hcatFieldSchema.getStructSubSchema();
      int sz = subSchema.getFieldNames().size();

      List<Object> struct = new ArrayList<Object>(Collections.nCopies(sz, null));
      while ((valueToken = p.nextToken()) != JsonToken.END_OBJECT) {
        populateRecord(struct, valueToken, p, subSchema);
      }
      val = struct;
      break;
    default:
      LOG.error("Unknown type found: " + hcatFieldSchema.getType());
      return null;
    }
    return val;
  }
189121
private Set<String> collectFields(Class clazz, String fieldPrefix, Set<String> fields) {
        Map<String, Class> fieldsAndClasses = getFieldsAndClasses(clazz, fieldPrefix);

        for (Map.Entry<String, Class> entry : fieldsAndClasses.entrySet()) {
            String field = entry.getKey();
            Class fieldClass = entry.getValue();

            if (DIRECTLY_PROJECTED_TYPES.contains(fieldClass) || Collection.class.isAssignableFrom(fieldClass)) {
                fields.add(field);
            } else {
                collectFields(fieldClass, field + ".", fields);
            }
        }

        return fields;
    }
666322
private Object resolvePropertyTypedValue(FieldData field) {
        Object value;
        if (field.metaData.isInstantiableCollectionType()) {
            value = getArrayPropertyAsCollection(field);
        } else {
            value = resolvePropertyTypedValue(field, field.metaData.getType());
        }
        return value;
    }
1358216
public void process()
   {
      if (m_data != null)
      {
         int index = 0;
         int offset = 0;
         // First the length (repeated twice)
         int length = MPPUtility.getInt(m_data, offset);
         offset += 8;
         // Then the number of custom columns
         int numberOfAliases = MPPUtility.getInt(m_data, offset);
         offset += 4;

         // Then the aliases themselves
         while (index < numberOfAliases && offset < length)
         {
            // Each item consists of the Field ID (2 bytes), 40 0B marker (2 bytes), and the
            // offset to the string (4 bytes)

            // Get the Field ID
            int fieldID = MPPUtility.getInt(m_data, offset);
            offset += 4;
            // Get the alias offset (offset + 4 for some reason).
            int aliasOffset = MPPUtility.getInt(m_data, offset) + 4;
            offset += 4;
            // Read the alias itself
            if (aliasOffset < m_data.length)
            {
               String alias = MPPUtility.getUnicodeString(m_data, aliasOffset);
               m_fields.getCustomField(FieldTypeHelper.getInstance(fieldID)).setAlias(alias);
            }
            index++;
         }
      }
   }
659773
def parse_field(data, field_cfg, target, is_optional=False):
        
        field_type = field_cfg[Field.FIELD_TYPE]
        field_key = field_cfg[Field.FIELD_KEY] if Field.FIELD_KEY in field_cfg else None
        field_ext_id = field_cfg[Field.FIELD_EXT_ID] if Field.FIELD_EXT_ID in field_cfg else field_key
        if field_type == Types.TYPE_ARRAY:
            if isinstance(target, dict):  # add to object
                target.update({field_ext_id: []})
                field_value = data[field_key]
            elif not field_key:  # add to array
                field_value = data
            else:
                raise NotImplementedError('Array of arrays is not supported')
            field_pattern = field_cfg[Field.FIELD_MATCH] if Field.FIELD_MATCH in field_cfg else None
            if Field.FIELD_SUBITEMS in field_cfg:
                subfield = next(iter(field_cfg[Field.FIELD_SUBITEMS].values()))  # only one field within array is allowed
                for item in field_value:
                    if Field.is_match(field_pattern, item):
                        Field.parse_field(item, subfield, target[field_ext_id] if field_ext_id else target)
            else:
                target[field_ext_id] = field_value
        elif field_type == Types.TYPE_OBJECT:
            is_explicit = bool(field_cfg[Field.FIELD_EXPLICIT]) if Field.FIELD_EXPLICIT in field_cfg else False
            is_optional = bool(field_cfg[Field.FIELD_OPTIONAL]) if Field.FIELD_OPTIONAL in field_cfg else False
            if field_key:
                try:
                    field_value = data[field_key]
                except KeyError:
                    if is_optional:
                        field_value = None
                    else:
                        raise
            else: # noname object
                field_value = data  # working with the same item
            if is_explicit:
                obj_exp = {}
                if isinstance(target, dict):  # add to object
                    target.update({field_ext_id: obj_exp})
                else:  # add to array
                    target.append(obj_exp)
            for subfield in field_cfg[Field.FIELD_SUBITEMS]:
                Field.parse_field(field_value, field_cfg[Field.FIELD_SUBITEMS][subfield],
                                  obj_exp if is_explicit else target, is_optional)
        else:  # other types
            try:
                field_value = data[field_key]
            except TypeError:
                if is_optional:
                    field_value = None
                else:
                    raise
            casted_value = Converter.convert(field_value, field_type)
            if isinstance(target, dict):  # add to object
                target.update({field_ext_id: casted_value})
            else:  # add to array
                target.append(casted_value)
654258
private FieldElement readField(
      Location location, String documentation, @Nullable Field.Label label, String type) {
    String name = reader.readName();
    reader.require('=');
    int tag = reader.readInt();

    List<OptionElement> options = new OptionReader(reader).readOptions();
    reader.require(';');

    options = new ArrayList<>(options); // Mutable copy for extractDefault.
    String defaultValue = stripDefault(options);

    documentation = reader.tryAppendTrailingDocumentation(documentation);
    return new FieldElement(
        location,
        label,
        type,
        name,
        defaultValue,
        tag,
        documentation,
        new ArrayList<>(options));
  }
1162456
def prepare_fields(fields):
    
    def process_item(value):
        if not isinstance(value, NUMERIC_TYPES):
            if isinstance(value, six.string_types):
                # encode utf-8 to unicode, if necessary
                return force_text(value)
            else:
                if isinstance(value, dict):
                    return prepare_fields(value)
                elif isinstance(value, list):
                    return list(map(process_item, value))

                return six.text_type(value)
        return value

    return dict((key, process_item(value))
                for key, value
                in fields.items())
364537
private function setCustomFields()
    {
        $customFieldCollection = new CustomFieldCollection();

        if (isset($this->simpleXml->{'custom-fields'})) {
            /** @var SimpleXMLElement $field */
            foreach ($this->simpleXml->{'custom-fields'}->children() as $field) {
                $customField = $this->convertToCustomField($field);
                if (!is_null($customField)) {
                    $customFieldCollection->add($customField);
                }
            }
        }
        $this->customFields = $customFieldCollection;
    }