]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/Change.java
Merge commit '3efd7d44a55ae1fff284a1826e7c9afe27e0815e'
[simantics/platform.git] / bundles / org.simantics.db.procore / src / fi / vtt / simantics / procore / internal / Change.java
1 package fi.vtt.simantics.procore.internal;\r
2 \r
3 import org.simantics.db.service.ClusterUID;\r
4 \r
5 final public class Change {\r
6     \r
7     byte op0;\r
8     int key0;\r
9     int key1;\r
10     int key2;\r
11     ClusterUID clusterUID1;\r
12     ClusterUID clusterUID2;\r
13     byte[] lookup1;\r
14     byte[] lookup2;\r
15     byte lookIndex1;\r
16     byte lookIndex2;\r
17     int lastArg = 0;\r
18 \r
19     @Override\r
20     public String toString() {\r
21         return "Change " + (key0&0xffff) + " " + (key1&0xffff) + " " + (key2&0xffff) + " " + clusterUID2 + " " + clusterUID2;\r
22     }\r
23     \r
24     public final void init() {\r
25         lastArg = 0;\r
26     }\r
27 \r
28     public final void initValue() {\r
29         lastArg = 0;\r
30     }\r
31 \r
32     final void addStatementIndex0(int key, byte op) {\r
33         assert (op != 0);\r
34         key0 = key;\r
35         op0 = op;\r
36     }\r
37 \r
38     final void addStatementIndex1(int key, ClusterUID clusterUID, byte lookIndex, byte[] lookup) {\r
39         key1 = key;\r
40         clusterUID1 = clusterUID;\r
41         lookIndex1 = lookIndex;\r
42         lookup1 = lookup;\r
43 //        if(lookIndex > 0)\r
44 //            System.err.println("statementIndex1 " + pos + " " + lookIndex);\r
45     }\r
46 \r
47     final void addStatementIndex2(int key, ClusterUID clusterUID, byte lookIndex, byte[] lookup) {\r
48         key2 = key;\r
49         clusterUID2 = clusterUID;\r
50         lookIndex2 = lookIndex;\r
51         lookup2 = lookup;\r
52     }\r
53 \r
54     final void addStatementIndex(int key, ClusterUID clusterUID, byte op) {\r
55 \r
56         // new Exception("lastArg=" + lastArg).printStackTrace();\r
57 \r
58         assert (lastArg < 3);\r
59 \r
60         if (0 == lastArg)\r
61             addStatementIndex0(key, op);\r
62         else if (1 == lastArg)\r
63             addStatementIndex1(key, clusterUID, (byte)0, null);\r
64         else if (2 == lastArg)\r
65             addStatementIndex2(key, clusterUID, (byte)0, null);\r
66 \r
67         lastArg++;\r
68 \r
69     }\r
70 }\r