changeset 1029:4e5e9e3c25b3

remove Buffer.equalsIgnoreCase()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Nov 2016 00:55:20 -0600
parents 2ea54e6117c3
children 80cad9086593
files src/org/eclipse/jetty/http/HttpParser.java src/org/eclipse/jetty/io/AbstractBuffer.java src/org/eclipse/jetty/io/Buffer.java src/org/eclipse/jetty/io/ByteArrayBuffer.java src/org/eclipse/jetty/io/View.java
diffstat 5 files changed, 29 insertions(+), 209 deletions(-) [+]
line wrap: on
line diff
diff -r 2ea54e6117c3 -r 4e5e9e3c25b3 src/org/eclipse/jetty/http/HttpParser.java
--- a/src/org/eclipse/jetty/http/HttpParser.java	Thu Nov 03 00:23:04 2016 -0600
+++ b/src/org/eclipse/jetty/http/HttpParser.java	Thu Nov 03 00:55:20 2016 -0600
@@ -210,7 +210,7 @@
 					{
 						if (_buffer.length()>0 && !_headResponse)
 						{
-							Buffer chunk=_buffer.get(_buffer.length());
+							Buffer chunk = _buffer.get(_buffer.length());
 							_contentPosition += chunk.length();
 							_contentView.update(chunk);
 							_handler.content(chunk); // May recurse here
@@ -1074,7 +1074,7 @@
 			throw e;
 		}
 
-		return _contentView.length()>0?_contentView:null;
+		return _contentView.length()>0 ? _contentView : null;
 	}
 
 	/* ------------------------------------------------------------ */
diff -r 2ea54e6117c3 -r 4e5e9e3c25b3 src/org/eclipse/jetty/io/AbstractBuffer.java
--- a/src/org/eclipse/jetty/io/AbstractBuffer.java	Thu Nov 03 00:23:04 2016 -0600
+++ b/src/org/eclipse/jetty/io/AbstractBuffer.java	Thu Nov 03 00:55:20 2016 -0600
@@ -162,58 +162,6 @@
 		return true;
 	}
 
-	public boolean equalsIgnoreCase(Buffer b)
-	{
-		if (b==this)
-			return true;
-		
-		// reject different lengths
-		if (b.length() != length()) return false;
-
-		// reject AbstractBuffer with different hash value
-		if (_hash != 0 && b instanceof AbstractBuffer)
-		{
-			AbstractBuffer ab = (AbstractBuffer) b;
-			if (ab._hash != 0 && _hash != ab._hash) return false;
-		}
-
-		// Nothing for it but to do the hard grind.
-		int get=getIndex();
-		int bi=b.putIndex();
-		
-		byte[] array = array();
-		byte[] barray= b.array();
-		if (array!=null && barray!=null)
-		{
-			for (int i = putIndex(); i-->get;)
-			{
-				byte b1 = array[i];
-				byte b2 = barray[--bi];
-				if (b1 != b2)
-				{
-					if ('a' <= b1 && b1 <= 'z') b1 = (byte) (b1 - 'a' + 'A');
-					if ('a' <= b2 && b2 <= 'z') b2 = (byte) (b2 - 'a' + 'A');
-					if (b1 != b2) return false;
-				}
-			}
-		}
-		else
-		{
-			for (int i = putIndex(); i-->get;)
-			{
-				byte b1 = peek(i);
-				byte b2 = b.peek(--bi);
-				if (b1 != b2)
-				{
-					if ('a' <= b1 && b1 <= 'z') b1 = (byte) (b1 - 'a' + 'A');
-					if ('a' <= b2 && b2 <= 'z') b2 = (byte) (b2 - 'a' + 'A');
-					if (b1 != b2) return false;
-				}
-			}
-		}
-		return true;
-	}
-
 	public byte get()
 	{
 		return peek(_get++);
diff -r 2ea54e6117c3 -r 4e5e9e3c25b3 src/org/eclipse/jetty/io/Buffer.java
--- a/src/org/eclipse/jetty/io/Buffer.java	Thu Nov 03 00:23:04 2016 -0600
+++ b/src/org/eclipse/jetty/io/Buffer.java	Thu Nov 03 00:55:20 2016 -0600
@@ -134,13 +134,6 @@
 	
 	/**
 	 * 
-	 * @return a <code>boolean</code> value true if case sensitive comparison on this buffer
-	 */
-	boolean equalsIgnoreCase(Buffer buffer);
-
-
-	/**
-	 * 
 	 * @return a <code>boolean</code> value true if the buffer is immutable and that neither
 	 * the buffer contents nor the indexes may be changed.
 	 */
diff -r 2ea54e6117c3 -r 4e5e9e3c25b3 src/org/eclipse/jetty/io/ByteArrayBuffer.java
--- a/src/org/eclipse/jetty/io/ByteArrayBuffer.java	Thu Nov 03 00:23:04 2016 -0600
+++ b/src/org/eclipse/jetty/io/ByteArrayBuffer.java	Thu Nov 03 00:55:20 2016 -0600
@@ -57,7 +57,7 @@
 		_access = access;
 	}
 
