ByteBuffer and InputStream now better match the standard.

This commit is contained in:
JET 2011-10-20 13:45:47 -06:00
parent 9ac8117d04
commit 39bee886e3
2 changed files with 15 additions and 10 deletions

View File

@ -56,7 +56,7 @@ public abstract class InputStream {
} }
public void reset() throws IOException { public void reset() throws IOException {
// ignore throw new IOException("mark/reset not supported");
} }
public boolean markSupported() { public boolean markSupported() {

View File

@ -15,45 +15,50 @@ public abstract class Buffer {
protected int position; protected int position;
protected int limit; protected int limit;
public int limit() { public final int limit() {
return limit; return limit;
} }
public int remaining() { public final int remaining() {
return limit-position; return limit-position;
} }
public int position() { public final int position() {
return position; return position;
} }
public int capacity() { public final int capacity() {
return capacity; return capacity;
} }
public Buffer limit(int newLimit) { public final Buffer limit(int newLimit) {
limit = newLimit; limit = newLimit;
return this; return this;
} }
public Buffer position(int newPosition) { public final Buffer position(int newPosition) {
position = newPosition; position = newPosition;
return this; return this;
} }
public boolean hasRemaining() { public final boolean hasRemaining() {
return remaining() > 0; return remaining() > 0;
} }
public Buffer clear() { public final Buffer clear() {
position = 0; position = 0;
limit = capacity; limit = capacity;
return this; return this;
} }
public Buffer flip() { public final Buffer flip() {
limit = position; limit = position;
position = 0; position = 0;
return this; return this;
} }
public final Buffer rewind() {
position = 0;
return this;
}
} }