X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.db%2Fsrc%2Forg%2Fsimantics%2Fdb%2Fservice%2FBytes.java;h=a75f0a5e5ed31f2c7159b76ddd86c30a0e4d056d;hp=fcd12a0ca7fcc1a37420ecf9e973e54d2c6dafe2;hb=HEAD;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.db/src/org/simantics/db/service/Bytes.java b/bundles/org.simantics.db/src/org/simantics/db/service/Bytes.java index fcd12a0ca..a75f0a5e5 100644 --- a/bundles/org.simantics.db/src/org/simantics/db/service/Bytes.java +++ b/bundles/org.simantics.db/src/org/simantics/db/service/Bytes.java @@ -1,120 +1,120 @@ -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; - } - -} +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; + } + +}