]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db/src/org/simantics/db/service/Bytes.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.db / src / org / simantics / db / service / Bytes.java
index fcd12a0ca7fcc1a37420ecf9e973e54d2c6dafe2..a75f0a5e5ed31f2c7159b76ddd86c30a0e4d056d 100644 (file)
-package org.simantics.db.service;\r
-\r
-\r
-final public class Bytes {\r
-\r
-       final public static void write(byte[] bytes, int index, byte value) {\r
-               bytes[index] = value;\r
-       }\r
-\r
-       final public static void writeLE(byte[] bytes, int index, long value) {\r
-               \r
-               bytes[index++] = (byte) (value & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 8) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 16) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 24) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 32) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 40) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 48) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 56) & 0xFF);\r
-               \r
-       }\r
-\r
-       final public static void writeLE6(byte[] bytes, int index, long value) {\r
-               \r
-               bytes[index++] = (byte) (value & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 8) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 16) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 24) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 32) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 40) & 0xFF);\r
-               \r
-       }\r
-\r
-       final public static void writeLE7(byte[] bytes, int index, long value) {\r
-               \r
-               bytes[index++] = (byte) (value & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 8) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 16) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 24) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 32) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 40) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 48) & 0xFF);\r
-               \r
-       }\r
-       \r
-       final public static void writeLE8(byte[] bytes, int index, long value) {\r
-               \r
-               bytes[index++] = (byte) (value & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 8) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 16) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 24) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 32) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 40) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 48) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 56) & 0xFF);\r
-               \r
-       }\r
-\r
-       final public static void writeLE(byte[] bytes, int index, int value) {\r
-               \r
-               bytes[index++] = (byte) (value & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 8) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 16) & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 24) & 0xFF);\r
-               \r
-       }\r
-\r
-       final public static void writeLE(byte[] bytes, int index, short value) {\r
-               \r
-               bytes[index++] = (byte) (value & 0xFF);\r
-               bytes[index++] = (byte) ((value >>> 8) & 0xFF);\r
-               \r
-       }\r
-       \r
-       final public static byte read(byte[] bytes, int byteIndex) {\r
-               return bytes[byteIndex++];\r
-       }\r
-\r
-       final public static int readLE2(byte[] bytes, int byteIndex) {\r
-               int result = (int) \r
-                       (((int)(bytes[byteIndex++] & 0xff)) | \r
-                       (((int)(bytes[byteIndex++] & 0xff))<<8)); \r
-               return result;\r
-       }\r
-\r
-       final public static int readLE4(byte[] bytes, int byteIndex) {\r
-               int result = (int) \r
-                       (((int)(bytes[byteIndex++] & 0xff)) | \r
-                       (((int)(bytes[byteIndex++] & 0xff))<<8) | \r
-                       (((int)(bytes[byteIndex++] & 0xff))<<16) | \r
-                       (((int)(bytes[byteIndex++] & 0xff))<<24)); \r
-               return result;\r
-       }\r
-       \r
-       final public static long readLE7(byte[] bytes, int byteIndex) {\r
-               long result = (long) \r
-                       (((long)(bytes[byteIndex++] & 0xff)) | \r
-                       (((long)(bytes[byteIndex++] & 0xff))<<8) | \r
-                       (((long)(bytes[byteIndex++] & 0xff))<<16) | \r
-                       (((long)(bytes[byteIndex++] & 0xff))<<24) | \r
-                       (((long)(bytes[byteIndex++] & 0xff))<<32) | \r
-                       (((long)(bytes[byteIndex++] & 0xff))<<40) | \r
-                       (((long)(bytes[byteIndex++] & 0xff))<<48));\r
-               return result;\r
-       }\r
-\r
-       final public static long readLE8(byte[] bytes, int byteIndex) {\r
-               long result = (long) \r
-                       (((long)(bytes[byteIndex++] & 0xff)) | \r
-                       (((long)(bytes[byteIndex++] & 0xff))<<8) | \r
-                       (((long)(bytes[byteIndex++] & 0xff))<<16) | \r
-                       (((long)(bytes[byteIndex++] & 0xff))<<24) | \r
-                       (((long)(bytes[byteIndex++] & 0xff))<<32) | \r
-                       (((long)(bytes[byteIndex++] & 0xff))<<40) | \r
-                       (((long)(bytes[byteIndex++] & 0xff))<<48) | \r
-                       (((long)(bytes[byteIndex++] & 0xff))<<56));\r
-               return result;\r
-       }\r
-               \r
-}\r
+package org.simantics.db.service;
+
+
+final public class Bytes {
+
+       final public static void write(byte[] bytes, int index, byte value) {
+               bytes[index] = value;
+       }
+
+       final public static void writeLE(byte[] bytes, int index, long value) {
+               
+               bytes[index++] = (byte) (value & 0xFF);
+               bytes[index++] = (byte) ((value >>> 8) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 16) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 24) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 32) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 40) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 48) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 56) & 0xFF);
+               
+       }
+
+       final public static void writeLE6(byte[] bytes, int index, long value) {
+               
+               bytes[index++] = (byte) (value & 0xFF);
+               bytes[index++] = (byte) ((value >>> 8) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 16) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 24) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 32) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 40) & 0xFF);
+               
+       }
+
+       final public static void writeLE7(byte[] bytes, int index, long value) {
+               
+               bytes[index++] = (byte) (value & 0xFF);
+               bytes[index++] = (byte) ((value >>> 8) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 16) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 24) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 32) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 40) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 48) & 0xFF);
+               
+       }
+       
+       final public static void writeLE8(byte[] bytes, int index, long value) {
+               
+               bytes[index++] = (byte) (value & 0xFF);
+               bytes[index++] = (byte) ((value >>> 8) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 16) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 24) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 32) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 40) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 48) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 56) & 0xFF);
+               
+       }
+
+       final public static void writeLE(byte[] bytes, int index, int value) {
+               
+               bytes[index++] = (byte) (value & 0xFF);
+               bytes[index++] = (byte) ((value >>> 8) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 16) & 0xFF);
+               bytes[index++] = (byte) ((value >>> 24) & 0xFF);
+               
+       }
+
+       final public static void writeLE(byte[] bytes, int index, short value) {
+               
+               bytes[index++] = (byte) (value & 0xFF);
+               bytes[index++] = (byte) ((value >>> 8) & 0xFF);
+               
+       }
+       
+       final public static byte read(byte[] bytes, int byteIndex) {
+               return bytes[byteIndex++];
+       }
+
+       final public static int readLE2(byte[] bytes, int byteIndex) {
+               int result = (int) 
+                       (((int)(bytes[byteIndex++] & 0xff)) | 
+                       (((int)(bytes[byteIndex++] & 0xff))<<8)); 
+               return result;
+       }
+
+       final public static int readLE4(byte[] bytes, int byteIndex) {
+               int result = (int) 
+                       (((int)(bytes[byteIndex++] & 0xff)) | 
+                       (((int)(bytes[byteIndex++] & 0xff))<<8) | 
+                       (((int)(bytes[byteIndex++] & 0xff))<<16) | 
+                       (((int)(bytes[byteIndex++] & 0xff))<<24)); 
+               return result;
+       }
+       
+       final public static long readLE7(byte[] bytes, int byteIndex) {
+               long result = (long) 
+                       (((long)(bytes[byteIndex++] & 0xff)) | 
+                       (((long)(bytes[byteIndex++] & 0xff))<<8) | 
+                       (((long)(bytes[byteIndex++] & 0xff))<<16) | 
+                       (((long)(bytes[byteIndex++] & 0xff))<<24) | 
+                       (((long)(bytes[byteIndex++] & 0xff))<<32) | 
+                       (((long)(bytes[byteIndex++] & 0xff))<<40) | 
+                       (((long)(bytes[byteIndex++] & 0xff))<<48));
+               return result;
+       }
+
+       final public static long readLE8(byte[] bytes, int byteIndex) {
+               long result = (long) 
+                       (((long)(bytes[byteIndex++] & 0xff)) | 
+                       (((long)(bytes[byteIndex++] & 0xff))<<8) | 
+                       (((long)(bytes[byteIndex++] & 0xff))<<16) | 
+                       (((long)(bytes[byteIndex++] & 0xff))<<24) | 
+                       (((long)(bytes[byteIndex++] & 0xff))<<32) | 
+                       (((long)(bytes[byteIndex++] & 0xff))<<40) | 
+                       (((long)(bytes[byteIndex++] & 0xff))<<48) | 
+                       (((long)(bytes[byteIndex++] & 0xff))<<56));
+               return result;
+       }
+               
+}