package org.simantics.databoard.serialization.impl; import gnu.trove.map.hash.TObjectIntHashMap; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.util.List; import org.simantics.databoard.binding.Binding; import org.simantics.databoard.binding.RecordBinding; import org.simantics.databoard.binding.error.BindingException; import org.simantics.databoard.binding.reflection.ClassBinding; import org.simantics.databoard.binding.util.IsReferableQuery; import org.simantics.databoard.binding.util.Result; import org.simantics.databoard.serialization.SerializationException; import org.simantics.databoard.serialization.Serializer; import org.simantics.databoard.serialization.Serializer.CompositeSerializer; public class GenericRecordSerializer extends CompositeSerializer { RecordBinding binding; public Serializer[] componentSerializers; Integer fixedSize; int minSize; boolean createPartial; /** * Field type for each field * 0 - Object * 1 - boolean * 2 - byte * 3 - int * 4 - long * 5 - float * 6 - double */ public int[] fieldType; /** * * @param binding * @param componentSerializers (optional) can be set later */ public GenericRecordSerializer(RecordBinding binding, Serializer[] componentSerializers) { super( IsReferableQuery.isReferable( binding.type() ) != Result.No ); this.binding = binding; this.componentSerializers = componentSerializers; } @Override public void finalizeConstruction() { fixedSize = null; createPartial = !binding.isImmutable(); if ( binding instanceof ClassBinding ) { ClassBinding cb = (ClassBinding) binding; createPartial &= cb.ci.partialConstructionPossible; } fieldType = new int[componentSerializers.length]; for (int i=0; i