Add support for some methods in NIO buffers from Java 11

This commit is contained in:
Alexey Andreev 2019-08-21 13:56:39 +03:00
parent 0a5ed2b4a5
commit 75e38c51de
8 changed files with 301 additions and 7 deletions

View File

@ -34,7 +34,7 @@ public abstract class TBuffer {
return position;
}
public final TBuffer position(int newPosition) {
public TBuffer position(int newPosition) {
if (newPosition < 0 || newPosition > limit) {
throw new IllegalArgumentException("New position " + newPosition + " is outside of range [0;"
+ limit + "]");
@ -50,7 +50,7 @@ public abstract class TBuffer {
return limit;
}
public final TBuffer limit(int newLimit) {
public TBuffer limit(int newLimit) {
if (newLimit < 0 || newLimit > capacity) {
throw new IllegalArgumentException("New limit " + newLimit + " is outside of range [0;"
+ capacity + "]");
@ -65,12 +65,12 @@ public abstract class TBuffer {
return this;
}
public final TBuffer mark() {
public TBuffer mark() {
mark = position;
return this;
}
public final TBuffer reset() {
public TBuffer reset() {
if (mark < 0) {
throw new TInvalidMarkException();
}
@ -78,21 +78,21 @@ public abstract class TBuffer {
return this;
}
public final TBuffer clear() {
public TBuffer clear() {
position = 0;
limit = capacity;
mark = -1;
return this;
}
public final TBuffer flip() {
public TBuffer flip() {
limit = position;
position = 0;
mark = -1;
return this;
}
public final TBuffer rewind() {
public TBuffer rewind() {
mark = -1;
position = 0;
return this;

View File

@ -256,4 +256,46 @@ public abstract class TByteBuffer extends TBuffer implements TComparable<TByteBu
public abstract TFloatBuffer asFloatBuffer();
public abstract TDoubleBuffer asDoubleBuffer();
@Override
public final TByteBuffer mark() {
super.mark();
return this;
}
@Override
public final TByteBuffer reset() {
super.reset();
return this;
}
@Override
public final TByteBuffer clear() {
super.clear();
return this;
}
@Override
public final TByteBuffer flip() {
super.flip();
return this;
}
@Override
public final TByteBuffer rewind() {
super.rewind();
return this;
}
@Override
public TByteBuffer limit(int newLimit) {
super.limit(newLimit);
return this;
}
@Override
public TByteBuffer position(int newPosition) {
super.position(newPosition);
return this;
}
}

View File

@ -305,4 +305,46 @@ public abstract class TCharBuffer extends TBuffer implements Comparable<TCharBuf
}
public abstract TByteOrder order();
@Override
public final TCharBuffer mark() {
super.mark();
return this;
}
@Override
public final TCharBuffer reset() {
super.reset();
return this;
}
@Override
public final TCharBuffer clear() {
super.clear();
return this;
}
@Override
public final TCharBuffer flip() {
super.flip();
return this;
}
@Override
public final TCharBuffer rewind() {
super.rewind();
return this;
}
@Override
public TCharBuffer limit(int newLimit) {
super.limit(newLimit);
return this;
}
@Override
public TCharBuffer position(int newPosition) {
super.position(newPosition);
return this;
}
}

View File

@ -211,4 +211,46 @@ public abstract class TDoubleBuffer extends TBuffer implements Comparable<TDoubl
}
public abstract TByteOrder order();
@Override
public final TDoubleBuffer mark() {
super.mark();
return this;
}
@Override
public final TDoubleBuffer reset() {
super.reset();
return this;
}
@Override
public final TDoubleBuffer clear() {
super.clear();
return this;
}
@Override
public final TDoubleBuffer flip() {
super.flip();
return this;
}
@Override
public final TDoubleBuffer rewind() {
super.rewind();
return this;
}
@Override
public TDoubleBuffer limit(int newLimit) {
super.limit(newLimit);
return this;
}
@Override
public TDoubleBuffer position(int newPosition) {
super.position(newPosition);
return this;
}
}

View File

@ -210,4 +210,46 @@ public abstract class TFloatBuffer extends TBuffer implements Comparable<TFloatB
}
public abstract TByteOrder order();
@Override
public final TFloatBuffer mark() {
super.mark();
return this;
}
@Override
public final TFloatBuffer reset() {
super.reset();
return this;
}
@Override
public final TFloatBuffer clear() {
super.clear();
return this;
}
@Override
public final TFloatBuffer flip() {
super.flip();
return this;
}
@Override
public final TFloatBuffer rewind() {
super.rewind();
return this;
}
@Override
public TFloatBuffer limit(int newLimit) {
super.limit(newLimit);
return this;
}
@Override
public TFloatBuffer position(int newPosition) {
super.position(newPosition);
return this;
}
}

View File

@ -210,4 +210,46 @@ public abstract class TIntBuffer extends TBuffer implements Comparable<TIntBuffe
}
public abstract TByteOrder order();
@Override
public final TIntBuffer mark() {
super.mark();
return this;
}
@Override
public final TIntBuffer reset() {
super.reset();
return this;
}
@Override
public final TIntBuffer clear() {
super.clear();
return this;
}
@Override
public final TIntBuffer flip() {
super.flip();
return this;
}
@Override
public final TIntBuffer rewind() {
super.rewind();
return this;
}
@Override
public TIntBuffer limit(int newLimit) {
super.limit(newLimit);
return this;
}
@Override
public TIntBuffer position(int newPosition) {
super.position(newPosition);
return this;
}
}

View File

@ -211,4 +211,46 @@ public abstract class TLongBuffer extends TBuffer implements Comparable<TLongBuf
}
public abstract TByteOrder order();
@Override
public final TLongBuffer mark() {
super.mark();
return this;
}
@Override
public final TLongBuffer reset() {
super.reset();
return this;
}
@Override
public final TLongBuffer clear() {
super.clear();
return this;
}
@Override
public final TLongBuffer flip() {
super.flip();
return this;
}
@Override
public final TLongBuffer rewind() {
super.rewind();
return this;
}
@Override
public TLongBuffer limit(int newLimit) {
super.limit(newLimit);
return this;
}
@Override
public TLongBuffer position(int newPosition) {
super.position(newPosition);
return this;
}
}

View File

@ -210,4 +210,46 @@ public abstract class TShortBuffer extends TBuffer implements Comparable<TShortB
}
public abstract TByteOrder order();
@Override
public final TShortBuffer mark() {
super.mark();
return this;
}
@Override
public final TShortBuffer reset() {
super.reset();
return this;
}
@Override
public final TShortBuffer clear() {
super.clear();
return this;
}
@Override
public final TShortBuffer flip() {
super.flip();
return this;
}
@Override
public final TShortBuffer rewind() {
super.rewind();
return this;
}
@Override
public TShortBuffer limit(int newLimit) {
super.limit(newLimit);
return this;
}
@Override
public TShortBuffer position(int newPosition) {
super.position(newPosition);
return this;
}
}