List of utility methods to do ByteBuffer to Long Array
long[] | deserializeLongArray(ByteBuffer buffer) deserialize Long Array int size = buffer.getInt(); long[] nums = new long[size]; for (int i = 0; i < size; i++) { nums[i] = buffer.getLong(); return nums; |
long | getLong(ByteBuffer buffer) get Long assert (buffer.capacity() - buffer.position() >= 8); long[] data = new long[8]; data[7] = buffer.get(); data[6] = buffer.get(); data[5] = buffer.get(); data[4] = buffer.get(); data[3] = buffer.get(); data[2] = buffer.get(); ... |
long | getLong(ByteBuffer byteBuffer, int longIndex) get Long int index = longIndex * 8; if (index >= byteBuffer.limit()) { return 0L; if (byteBuffer.limit() >= index + 8) { return makeLong(byteBuffer.get(index + 0), byteBuffer.get(index + 1), byteBuffer.get(index + 2), byteBuffer.get(index + 3), byteBuffer.get(index + 4), byteBuffer.get(index + 5), byteBuffer.get(index + 6), byteBuffer.get(index + 7)); ... |
long | getLong(ByteBuffer in) Get a long integer from the byte buffer. int i = in.getInt(); if (i != 0xFFFFFFFF) return i; try { return in.getLong(); } catch (BufferUnderflowException bue) { in.position(in.position() - 4); throw bue; ... |
float | getLong(ByteBuffer longCalculator, byte[] bytes) Calculates the corresponding long given 8 sequential bytes. longCalculator.clear();
longCalculator.put(bytes);
longCalculator.position(0);
return longCalculator.getLong();
|
long | getLongB(ByteBuffer bb, int index) get Long B return makeLong(bb.get(index), bb.get(index + 1), bb.get(index + 2), bb.get(index + 3), bb.get(index + 4),
bb.get(index + 5), bb.get(index + 6), bb.get(index + 7));
|
long | getLongBE(ByteBuffer b, int start, int end) get Long BE int number = 0; for (int i = 0; i < (end - start + 1); i++) { number += ((b.get(end - i) & 0xFF) << i * 8); return number; |
ByteBuffer | getLongByteBuffer(long id) get Long Byte Buffer ByteBuffer buffer = ByteBuffer.allocate(longSize);
buffer.putLong(id);
buffer.flip();
return buffer;
|
long | getLongFromBuffer(ByteBuffer buffer, int offset, int size) Gets long from buffer long data = 0; try { if (size == 1) { data |= buffer.get(offset) & 0xFF; } else if (size == 2) { data |= buffer.getShort(offset) & 0xFFFF; data = Short.reverseBytes((short) data); } else if (size == 4) { ... |
Long | getLongFromByteBuffer(ByteBuffer data) long from ByteBuffer return getLongFromBytes(data.array());
|