Example usage for io.netty.util.internal PlatformDependent getInt

List of usage examples for io.netty.util.internal PlatformDependent getInt

Introduction

In this page you can find the example usage for io.netty.util.internal PlatformDependent getInt.

Prototype

public static int getInt(byte[] data, int index) 

Source Link

Usage

From source file:herddb.utils.Bytes.java

License:Apache License

public static int toInt(byte[] array, int index) {
    if (HAS_UNSAFE && UNALIGNED) {
        int v = PlatformDependent.getInt(array, index);
        return BIG_ENDIAN_NATIVE_ORDER ? v : Integer.reverseBytes(v);
    }/*from   w  w w  .  j a  v a 2s  . c  o  m*/

    return (array[index] & 0xff) << 24 | //
            (array[index + 1] & 0xff) << 16 | //
            (array[index + 2] & 0xff) << 8 | //
            array[index + 3] & 0xff;
}