mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
implement asReadOnlyBuffer and getShort(int) in ByteBuffer
This commit is contained in:
parent
61457dca70
commit
84bcbbcaa3
@ -36,6 +36,13 @@ public class ByteBuffer extends Buffer implements Comparable<ByteBuffer> {
|
||||
position = 0;
|
||||
}
|
||||
|
||||
public ByteBuffer asReadOnlyBuffer() {
|
||||
ByteBuffer b = new ByteBuffer(array, arrayOffset, capacity, true);
|
||||
b.position(position());
|
||||
b.limit(limit());
|
||||
return b;
|
||||
}
|
||||
|
||||
public int compareTo(ByteBuffer o) {
|
||||
int end = (remaining() < o.remaining() ? remaining() : o.remaining());
|
||||
|
||||
@ -159,6 +166,13 @@ public class ByteBuffer extends Buffer implements Comparable<ByteBuffer> {
|
||||
| ((array[p + 3] & 0xFF));
|
||||
}
|
||||
|
||||
public short getShort(int position) {
|
||||
checkGet(position, 2);
|
||||
|
||||
int p = arrayOffset + position;
|
||||
return (short) (((array[p] & 0xFF) << 8) | ((array[p + 1] & 0xFF)));
|
||||
}
|
||||
|
||||
public int getInt() {
|
||||
checkGet(4);
|
||||
int i = get() << 24;
|
||||
|
Loading…
Reference in New Issue
Block a user