diff src/org/eclipse/jetty/io/ByteArrayBuffer.java @ 1029:4e5e9e3c25b3

remove Buffer.equalsIgnoreCase()
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 03 Nov 2016 00:55:20 -0600
parents 6647dbc8be71
children 80cad9086593
line wrap: on
line diff
--- 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;
 	}