-package org.simantics.databoard.serialization.impl;\r
-\r
-import java.io.DataInput;\r
-import java.io.DataOutput;\r
-import java.io.IOException;\r
-\r
-import org.simantics.databoard.binding.BooleanBinding;\r
-import org.simantics.databoard.binding.error.BindingException;\r
-import org.simantics.databoard.serialization.Serializer.NonRecursiveSerializer;\r
-\r
-public class BooleanSerializer extends NonRecursiveSerializer {\r
-\r
- BooleanBinding binding;\r
- \r
- public BooleanSerializer(BooleanBinding binding) {\r
- this.binding = binding;\r
- }\r
- \r
- @Override\r
- public Object deserialize(DataInput in) throws IOException {\r
- try {\r
- boolean value = in.readByte() != 0; \r
- return binding.create(value);\r
- } catch (BindingException e) {\r
- throw new IOException( e ); \r
- }\r
- }\r
- \r
- @Override\r
- public void deserializeTo(DataInput in, Object obj) throws IOException {\r
- try {\r
- boolean newValue = in.readByte() != 0; \r
- binding.setValue(obj, newValue);\r
- } catch (BindingException e) {\r
- throw new IOException( e ); \r
- }\r
- }\r
- \r
- @Override\r
- public void skip(DataInput in)\r
- throws IOException {\r
- in.skipBytes(1); \r
- }\r
-\r
- @Override\r
- public void serialize(DataOutput out, Object obj) throws IOException {\r
- try {\r
- boolean value = binding.getValue_(obj);\r
- out.write( (byte) (value ? 1 : 0) );\r
- } catch (BindingException e) {\r
- throw new IOException( e ); \r
- }\r
- }\r
-\r
- @Override\r
- public Integer getConstantSize() {\r
- return 1;\r
- }\r
-\r
- @Override\r
- public int getSize(Object obj) {\r
- return 1;\r
- }\r
-\r
- @Override\r
- public int getMinSize() {\r
- return 1;\r
- }\r
- \r
- public boolean getBoolean(DataInput in) throws IOException\r
- {\r
- return in.readByte() != 0;\r
- }\r
- \r
- public void putBoolean(DataOutput out, boolean x) throws IOException\r
- {\r
- out.writeBoolean(x);\r
- }\r
- \r
-}\r
+package org.simantics.databoard.serialization.impl;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.simantics.databoard.binding.BooleanBinding;
+import org.simantics.databoard.binding.error.BindingException;
+import org.simantics.databoard.serialization.Serializer.NonRecursiveSerializer;
+
+public class BooleanSerializer extends NonRecursiveSerializer {
+
+ BooleanBinding binding;
+
+ public BooleanSerializer(BooleanBinding binding) {
+ this.binding = binding;
+ }
+
+ @Override
+ public Object deserialize(DataInput in) throws IOException {
+ try {
+ boolean value = in.readByte() != 0;
+ return binding.create(value);
+ } catch (BindingException e) {
+ throw new IOException( e );
+ }
+ }
+
+ @Override
+ public void deserializeTo(DataInput in, Object obj) throws IOException {
+ try {
+ boolean newValue = in.readByte() != 0;
+ binding.setValue(obj, newValue);
+ } catch (BindingException e) {
+ throw new IOException( e );
+ }
+ }
+
+ @Override
+ public void skip(DataInput in)
+ throws IOException {
+ in.skipBytes(1);
+ }
+
+ @Override
+ public void serialize(DataOutput out, Object obj) throws IOException {
+ try {
+ boolean value = binding.getValue_(obj);
+ out.write( (byte) (value ? 1 : 0) );
+ } catch (BindingException e) {
+ throw new IOException( e );
+ }
+ }
+
+ @Override
+ public Integer getConstantSize() {
+ return 1;
+ }
+
+ @Override
+ public int getSize(Object obj) {
+ return 1;
+ }
+
+ @Override
+ public int getMinSize() {
+ return 1;
+ }
+
+ public boolean getBoolean(DataInput in) throws IOException
+ {
+ return in.readByte() != 0;
+ }
+
+ public void putBoolean(DataOutput out, boolean x) throws IOException
+ {
+ out.writeBoolean(x);
+ }
+
+}