Convert a WSDL-style
{@link org.fcrepo.server.types.gen.ObjectFields ObjectFields} object to a
local {@link ObjectFields} object.
332937
public static ObjectFields convertGenObjectFieldsToObjectFields(org.fcrepo.server.types.gen.ObjectFields source) {
        if (source == null) {
            return null;
        }
        ObjectFields result = new ObjectFields();
        result.setPid(source.getPid() != null ? source.getPid().getValue() : null);
        result.setLabel(source.getLabel() != null ? source.getLabel().getValue() : null);
        result.setState(source.getState() != null ? source.getState().getValue() : null);
        result.setOwnerId(source.getOwnerId() != null ? source.getOwnerId().getValue() : null);
        result.setCDate(source.getCDate() != null ? DateUtility.convertStringToDate(source.getCDate().getValue()) : null);
        result.setMDate(source.getMDate() != null ? DateUtility.convertStringToDate(source.getMDate().getValue()) : null);
        result.setDCMDate(source.getDcmDate() != null ? DateUtility.convertStringToDate(source.getDcmDate().getValue()) : null);
        result.titles().addAll(convertStringArray(source.getTitle()));
        result.subjects().addAll(convertStringArray(source.getSubject()));
        result.descriptions()
                .addAll(convertStringArray(source.getDescription()));
        result.publishers().addAll(convertStringArray(source.getPublisher()));
        result.contributors()
                .addAll(convertStringArray(source.getContributor()));
        result.dates().addAll(convertStringArray(source.getDate()));
        result.types().addAll(convertStringArray(source.getType()));
        result.formats().addAll(convertStringArray(source.getFormat()));
        result.identifiers().addAll(convertStringArray(source.getIdentifier()));
        result.sources().addAll(convertStringArray(source.getSource()));
        result.languages().addAll(convertStringArray(source.getLanguage()));
        result.relations().addAll(convertStringArray(source.getRelation()));
        result.coverages().addAll(convertStringArray(source.getCoverage()));
        result.rights().addAll(convertStringArray(source.getRights()));
        return result;
    }
1365702
public static LocalProperties forOrdering(Ordering o) {
		LocalProperties props = new LocalProperties();
		props.ordering = o;
		props.groupedFields = o.getInvolvedIndexes();
		return props;
	}
316983
private static ObjectStreamClass createClassDesc(Class<?> cl) {

        ObjectStreamClass result = new ObjectStreamClass();

        boolean isArray = cl.isArray();
        boolean serializable = isSerializable(cl);
        boolean externalizable = isExternalizable(cl);

        result.isSerializable = serializable;
        result.isExternalizable = externalizable;

        // Now we fill in the values
        result.setName(cl.getName());
        result.setClass(cl);
        Class<?> superclass = cl.getSuperclass();
        if (superclass != null) {
            result.setSuperclass(lookup(superclass));
        }

        Field[] declaredFields = null;

        // Compute the SUID
        if (serializable || externalizable) {
            if (result.isEnum() || result.isProxy()) {
                result.setSerialVersionUID(0L);
            } else {
                declaredFields = cl.getDeclaredFields();
                result.setSerialVersionUID(computeSerialVersionUID(cl, declaredFields));
            }
        }

        // Serializables need field descriptors
        if (serializable && !isArray) {
            if (declaredFields == null) {
                declaredFields = cl.getDeclaredFields();
            }
            result.buildFieldDescriptors(declaredFields);
        } else {
            // Externalizables or arrays do not need FieldDesc info
            result.setFields(NO_FIELDS);
        }

        // Copy all fields to loadFields - they should be read by default in
        // ObjectInputStream.defaultReadObject() method
        ObjectStreamField[] fields = result.getFields();

        if (fields != null) {
            ObjectStreamField[] loadFields = new ObjectStreamField[fields.length];

            for (int i = 0; i < fields.length; ++i) {
                loadFields[i] = new ObjectStreamField(fields[i].getName(),
                        fields[i].getType(), fields[i].isUnshared());

                // resolve type string to init typeString field in
                // ObjectStreamField
                loadFields[i].getTypeString();
            }
            result.setLoadFields(loadFields);
        }

        byte flags = 0;
        if (externalizable) {
            flags |= ObjectStreamConstants.SC_EXTERNALIZABLE;
            flags |= ObjectStreamConstants.SC_BLOCK_DATA; // use protocol version 2 by default
        } else if (serializable) {
            flags |= ObjectStreamConstants.SC_SERIALIZABLE;
        }
        result.methodWriteReplace = findMethod(cl, "writeReplace");
        result.methodReadResolve = findMethod(cl, "readResolve");
        result.methodWriteObject = findPrivateMethod(cl, "writeObject", WRITE_PARAM_TYPES);
        result.methodReadObject = findPrivateMethod(cl, "readObject", READ_PARAM_TYPES);
        result.methodReadObjectNoData = findPrivateMethod(cl, "readObjectNoData", EmptyArray.CLASS);
        if (result.hasMethodWriteObject()) {
            flags |= ObjectStreamConstants.SC_WRITE_METHOD;
        }
        result.setFlags(flags);

        return result;
    }
