]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/scratch/org/simantics/databoard/tests/Jotakin11.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.databoard / scratch / org / simantics / databoard / tests / Jotakin11.java
1 package org.simantics.databoard.tests;
2
3 import org.simantics.databoard.Bindings;
4 import org.simantics.databoard.annotations.Referable;
5 import org.simantics.databoard.binding.Binding;
6 import org.simantics.databoard.serialization.Serializer;
7
8 public class Jotakin11 {
9
10         static @Referable class Node {
11                 public int id;
12                 public Node[] reference;
13                 public Node(int id, Node...reference) {
14                         this.id = id;
15                         this.reference = reference;
16                 }
17                 
18         }
19         
20         public static void main(String[] args) throws Exception {
21                 
22                 Node a = new Node(0);
23                 Node b = new Node(1);
24                 Node c = new Node(2);
25                 a.reference = new Node[] {b, c};
26                 b.reference = new Node[] {a};
27                 c.reference = new Node[] {c};
28                 
29                 Binding binding = Bindings.getBinding( Node.class );
30                 Serializer s = Bindings.getSerializer(binding);
31                 byte[] data = s.serialize(a);
32                 
33                 System.out.println(s.getSize(c) + " bytes");
34                 
35                 Node d = (Node) s.deserialize( data );
36                 System.out.println( binding.toString(d) );
37                 
38         }
39         
40 }