--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2012 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.databoard.tests;\r
+\r
+import java.util.UUID;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.binding.Binding;\r
+import org.simantics.databoard.binding.RecordBinding;\r
+import org.simantics.databoard.serialization.Serializer;\r
+\r
+public class TestPrimitiveSetters {\r
+\r
+ public static class X {\r
+ \r
+ public boolean z; // 0\r
+ public Boolean zz;// 1\r
+ \r
+ public byte b; // 2\r
+ public Byte bb; // 3\r
+ \r
+ public int i; // 4\r
+ public Integer ii;// 5\r
+ \r
+ public long l; // 6 \r
+ public Long ll; // 7\r
+ \r
+ public float f; // 8\r
+ public Float ff; // 9\r
+ \r
+ public double d; // 10\r
+ public Double dd; // 11\r
+\r
+ private boolean z_; // 12\r
+ private Boolean zz_;// 13\r
+ \r
+ private byte b_; // 14\r
+ private Byte bb_; // 15\r
+ /*\r
+ private int i_; // 16\r
+ private Integer ii_;// 17\r
+ \r
+ private long l_; // 18 \r
+ private Long ll_; // 19\r
+ \r
+ private float f_; // 20\r
+ private Float ff_; // 21\r
+ \r
+ private double d_; // 22\r
+ private Double dd_; // 23\r
+ */\r
+ public void setZ_(boolean z) {this.z_ = z;}\r
+ public boolean getZ_() {return z_;}\r
+\r
+ public void setZz_(Boolean z) {this.zz_ = z;}\r
+ public Boolean getZz_() {return zz_;}\r
+ \r
+ public void setB_(byte z) {this.b_ = z;}\r
+ public byte getB_() {return b_;}\r
+\r
+ public void setBb_(Byte z) {this.bb_ = z;}\r
+ public Byte getBb_() {return bb_;} \r
+ \r
+ }\r
+ \r
+ public static void main(String[] args) throws Exception {\r
+ // DONE Add primitive support for Deserialization\r
+ // TODO Test UUID\r
+ // TODO Remove validator from AsmBindingClassLoader\r
+ // DONE Test Setters\r
+ \r
+ RecordBinding b = Bindings.getBinding( X.class );\r
+ \r
+ X x = new X();\r
+ b.setBoolean(x, 0, true);\r
+ b.setBoolean(x, 1, true);\r
+ \r
+ b.setByte(x, 2, (byte)3);\r
+ b.setByte(x, 3, (byte)3);\r
+ \r
+ b.setInt(x, 4, 3);\r
+ b.setInt(x, 5, 3);\r
+\r
+ b.setLong(x, 6, 3L);\r
+ b.setLong(x, 7, 3L);\r
+ \r
+ b.setFloat(x, 8, 3.f);\r
+ b.setFloat(x, 9, 3.f);\r
+ \r
+ b.setDouble(x, 10, 3.2);\r
+ b.setDouble(x, 11, 3.4);\r
+\r
+ b.setBoolean(x, 12, true);\r
+ b.setBoolean(x, 13, true);\r
+ \r
+ b.setByte(x, 14, (byte)3);\r
+ b.setByte(x, 15, (byte)3);\r
+ \r
+ System.out.println( b.getBoolean(x, 0) );\r
+ System.out.println( b.getBoolean(x, 1) );\r
+ \r
+ System.out.println( b.getByte(x, 2) );\r
+ System.out.println( b.getByte(x, 3) );\r
+ \r
+ System.out.println( b.getInt(x, 4) );\r
+ System.out.println( b.getInt(x, 5) );\r
+ \r
+ System.out.println( b.getLong(x, 6) );\r
+ System.out.println( b.getLong(x, 7) );\r
+ \r
+ System.out.println( b.getFloat(x, 8) );\r
+ System.out.println( b.getFloat(x, 9) );\r
+ \r
+ System.out.println( b.getDouble(x, 10) );\r
+ System.out.println( b.getDouble(x, 11) );\r
+ \r
+ System.out.println( b.getBoolean(x, 12) );\r
+ System.out.println( b.getBoolean(x, 13) );\r
+ \r
+ System.out.println( b.getByte(x, 14) );\r
+ System.out.println( b.getByte(x, 15) );\r
+ \r
+ System.out.println(b.toString(x));\r
+ \r
+ UUID guid = UUID.randomUUID();\r
+ Binding binding = Bindings.getBinding(UUID.class);\r
+ Serializer s = Bindings.getSerializer(binding);\r
+ byte[] data = s.serialize( guid );\r
+ \r
+ guid = (UUID) s.deserialize( data );\r
+ \r
+ }\r
+}\r