mirror of
https://github.com/corda/corda.git
synced 2025-06-15 13:48:14 +00:00
update NIO code to be more compatible with Java
This commit is contained in:
@ -10,12 +10,9 @@
|
||||
|
||||
package java.nio;
|
||||
|
||||
public class ByteBuffer implements Comparable<ByteBuffer> {
|
||||
public class ByteBuffer extends Buffer implements Comparable<ByteBuffer> {
|
||||
private final byte[] array;
|
||||
private int arrayOffset;
|
||||
private int capacity;
|
||||
private int position;
|
||||
private int limit;
|
||||
private final boolean readOnly;
|
||||
|
||||
public static ByteBuffer allocate(int capacity) {
|
||||
@ -55,12 +52,6 @@ public class ByteBuffer implements Comparable<ByteBuffer> {
|
||||
return array;
|
||||
}
|
||||
|
||||
public ByteBuffer clear() {
|
||||
position = 0;
|
||||
limit = capacity;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ByteBuffer slice() {
|
||||
ByteBuffer buf = new ByteBuffer(array, true);
|
||||
buf.arrayOffset = arrayOffset + position;
|
||||
@ -70,22 +61,6 @@ public class ByteBuffer implements Comparable<ByteBuffer> {
|
||||
return buf;
|
||||
}
|
||||
|
||||
public int limit() {
|
||||
return limit;
|
||||
}
|
||||
|
||||
public int remaining() {
|
||||
return limit-position;
|
||||
}
|
||||
|
||||
public int position() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public int capacity() {
|
||||
return capacity;
|
||||
}
|
||||
|
||||
public int arrayOffset() {
|
||||
return arrayOffset;
|
||||
}
|
||||
@ -100,16 +75,6 @@ public class ByteBuffer implements Comparable<ByteBuffer> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ByteBuffer limit(int newLimit) {
|
||||
limit = newLimit;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ByteBuffer position(int newPosition) {
|
||||
position = newPosition;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ByteBuffer put(byte val) {
|
||||
checkPut(1);
|
||||
array[arrayOffset+(position++)] = val;
|
||||
@ -164,10 +129,6 @@ public class ByteBuffer implements Comparable<ByteBuffer> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasRemaining() {
|
||||
return remaining() > 0;
|
||||
}
|
||||
|
||||
public byte get() {
|
||||
checkGet(1);
|
||||
return array[arrayOffset+(position++)];
|
||||
@ -189,12 +150,6 @@ public class ByteBuffer implements Comparable<ByteBuffer> {
|
||||
return array[arrayOffset+position];
|
||||
}
|
||||
|
||||
public ByteBuffer flip() {
|
||||
limit = position;
|
||||
position = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getInt() {
|
||||
checkGet(4);
|
||||
int i = get() << 24;
|
||||
|
Reference in New Issue
Block a user