1 package org.simantics.databoard.serialization.impl;
3 import java.io.DataInput;
4 import java.io.DataOutput;
5 import java.io.IOException;
7 import org.simantics.databoard.binding.DoubleBinding;
8 import org.simantics.databoard.binding.error.BindingException;
9 import org.simantics.databoard.serialization.Serializer.NonRecursiveSerializer;
11 public class DoubleSerializer extends NonRecursiveSerializer {
13 DoubleBinding binding;
15 public DoubleSerializer(DoubleBinding binding) {this.binding = binding;}
18 public Object deserialize(DataInput in) throws IOException {
20 double value = in.readDouble();
21 return binding.create(value);
22 } catch (BindingException e) {
23 throw new IOException( e );
28 public void deserializeTo(DataInput in, Object obj) throws IOException {
30 double value = in.readDouble();
31 binding.setValue(obj, value);
32 } catch (BindingException e) {
33 throw new IOException( e );
38 public void skip(DataInput in)
44 public void serialize(DataOutput out, Object obj) throws IOException {
46 double value = binding.getValue_(obj);
47 out.writeDouble(value);
48 } catch (BindingException e) {
49 throw new IOException( e );
54 public Integer getConstantSize() {
59 public int getSize(Object obj) {
64 public int getMinSize() {
68 public double getDouble(DataInput in) throws IOException
70 return in.readDouble();
73 public void putDouble(DataOutput out, double x) throws IOException