-	public ByteArrayBuffer(byte[] bytes, int index, int length, int access, boolean isVolatile)
+	private ByteArrayBuffer(byte[] bytes, int index, int length, int access, boolean isVolatile)
 	{
 		super(READWRITE, isVolatile);
 		_bytes = bytes;
@@ -81,42 +81,21 @@
 		_access=IMMUTABLE;
 		_string = value;
 	}
-	
-	public ByteArrayBuffer(String value,boolean immutable)
-	{
-		super(READWRITE,NON_VOLATILE);
-		_bytes = StringUtil.getBytes(value);
-		setGetIndex(0);
-		setPutIndex(_bytes.length);
-		if (immutable)
-		{
-			_access=IMMUTABLE;
-			_string = value;
-		}
-	}
 
-	public ByteArrayBuffer(String value,String encoding) throws UnsupportedEncodingException
-	{
-		super(READWRITE,NON_VOLATILE);
-		_bytes = value.getBytes(encoding);
-		setGetIndex(0);
-		setPutIndex(_bytes.length);
-		_access=IMMUTABLE;
-		_string = value;
-	}
-
-	public byte[] array()
+	@Override
+	public final byte[] array()
 	{
 		return _bytes;
 	}
 
-	public int capacity()
+	@Override
+	public final int capacity()
 	{
 		return _bytes.length;
 	}
 	
 	@Override
