diff src/org/eclipse/jetty/io/JBuffer.java @ 1048:2b769da7f67d

remove Buffer
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 07 Nov 2016 23:15:42 -0700
parents a8c92b0a08ed
children 4afdf0f0c5bc
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/JBuffer.java	Mon Nov 07 22:51:09 2016 -0700
+++ b/src/org/eclipse/jetty/io/JBuffer.java	Mon Nov 07 23:15:42 2016 -0700
@@ -9,11 +9,10 @@
 import java.nio.channels.ReadableByteChannel;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.eclipse.jetty.io.nio.NIOBuffer;
 import org.eclipse.jetty.util.TypeUtil;
 
 
-public final class JBuffer implements NIOBuffer {
+public final class JBuffer {
 	private static final Logger LOG = LoggerFactory.getLogger(JBuffer.class);
 
 	private final ByteBuffer bb;
@@ -22,37 +21,30 @@
 		this.bb = bb;
 	}
 
-	@Override
 	public byte[] array() {
 		return bb.hasArray() ? bb.array() : null;
 	}
 
-	@Override
-	public Buffer duplicate() {
+	public JBuffer duplicate() {
 		return new JBuffer(bb.duplicate());
 	}
 
-	@Override
 	public int remaining() {
 		return bb.remaining();
 	}
 
-	@Override
 	public boolean isReadOnly() {
 		return bb.isReadOnly();
 	}
 
-	@Override
 	public boolean hasRemaining() {
 		return bb.hasRemaining();
 	}
 
-	@Override
 	public byte get() {
 		return bb.get();
 	}
 
-	@Override
 	public void compact() {
 		int n = bb.remaining();
 		bb.compact();
@@ -60,49 +52,41 @@
 		bb.limit(n);
 	}
 
-	@Override
 	public int capacity() {
 		return bb.capacity();
 	}
 
-	@Override
 	public boolean isDirect() {
 		return bb.isDirect();
 	}
 
 
 
-	@Override
 	public ByteBuffer getByteBuffer() {
 		ByteBuffer dup = bb.duplicate();
 		dup.limit(dup.capacity());
 		return dup;
 	}
 
-	@Override
 	public int getIndex() {
 		return bb.position();
 	}
 
-	@Override
 	public void clear() {
 		bb.position(0);
 		bb.limit(0);
 	}
 
-	@Override
 	public int space() {
 		return bb.capacity() - bb.limit();
 	}
 
-	@Override
-	public Buffer buffer() {
+	public JBuffer buffer() {
 		return this;
 	}
 
 
-	@Override
-	public Buffer get(int length) {
+	public JBuffer get(int length) {
 		ByteBuffer dup = bb.duplicate();
 		int end = bb.position()+length;
 		dup.limit(end);
@@ -110,7 +94,6 @@
 		return new JBuffer(dup);
 	}
 
-	@Override
 	public int get(byte[] b, int offset, int length) {
 		int remaining = bb.remaining();
 		if( remaining == 0 )
@@ -122,12 +105,10 @@
 	}
 
 
-	@Override
-	public int put(Buffer src) {
+	public int put(JBuffer src) {
 		return put(src.asArray());
 	}
 
-	@Override
 	public void put(byte b)
 	{
 		ByteBuffer dup = bb.duplicate();
@@ -137,7 +118,6 @@
 		bb.limit(bb.limit()+1);
 	}
 
-	@Override
 	public int put(byte[] b, int offset, int length) {
 		ByteBuffer dup = bb.duplicate();
 		int put = bb.limit();
@@ -151,47 +131,39 @@
 		return length;
 	}
 
-	@Override
 	public int put(byte[] b) {
 		return put(b,0,b.length);
 	}
 
-	@Override
 	public final int putIndex() {
 		return bb.limit();
 	}
 
-	@Override
 	public void setGetIndex(int getIndex) {
 		bb.position(getIndex);
 	}
 
-	@Override
 	public void setPutIndex(int putIndex) {
 		bb.limit(putIndex);
 	}
 
-	@Override
 	public int skip(int n) {
 		if (remaining() < n) n = remaining();
 		bb.position(bb.position() + n);
 		return n;
 	}
 
-	@Override
-	public Buffer slice() {
+	public JBuffer slice() {
 		return duplicate();
 	}
 
-	@Override
-	public final Buffer sliceFrom(int index) {
+	public final JBuffer sliceFrom(int index) {
 		ByteBuffer dup = bb.duplicate();
 		dup.position(index);
 		dup.limit(bb.position()-1);
 		return new JBuffer(dup);
 	}
 
-	@Override
 	public int readFrom(InputStream in,int max) throws IOException {
 		ByteBuffer dup = bb.duplicate();
 		int put = bb.limit();
@@ -218,7 +190,6 @@
 		return toString("ISO-8859-1");
 	}
 
-	@Override
 	public final String toString(int index, int length) {
 		ByteBuffer dup = bb.duplicate();
 		dup.limit(index+length);
@@ -226,7 +197,6 @@
 		return new JBuffer(dup).toString();
 	}
 
-	@Override
 	public final String toString(String charset)
 	{
 		byte[] bytes = asArray();
@@ -241,7 +211,6 @@
 		}
 	}
 
-	@Override
 	public String toDetailString()
 	{
 		StringBuilder buf = new StringBuilder();
@@ -276,45 +245,39 @@
 
 
 
-	private Buffer pokeBuffer(int index) {
-		Buffer dup = duplicate();
+	private JBuffer pokeBuffer(int index) {
+		JBuffer dup = duplicate();
 		dup.setPutIndex(index);
 		return dup;
 	}
 
-	@Override
 	public int poke(int index, byte b[], int offset, int length) {
 		return pokeBuffer(index).put(b,offset,length);
 	}
 
-	@Override
 	public void poke(int index, byte b) {
 		pokeBuffer(index).put(b);
 	}
 
-	@Override
-	public int poke(int index, Buffer src) {
+	public int poke(int index, JBuffer src) {
 		return pokeBuffer(index).put(src);
 	}
 
-	private Buffer peekBuffer(int index) {
-		Buffer dup = duplicate();
+	private JBuffer peekBuffer(int index) {
+		JBuffer dup = duplicate();
 		dup.setGetIndex(index);
 		dup.setPutIndex(dup.capacity());
 		return dup;
 	}
 
-	@Override
 	public int peek(int index, byte[] b, int offset, int length) {
 		return peekBuffer(index).get(b,offset,length);
 	}
 
-	@Override
 	public byte peek(int index) {
 		return bb.get(index);
 	}
 
-	@Override
 	public byte peek() {
 		return peek(bb.position());
 	}