Example usage for java.nio ByteBuffer getLong

List of usage examples for java.nio ByteBuffer getLong

Introduction

In this page you can find the example usage for java.nio ByteBuffer getLong.

Prototype

public abstract long getLong();

Source Link

Document

Returns the long at the current position and increases the position by 8.

Usage

From source file:org.linguafranca.pwdb.kdbx.Helpers.java

public static UUID uuidFromBase64(String base64) {
    // round the houses for Android
    byte[] buffer = Base64.decodeBase64(base64.getBytes());
    ByteBuffer b = ByteBuffer.wrap(buffer);
    return new UUID(b.getLong(), b.getLong(8));
}

From source file:com.alibaba.otter.shared.common.utils.ByteUtils.java

public static long bytes2long(byte[] data, int offset) {
    ByteBuffer buffer = ByteBuffer.wrap(data, offset, 8);
    return buffer.getLong();
}

From source file:com.cnaude.mutemanager.UUIDFetcher.java

public static UUID fromBytes(byte[] array) {
    if (array.length != 16) {
        throw new IllegalArgumentException("Illegal byte array length: " + array.length);
    }//from  w  w w  . j  a va 2s  .c o m
    ByteBuffer byteBuffer = ByteBuffer.wrap(array);
    long mostSignificant = byteBuffer.getLong();
    long leastSignificant = byteBuffer.getLong();
    return new UUID(mostSignificant, leastSignificant);
}

From source file:com.simpsonwil.strongquests.util.UUIDFetcher.java

public static UUID fromBytes(byte[] array) {
    if (array.length != 16)
        throw new IllegalArgumentException("Illegal byte array length: " + array.length);

    ByteBuffer byteBuffer = ByteBuffer.wrap(array);
    long mostSignificant = byteBuffer.getLong();
    long leastSignificant = byteBuffer.getLong();

    return new UUID(mostSignificant, leastSignificant);
}

From source file:com.intellectualcrafters.plot.uuid.UUIDFetcher.java

@SuppressWarnings("unused")
public static UUID fromBytes(final byte[] array) {
    if (array.length != 16) {
        throw new IllegalArgumentException("Illegal byte array length: " + array.length);
    }//  w ww.j a va  2s  . com
    final ByteBuffer byteBuffer = ByteBuffer.wrap(array);
    final long mostSignificant = byteBuffer.getLong();
    final long leastSignificant = byteBuffer.getLong();
    return new UUID(mostSignificant, leastSignificant);
}

From source file:com.sm.store.Utils.java

public static Value bytesToValue(byte[] bytes) {
    int len = bytes.length;
    ByteBuffer buf = ByteBuffer.wrap(bytes);
    long ver = buf.getLong();
    short node = buf.getShort();
    byte[] data = new byte[len - 10];
    buf.get(data);/*from w w  w  .j  av a  2s .c om*/
    return CacheValue.createValue(data, ver, node);
}

From source file:com.alibaba.otter.shared.common.utils.ByteUtils.java

public static long bytes2long(byte[] b) {
    ByteBuffer buf = ByteBuffer.allocate(8);
    buf.put(b);/*  w  w w.  j a v a2 s.c om*/
    buf.flip();
    return buf.getLong();
}

From source file:com.sm.store.Utils.java

public static void addOneLong(Value value) {
    ByteBuffer buf = ByteBuffer.wrap((byte[]) value.getData());
    long k = buf.getLong() + 1;
    byte[] data = putLong(k);
    value.setData(data);/*from  ww  w.  java 2 s.com*/
    value.setVersion(value.getVersion() + 1);
}

From source file:org.bimserver.utils.BinUtils.java

public static long byteArrayToLong(byte[] bytes) {
    ByteBuffer byteBuffer = ByteBuffer.wrap(bytes);
    return byteBuffer.getLong();
}

From source file:com.pushtechnology.diffusion.examples.runnable.RandomData.java

/**
 * Deserialize a {@link Binary} value as a {@link RandomData} value.
 * @param binary The {@link Binary} value
 * @return The {@link RandomData} value//from  w  w  w  . j ava 2s . co m
 */
static RandomData fromBinary(Binary binary) {
    final ByteBuffer buffer = ByteBuffer.wrap(binary.toByteArray());
    final int id = buffer.getInt();
    final long timestamp = buffer.getLong();
    final int randomInt = buffer.getInt();
    return new RandomData(id, timestamp, randomInt);
}