]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.history/test/org/simantics/history/test/TestXYZ.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.history / test / org / simantics / history / test / TestXYZ.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2012 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.history.test;
13
14 import org.simantics.databoard.Bindings;
15 import org.simantics.databoard.binding.Binding;
16 import org.simantics.databoard.binding.mutable.Variant;
17 import org.simantics.databoard.serialization.Serializer;
18 import org.simantics.history.impl.CollectorState;
19 import org.simantics.history.impl.CollectorState.Item;
20
21 public class TestXYZ {
22
23         public static void main(String[] args) throws Exception {
24                 
25                 CollectorState.Item cs = new CollectorState.Item();
26                 Binding b = Bindings.getBinding(CollectorState.Item.class);
27                 cs = (CollectorState.Item) b.createDefault();
28                 Serializer s = Bindings.getSerializer(b);
29                 byte[] dat = s.serialize(cs);
30                 cs = (Item) s.deserialize(dat);
31                 System.out.println(b.toString(cs));
32                 
33                 Variant v = new Variant(b, cs);
34                 Serializer vs = Bindings.getSerializer( Bindings.VARIANT );
35                 byte[] data = vs.serialize(v);          
36                 v = (Variant) vs.deserialize(data);
37                 System.out.println(v);
38                 
39                 Binding b2 = Bindings.getBinding( b.type() );
40                 Object cs2 = Bindings.adapt(cs, b, b2);
41                 System.out.println(b2.toString(cs2));
42         }
43         
44 }