james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwiederk...@apache.org
Subject svn commit: r748587 - in /james/mime4j/trunk/src: main/java/org/apache/james/mime4j/util/ByteArrayBuffer.java test/java/org/apache/james/mime4j/util/TestByteArrayBuffer.java
Date Fri, 27 Feb 2009 16:53:07 GMT
Author: mwiederkehr
Date: Fri Feb 27 16:53:07 2009
New Revision: 748587

URL: http://svn.apache.org/viewvc?rev=748587&view=rev
Log:
removed ByteArrayBuffer.append(char[],int,int) because of naive character to byte conversion

Modified:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/ByteArrayBuffer.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/TestByteArrayBuffer.java

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/ByteArrayBuffer.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/ByteArrayBuffer.java?rev=748587&r1=748586&r2=748587&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/ByteArrayBuffer.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/ByteArrayBuffer.java Fri
Feb 27 16:53:07 2009
@@ -90,28 +90,6 @@
         this.len = newlen;
     }
 
-    public void append(final char[] b, int off, int len) {
-        if (b == null) {
-            return;
-        }
-        if ((off < 0) || (off > b.length) || (len < 0) ||
-                ((off + len) < 0) || ((off + len) > b.length)) {
-            throw new IndexOutOfBoundsException();
-        }
-        if (len == 0) {
-            return;
-        }
-        int oldlen = this.len;
-        int newlen = oldlen + len;
-        if (newlen > this.buffer.length) {
-            expand(newlen);
-        }
-        for (int i1 = off, i2 = oldlen; i2 < newlen; i1++, i2++) {
-            this.buffer[i2] = (byte) b[i1];
-        }
-        this.len = newlen;
-    }
-
     public void clear() {
         this.len = 0;
     }

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/TestByteArrayBuffer.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/TestByteArrayBuffer.java?rev=748587&r1=748586&r2=748587&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/TestByteArrayBuffer.java
(original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/util/TestByteArrayBuffer.java
Fri Feb 27 16:53:07 2009
@@ -166,66 +166,4 @@
         }
     }
     
-    public void testAppendCharArrayAsAscii() throws Exception {
-        String s1 = "stuff";
-        String s2 = " and more stuff";
-        char[] b1 = s1.toCharArray();
-        char[] b2 = s2.toCharArray();
-        
-        ByteArrayBuffer buffer = new ByteArrayBuffer(8);
-        buffer.append(b1, 0, b1.length);
-        buffer.append(b2, 0, b2.length);
-         
-        assertEquals(s1 + s2, new String(buffer.toByteArray(), "US-ASCII"));
-    }
-    
-    public void testAppendNullCharArray() throws Exception {
-        ByteArrayBuffer buffer = new ByteArrayBuffer(8);
-        buffer.append((char[])null, 0, 0);
-        assertEquals(0, buffer.length());
-    }
-
-    public void testAppendEmptyCharArray() throws Exception {
-        ByteArrayBuffer buffer = new ByteArrayBuffer(8);
-        buffer.append(new char[] {}, 0, 0);
-        assertEquals(0, buffer.length());
-    }
-
-    public void testInvalidAppendCharArrayAsAscii() throws Exception {
-        ByteArrayBuffer buffer = new ByteArrayBuffer(4);
-        buffer.append((char[])null, 0, 0);
-
-        char[] tmp = new char[] { '1', '2', '3', '4'};
-        try {
-            buffer.append(tmp, -1, 0);
-            fail("IndexOutOfBoundsException should have been thrown");
-        } catch (IndexOutOfBoundsException ex) {
-            // expected
-        }
-        try {
-            buffer.append(tmp, 0, -1);
-            fail("IndexOutOfBoundsException should have been thrown");
-        } catch (IndexOutOfBoundsException ex) {
-            // expected
-        }
-        try {
-            buffer.append(tmp, 0, 8);
-            fail("IndexOutOfBoundsException should have been thrown");
-        } catch (IndexOutOfBoundsException ex) {
-            // expected
-        }
-        try {
-            buffer.append(tmp, 10, Integer.MAX_VALUE);
-            fail("IndexOutOfBoundsException should have been thrown");
-        } catch (IndexOutOfBoundsException ex) {
-            // expected
-        }
-        try {
-            buffer.append(tmp, 2, 4);
-            fail("IndexOutOfBoundsException should have been thrown");
-        } catch (IndexOutOfBoundsException ex) {
-            // expected
-        }
-    }
-    
 }



Mime
View raw message