1151484
def ConvertFromWireFormat(self, value, container=None):
    """"""
    result = self.type()
    ReadIntoObject(value[2], 0, result)

    return result
858513
public Object readObject(AbstractHessianInput in, Object[] fieldNames) throws IOException {
        GenericObject obj = new GenericObject(type);
        return readGenericObject(in, obj, (String[]) fieldNames);
    }
409698
public int putRawFieldData(Convert field)
    {
        String strKey = this.getFullKey(field.getFieldName());
        Class<?> classData = String.class;
        if (field.getField() != null)
            classData = this.getMessage().getNativeClassType(field.getField().getDataClass());
        Object objValue = field.getData();
        try {
            objValue = DataConverters.convertObjectToDatatype(objValue, classData, null);  // I do this just to be careful.
        } catch (Exception ex) {
            objValue = null;
        }
        this.getMessage().putNative(strKey, objValue);
        return Constant.NORMAL_RETURN;
    }
839375
public int getRawFieldData(Convert field)
    {
        if (this.getKey() == null)
            this.setKey(field.getFieldName());
        Object objValue = this.get();
        if ((objValue == null) || (objValue.getClass() == field.getField().getDataClass()))
            return field.setData(objValue); // Should call here
        else
            return field.setString(this.getString());
    }
634590
def _fields_to_object(descriptor, fields):
    ''
    # pylint: disable=protected-access
    obj = descriptor._concrete_class()

    for name, value in fields:
        if isinstance(value, tuple):
            subtype = descriptor.fields_by_name[name].message_type
            value = _fields_to_object(subtype, value)
        _assign_to_field(obj, name, value)

    return obj
850846
def fields_with_locales(self):
        

        result = {}
        for locale, fields in self._fields.items():
            for k, v in fields.items():
                real_field_id = self._real_field_id_for(k)
                if real_field_id not in result:
                    result[real_field_id] = {}
                result[real_field_id][locale] = self._serialize_value(v)
        return result
538513
private static List<Field> getServiceFields(Object object)
    {
        final List<Field> toInject = new ArrayList<>();
        Class<?> clazz = object.getClass();
        while (clazz != null)
        {
            final Field[] fields = clazz.getDeclaredFields();
            final int length = fields.length;
            for (int i = 0; i < length; i++)
            {
                final Field field = fields[i];
                if (field.isAnnotationPresent(FeatureGet.class))
                {
                    toInject.add(field);
                }
            }
            clazz = clazz.getSuperclass();
        }
        return toInject;
    }
736190
function (fieldDefinition) {
		let type = fieldDefinition.fieldType;
		if (typeof type === 'object') {
			type = fieldDefinition.fieldType.type;
		}
		return type;
	}
1099445
protected SerializerJson<?> createSerializer(Class<?> cl)
  {
    SerializerJson<?> ser = _staticSerMap.get(cl);

    if (ser != null) {
      return ser;
    }

    TypeRef typeRef = TypeRef.of(cl);
    
    if (cl.isArray()) {
      Class<?> eltType = cl.getComponentType();
      
      return new ObjectArraySerializerJson(eltType, serializer(eltType));
    }
    
    Method methodReplaceObject = findWriteReplace(cl);
    
    if (methodReplaceObject != null) {
      return new JavaSerializerWriteReplace(methodReplaceObject);
    }
    
    CollectionFunction collFun = _factoryMap.get(cl);
    
    if (collFun != null) {
      return collFun.apply(typeRef, this);
    }
    
    if (Map.class.isAssignableFrom(cl)) {
      return new MapJavaSerializer(typeRef, this, cl);
    }
    else if (Collection.class.isAssignableFrom(cl)) {
      return new ListJavaSerializer(typeRef, this, cl);
    }
    /*
    if (Collection.class.isAssignableFrom(cl)) {
      return new CollectionSerializerJson(typeRef, this);
    }

    if (Map.class.isAssignableFrom(cl)) {
      return new MapSerializerJson(typeRef, this, HashMap::new);
    }
    */
    
    ser = findInterfaceSerializer(cl);
    
    if (ser != null) {
      return ser;
    }

    if (AtomicInteger.class.isAssignableFrom(cl)) {
      return AtomicIntegerSerializer.SER;
    }

    if (Enum.class.isAssignableFrom(cl)) {
      return EnumSerializer.SER;
    }
    
    try {
      Method valueOf = cl.getMethod("valueOf", String.class);
      
      if (Modifier.isStatic(valueOf.getModifiers())) {
          //&& cl.equals(valueOf.getReturnType())) {
        return new StringValueOfSerializer<>(cl, valueOf);
      }
    } catch (NoSuchMethodException e) {
      log.log(Level.ALL, e.toString(), e);
    }

    return new JavaSerializerJson(typeRef, this);
  }
