1 package org.simantics.acorn.internal;
3 import org.simantics.acorn.exception.IllegalAcornStateException;
4 import org.simantics.db.service.Bytes;
5 import org.simantics.db.service.ClusterUID;
7 public abstract class ClusterUpdateProcessorBase2 {
9 final private byte[] bytes;
11 final private int len;
12 final private ClusterUID uid;
14 public ClusterUpdateProcessorBase2(byte[] operations) {
15 this.bytes = operations;
16 this.len = Bytes.readLE4(bytes, 0) + 4; // whatta?
17 int version = Bytes.readLE4(bytes, 4);
18 assert(version == ClusterChange2.VERSION);
19 long cuid1 = Bytes.readLE8(bytes, 8);
20 long cuid2 = Bytes.readLE8(bytes, 16);
22 uid = ClusterUID.make(cuid1, cuid2);
25 public ClusterUID getClusterUID() {
29 private void processSetImmutable(int op) {
30 int value = bytes[pos++]&0xff;
31 setImmutable(value > 0);
34 private void processUndoValue(int op) {
35 Bytes.readLE4(bytes, pos);
39 public void process() throws IllegalAcornStateException {
43 int op = bytes[pos++]&0xff;
47 case ClusterChange2.SET_IMMUTABLE_OPERATION:
48 processSetImmutable(op);
50 case ClusterChange2.UNDO_VALUE_OPERATION:
54 throw new IllegalAcornStateException("Can not process cluster " + uid);
60 abstract void setImmutable(boolean value);