--- /dev/null
+package org.simantics.acorn.internal;
+
+import org.simantics.db.service.Bytes;
+import org.simantics.db.service.ClusterUID;
+
+public abstract class ClusterUpdateProcessorBase2 {
+
+ final private byte[] bytes;
+ private int pos = 0;
+ final private int len;
+ final private ClusterUID uid;
+
+ public ClusterUpdateProcessorBase2(byte[] operations) {
+ this.bytes = operations;
+ this.len = Bytes.readLE4(bytes, 0) + 4; // whatta?
+ int version = Bytes.readLE4(bytes, 4);
+ assert(version == ClusterChange2.VERSION);
+ long cuid1 = Bytes.readLE8(bytes, 8);
+ long cuid2 = Bytes.readLE8(bytes, 16);
+ pos = 24;
+ uid = ClusterUID.make(cuid1, cuid2);
+ }
+
+ public ClusterUID getClusterUID() {
+ return uid;
+ }
+
+ private void processSetImmutable(int op) {
+ int value = bytes[pos++]&0xff;
+ setImmutable(value > 0);
+ }
+
+ private void processUndoValue(int op) {
+ Bytes.readLE4(bytes, pos);
+ pos+=4;
+ }
+
+ public void process() {
+
+ while(pos < len) {
+
+ int op = bytes[pos++]&0xff;
+
+ switch(op) {
+
+ case ClusterChange2.SET_IMMUTABLE_OPERATION:
+ processSetImmutable(op);
+ break;
+ case ClusterChange2.UNDO_VALUE_OPERATION:
+ processUndoValue(op);
+ break;
+ default:
+ throw new IllegalStateException();
+
+ }
+
+ }
+
+ }
+
+ abstract void setImmutable(boolean value);
+
+}