package org.simantics.databoard.serialization.impl; import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; import java.util.List; import org.simantics.databoard.binding.ArrayBinding; import org.simantics.databoard.serialization.SerializationException; import org.simantics.databoard.serialization.Serializer.NonRecursiveSerializer; import org.simantics.databoard.type.ArrayType; import org.simantics.databoard.util.Range; public class DoubleArraySerializer extends NonRecursiveSerializer { Range length; Integer fixedLength, fixedSize; public DoubleArraySerializer(ArrayBinding binding) { ArrayType arrayType = (ArrayType) binding.type(); this.length = arrayType.getLength(); if (length!=null && length.getLower().equals(length.getUpper()) && length.getLower().getValue()!=null) { fixedLength = length.getLower().getValue().intValue(); fixedSize = fixedLength * 8; } } @Override public Object deserialize(DataInput in) throws IOException { int length = fixedSize != null ? fixedLength : in.readInt(); if (length<0) throw new SerializationException("Cannot use negative array length"); assertRemainingBytes(in, length*8L); double[] array = new double[length]; for(int i=0;i identities, Object obj) throws IOException { int length = fixedLength != null ? fixedLength : in.readInt(); double[] array = (double[]) obj; if (length!=array.length) array = new double[ length ]; assertRemainingBytes(in, length*8L); for (int i=0; i