1327019
private <T extends D6Model> T[] toArray(List<Object> objectList, Class<T> modelClazz) {

    if (objectList == null) {
      return (T[]) Array.newInstance(modelClazz, 0);
    }

    final T[] resultObjects = objectList.toArray((T[]) Array.newInstance(modelClazz, 0));

    return resultObjects;
  }
34185
public static String objectToColumnString(Object object, String delimiter, String[] fieldNames)
          throws IllegalAccessException, NoSuchFieldException, NoSuchMethodException, InvocationTargetException
  {
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < fieldNames.length; i++) {
      if (sb.length() > 0) {
        sb.append(delimiter);
      }
      try {
        Field field = object.getClass().getDeclaredField(fieldNames[i]);
        sb.append(field.get(object)) ;
      } catch (IllegalAccessException ex) {
        Method method = object.getClass().getDeclaredMethod("get" + StringUtils.capitalize(fieldNames[i]));
        sb.append(method.invoke(object));
      }
    }
    return sb.toString();
  }
1130700
public static Object objectify(ObjectMapper mapper, Object source) {
        return objectify(mapper, source, Object.class);
    }
886968
private static <T> IntermediateCompatibilityResult<T> getCompatibilityOfPreExistingFields(
			PojoSerializer<T> newPojoSerializer,
			LinkedOptionalMap<Field, TypeSerializerSnapshot<?>> fieldSerializerSnapshots) {

		// the present entries dictates the preexisting fields, because removed fields would be
		// represented as absent keys in the optional map.
		final Set<LinkedOptionalMap.KeyValue<Field, TypeSerializerSnapshot<?>>> presentFieldSnapshots =
			fieldSerializerSnapshots.getPresentEntries();

		final ArrayList<TypeSerializerSnapshot<?>> associatedFieldSerializerSnapshots = new ArrayList<>(presentFieldSnapshots.size());
		final ArrayList<TypeSerializer<?>> associatedNewFieldSerializers = new ArrayList<>(presentFieldSnapshots.size());

		final Map<Field, TypeSerializer<?>> newFieldSerializersIndex = buildNewFieldSerializersIndex(newPojoSerializer);
		for (LinkedOptionalMap.KeyValue<Field, TypeSerializerSnapshot<?>> presentFieldEntry : presentFieldSnapshots) {
			TypeSerializer<?> associatedNewFieldSerializer = newFieldSerializersIndex.get(presentFieldEntry.getKey());
			checkState(
				associatedNewFieldSerializer != null,
				"a present field should have its associated new field serializer available.");

			associatedFieldSerializerSnapshots.add(presentFieldEntry.getValue());
			associatedNewFieldSerializers.add(associatedNewFieldSerializer);
		}

		return CompositeTypeSerializerUtil.constructIntermediateCompatibilityResult(
			associatedNewFieldSerializers.toArray(new TypeSerializer<?>[associatedNewFieldSerializers.size()]),
			associatedFieldSerializerSnapshots.toArray(new TypeSerializerSnapshot<?>[associatedFieldSerializerSnapshots.size()]));
	}
1271584
def serialize(self, queryset, **options):
        
        self.options = options

        self.stream = options.pop("stream", six.StringIO())
        self.selected_fields = options.pop("fields", None)
        self.use_natural_keys = options.pop("use_natural_keys", False)
        if self.use_natural_keys and RemovedInDjango19Warning is not None:
            warnings.warn("``use_natural_keys`` is deprecated; use ``use_natural_foreign_keys`` instead.",
                          RemovedInDjango19Warning)
        self.use_natural_foreign_keys = options.pop('use_natural_foreign_keys', False) or self.use_natural_keys
        self.use_natural_primary_keys = options.pop('use_natural_primary_keys', False)

        self.start_serialization()
        self.first = True
        for obj in queryset:
            self.start_object(obj)
            # Use the concrete parent class' _meta instead of the object's _meta
            # This is to avoid local_fields problems for proxy models. Refs #17717.
            concrete_model = obj._meta.concrete_model
            # only one change local_fields -> fields for supporting nested models
            for field in concrete_model._meta.fields:
                if field.serialize:
                    if field.remote_field is None:
                        if self.selected_fields is None or field.attname in self.selected_fields:
                            self.handle_field(obj, field)
                    else:
                        if self.selected_fields is None or field.attname[:-3] in self.selected_fields:
                            self.handle_fk_field(obj, field)
            for field in concrete_model._meta.many_to_many:
                if field.serialize:
                    if self.selected_fields is None or field.attname in self.selected_fields:
                        self.handle_m2m_field(obj, field)
            self.end_object(obj)
            if self.first:
                self.first = False
        self.end_serialization()
        return self.getvalue()