]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.databoard/examples/org/simantics/databoard/example/AccessorReference.java
Fixed ComponentTypeCommands.setUnit to support unit == null
[simantics/platform.git] / bundles / org.simantics.databoard / examples / org / simantics / databoard / example / AccessorReference.java
1 package org.simantics.databoard.example;
2
3 import org.simantics.databoard.Accessors;
4 import org.simantics.databoard.Bindings;
5 import org.simantics.databoard.accessor.Accessor;
6 import org.simantics.databoard.accessor.error.AccessorConstructionException;
7 import org.simantics.databoard.accessor.error.AccessorException;
8 import org.simantics.databoard.accessor.reference.ChildReference;
9 import org.simantics.databoard.binding.Binding;
10 import org.simantics.databoard.binding.error.BindingConstructionException;
11
12 public class AccessorReference {
13
14         public static void main(String[] args) throws BindingConstructionException, AccessorConstructionException, AccessorException {
15                 
16                 
17                 int[][] data = new int[100][100];
18                 
19                 Accessor a = Accessors.getAccessor(data);
20                 
21                 // i-4/i-5
22                 String reference = "i-4/i-5";
23                 ChildReference ref = ChildReference.parsePath( reference );             
24                 a.getComponent(ref).setValue(Bindings.INTEGER, 100);            
25                 System.out.println(data[4][5]);
26                 
27                 // 4/5
28                 reference = "4/5";
29                 ref = ChildReference.parsePath( reference );            
30                 a.getComponent(ref).setValue(Bindings.INTEGER, -100);
31                 System.out.println(data[4][5]);
32                 
33                 
34         }
35         
36 }