diff src/org/eclipse/jetty/io/AbstractBuffer.java @ 1031:921c25a05eaa

remove Buffer.asReadOnlyBuffer()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Nov 2016 02:04:40 -0600
parents 80cad9086593
children eca26899c4bc
line wrap: on
line diff
--- a/src/org/eclipse/jetty/io/AbstractBuffer.java	Thu Nov 03 01:10:09 2016 -0600
+++ b/src/org/eclipse/jetty/io/AbstractBuffer.java	Thu Nov 03 02:04:40 2016 -0600
@@ -37,11 +37,7 @@
 
 	private final static boolean __boundsChecking = Boolean.getBoolean("org.eclipse.jetty.io.AbstractBuffer.boundsChecking");
 	
-	protected final static String 
-	__IMMUTABLE = "IMMUTABLE", 
-	__READONLY = "READONLY",
-	__READWRITE = "READWRITE", 
-	__VOLATILE = "VOLATILE";
+	protected final static String __READONLY = "READONLY";
 	
 	protected int _access;
 
@@ -61,15 +57,10 @@
 	 */
 	protected AbstractBuffer(int access)
 	{
-//		if (access == IMMUTABLE && isVolatile)
-//				throw new IllegalArgumentException("IMMUTABLE && VOLATILE");
 		setMarkIndex(-1);
 		_access = access;
 	}
 
-	/*
-	 * @see org.eclipse.io.Buffer#toArray()
-	 */
 	public byte[] asArray()
 	{
 		byte[] bytes = new byte[length()];
@@ -81,20 +72,6 @@
 		return bytes;
 	}
 
-	private ByteArrayBuffer duplicate(int access)
-	{
-		return new ByteArrayBuffer(asArray(), 0, length(), access);
-	}
-	
-	/*
-	 * @see org.eclipse.util.Buffer#asReadOnlyBuffer()
-	 */
-	public Buffer asReadOnlyBuffer()
-	{
-		if (isReadOnly()) return this;
-		return new View(this, markIndex(), getIndex(), putIndex(), READONLY);
-	}
-
 	public Buffer buffer()
 	{
 		return this;
@@ -292,12 +269,6 @@
 	public int poke(int index, Buffer src)
 	{
 		_hash=0;
-		/* 
-		if (isReadOnly()) 
-			throw new IllegalStateException(__READONLY);
-		if (index < 0) 
-			throw new IllegalArgumentException("index<0: " + index + "<0");
-		*/
 		
 		int length=src.length();
 		if (index + length > capacity())
@@ -339,12 +310,6 @@
 	public int poke(int index, byte[] b, int offset, int length)
 	{
 		_hash=0;
-		/*
-		if (isReadOnly()) 
-			throw new IllegalStateException(__READONLY);
-		if (index < 0) 
-			throw new IllegalArgumentException("index<0: " + index + "<0");
-		*/
 		if (index + length > capacity())
 		{
 			length=capacity()-index;
@@ -414,37 +379,17 @@
 
 	public void setGetIndex(int getIndex)
 	{
-		/* bounds checking
-		if (isImmutable()) 
-			throw new IllegalStateException(__IMMUTABLE);
-		if (getIndex < 0)
-			throw new IllegalArgumentException("getIndex<0: " + getIndex + "<0");
-		if (getIndex > putIndex())
-			throw new IllegalArgumentException("getIndex>putIndex: " + getIndex + ">" + putIndex());
-		 */
 		_get = getIndex;
 		_hash=0;
 	}
 
 	public void setMarkIndex(int index)
 	{
-		/*
-		if (index>=0 && isImmutable()) 
-			throw new IllegalStateException(__IMMUTABLE);
-		*/
 		_mark = index;
 	}
 
 	public void setPutIndex(int putIndex)
 	{
-		/* bounds checking
-		if (isImmutable()) 
-			throw new IllegalStateException(__IMMUTABLE);
-		if (putIndex > capacity())
-				throw new IllegalArgumentException("putIndex>capacity: " + putIndex + ">" + capacity());
-		if (getIndex() > putIndex)
-				throw new IllegalArgumentException("getIndex>putIndex: " + getIndex() + ">" + putIndex);
-		 */
 		_put = putIndex;
 		_hash=0;
 	}