-	public void compact()
+	public final void compact()
 	{
 		if (isReadOnly()) 
 			throw new IllegalStateException(__READONLY);
@@ -136,7 +115,7 @@
 
 
 	@Override
-	public boolean equals(Object obj)
+	public final boolean equals(Object obj)
 	{
 		if (obj==this)
 			return true;
@@ -171,67 +150,14 @@
 		return true;
 	}
 
-
 	@Override
-	public boolean equalsIgnoreCase(Buffer b)
-	{
-		if (b==this)
-			return true;
-		
-		// reject different lengths
-		if (b==null || b.length() != length()) 
-			return false;
-
-		// reject AbstractBuffer with different hash value
-		if (_hash != 0 && b instanceof AbstractBuffer)
-		{
-			AbstractBuffer ab = (AbstractBuffer) b;
-			if (ab._hash != 0 && _hash != ab._hash) return false;
-		}
-
-		// Nothing for it but to do the hard grind.
-		int get=getIndex();
-		int bi=b.putIndex();
-		byte[] barray=b.array();
-		if (barray==null)
-		{
-			for (int i = putIndex(); i-->get;)
-			{
-				byte b1 = _bytes[i];
-				byte b2 = b.peek(--bi);
-				if (b1 != b2)
-				{
-					if ('a' <= b1 && b1 <= 'z') b1 = (byte) (b1 - 'a' + 'A');
-					if ('a' <= b2 && b2 <= 'z') b2 = (byte) (b2 - 'a' + 'A');
-					if (b1 != b2) return false;
-				}
-			}
-		}
-		else
-		{
-			for (int i = putIndex(); i-->get;)
-			{
-				byte b1 = _bytes[i];
-				byte b2 = barray[--bi];
-				if (b1 != b2)
-				{
-					if ('a' <= b1 && b1 <= 'z') b1 = (byte) (b1 - 'a' + 'A');
-					if ('a' <= b2 && b2 <= 'z') b2 = (byte) (b2 - 'a' + 'A');
-					if (b1 != b2) return false;
-				}
-			}
-		}
-		return true;
-	}
-
-	@Override
-	public byte get()
+	public final byte get()
 	{
 		return _bytes[_get++];
 	}
 
 	@Override
-	public int hashCode()
+	public final int hashCode()
 	{
 		if (_hash == 0 || _hashGet!=_get || _hashPut!=_put) 
 		{
@@ -252,12 +178,14 @@
 	}
 	
 	
-	public byte peek(int index)
+	@Override
+	public final byte peek(int index)
 	{
 		return _bytes[index];
 	}
 	
-	public int peek(int index, byte[] b, int offset, int length)
+	@Override
+	public final int peek(int index, byte[] b, int offset, int length)
 	{
 		int l = length;
 		if (index + l > capacity())
@@ -274,7 +202,8 @@
 		return l;
 	}
 
-	public void poke(int index, byte b)
+	@Override
+	public final void poke(int index, byte b)
 	{
 		/* 
 		if (isReadOnly()) 
@@ -289,7 +218,7 @@
 	}
 	
 	@Override
-	public int poke(int index, Buffer src)
+	public final int poke(int index, Buffer src)
 	{
 		_hash=0;
 		
@@ -325,7 +254,7 @@
 	
 
 	@Override
-	public int poke(int index, byte[] b, int offset, int length)
+	public final int poke(int index, byte[] b, int offset, int length)
 	{
 		_hash=0;
 		/*
@@ -349,7 +278,7 @@
 	}
 	
 	@Override
-	public int readFrom(InputStream in,int max) throws IOException
+	public final int readFrom(InputStream in,int max) throws IOException
 	{
 		if (max<0||max>space())
 			max=space();
@@ -377,7 +306,7 @@
 	}
 
 	@Override
-	public int space()
+	public final int space()
 	{
 		return _bytes.length - _put;
 	}
diff -r 2ea54e6117c3 -r 4e5e9e3c25b3 src/org/eclipse/jetty/io/View.java
--- a/src/org/eclipse/jetty/io/View.java	Thu Nov 03 00:23:04 2016 -0600
+++ b/src/org/eclipse/jetty/io/View.java	Thu Nov 03 00:55:20 2016 -0600
@@ -66,54 +66,33 @@
 	 */
 	public void update(Buffer buffer)
 	{
-		_access=READWRITE;
-		_buffer=buffer.buffer();
+		_access = READWRITE;
+		_buffer = buffer.buffer();
 		setGetIndex(0);
 		setPutIndex(buffer.putIndex());
 		setGetIndex(buffer.getIndex());
 		setMarkIndex(buffer.markIndex());
-		_access=buffer.isReadOnly()?READONLY:READWRITE;
+		_access = buffer.isReadOnly()?READONLY:READWRITE;
 	}
 
-	public void update(int get, int put)
-	{
-		int a=_access;
-		_access=READWRITE;
-		setGetIndex(0);
-		setPutIndex(put);
-		setGetIndex(get);
-		setMarkIndex(-1);
-		_access=a;
-	}
-
-	/**
-	 * @return The {@link Buffer#array()} from the underlying buffer.
-	 */
+	@Override
 	public byte[] array()
 	{
 		return _buffer.array();
 	}
 
-	/**
-	 * @return The {@link Buffer#buffer()} from the underlying buffer.
-	 */
 	@Override
 	public Buffer buffer()
 	{
 		return _buffer.buffer();
 	}
 
-	/**
-	 * @return The {@link Buffer#capacity} of the underlying buffer.
-	 */
+	@Override
 	public int capacity()
 	{
 		return _buffer.capacity();
 	}
 
-	/**
-	 *  
-	 */
 	@Override
 	public void clear()
 	{
@@ -123,9 +102,6 @@
 		setGetIndex(_buffer.getIndex());
 	}
 
-	/**
-	 *  
-	 */
 	@Override
 	public void compact()
 	{
@@ -143,74 +119,48 @@
 		return  this==obj ||((obj instanceof Buffer)&& obj.equals(this)) || super.equals(obj);
 	}
 
-	/**
-	 * @return Whether the underlying buffer is {@link Buffer#isReadOnly read only}
-	 */
 	@Override
 	public boolean isReadOnly()
 	{
 		return _buffer.isReadOnly();
 	}
 
-	/**
-	 * @return Whether the underlying buffer is {@link Buffer#isVolatile volatile}
-	 */
 	@Override
 	public boolean isVolatile()
 	{
 		return true;
 	}
 
-	/**
-	 * @return The result of calling {@link Buffer#peek(int)} on the underlying buffer
-	 */
+	@Override
 	public byte peek(int index)
 	{
 		return _buffer.peek(index);
 	}
 
-	/**
-	 * @return The result of calling {@link Buffer#peek(int, byte[], int, int)} on the underlying buffer
-	 */
+	@Override
 	public int peek(int index, byte[] b, int offset, int length)
 	{
 		return _buffer.peek(index,b,offset,length);
 	}
 
-	/**
-	 * @return The result of calling {@link Buffer#peek(int, int)} on the underlying buffer
-	 */
 	@Override
 	public Buffer peek(int index, int length)
 	{
 		return _buffer.peek(index, length);
 	}
 	
-	/**
-	 * @param index
-	 * @param src
-	 */
 	@Override
 	public int poke(int index, Buffer src)
 	{
 		return _buffer.poke(index,src); 
 	}
 
-	/**
-	 * @param index
-	 * @param b
-	 */
+	@Override
 	public void poke(int index, byte b)
 	{
 		_buffer.poke(index,b);
 	}
 
-	/**
-	 * @param index
-	 * @param b
-	 * @param offset
-	 * @param length
-	 */
 	@Override
 	public int poke(int index, byte[] b, int offset, int length)
 	{