Return-Path: X-Original-To: apmail-james-mime4j-dev-archive@minotaur.apache.org Delivered-To: apmail-james-mime4j-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4258C9EB5 for ; Tue, 14 May 2013 13:30:27 +0000 (UTC) Received: (qmail 92537 invoked by uid 500); 14 May 2013 13:30:27 -0000 Delivered-To: apmail-james-mime4j-dev-archive@james.apache.org Received: (qmail 92192 invoked by uid 500); 14 May 2013 13:30:21 -0000 Mailing-List: contact mime4j-dev-help@james.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: mime4j-dev@james.apache.org Delivered-To: mailing list mime4j-dev@james.apache.org Received: (qmail 92118 invoked by uid 99); 14 May 2013 13:30:18 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 May 2013 13:30:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 14 May 2013 13:30:15 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 91079238897A; Tue, 14 May 2013 13:29:53 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1482328 - in /james/mime4j/trunk: core/src/main/java/org/apache/james/mime4j/io/ core/src/test/java/org/apache/james/mime4j/io/ dom/src/main/java/org/apache/james/mime4j/message/ dom/src/test/java/org/apache/james/mime4j/message/ Date: Tue, 14 May 2013 13:29:53 -0000 To: mime4j-dev@james.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130514132953.91079238897A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olegk Date: Tue May 14 13:29:53 2013 New Revision: 1482328 URL: http://svn.apache.org/r1482328 Log: Eliminated duplicate class in dom module Added: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/TextInputStreamTest.java (contents, props changed) - copied, changed from r1482294, james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/message/StringInputStreamTest.java Removed: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StringInputStream.java james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/message/StringInputStreamTest.java Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/TextInputStream.java james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StringBody.java Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/TextInputStream.java URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/TextInputStream.java?rev=1482328&r1=1482327&r2=1482328&view=diff ============================================================================== --- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/TextInputStream.java (original) +++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/io/TextInputStream.java Tue May 14 13:29:53 2013 @@ -38,6 +38,8 @@ class TextInputStream extends InputStrea private final CharBuffer cbuf; private final ByteBuffer bbuf; + private int mark = -1; + TextInputStream(final CharSequence s, final Charset charset, int bufferSize) { super(); this.encoder = charset.newEncoder() @@ -125,6 +127,24 @@ class TextInputStream extends InputStrea } @Override + public void mark(int readlimit) { + this.mark = this.cbuf.position(); + } + + @Override + public void reset() throws IOException { + if (this.mark != -1) { + this.cbuf.position(this.mark); + this.mark = -1; + } + } + + @Override + public boolean markSupported() { + return true; + } + + @Override public void close() throws IOException { } Copied: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/TextInputStreamTest.java (from r1482294, james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/message/StringInputStreamTest.java) URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/TextInputStreamTest.java?p2=james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/TextInputStreamTest.java&p1=james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/message/StringInputStreamTest.java&r1=1482294&r2=1482328&rev=1482328&view=diff ============================================================================== --- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/message/StringInputStreamTest.java (original) +++ james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/TextInputStreamTest.java Tue May 14 13:29:53 2013 @@ -17,7 +17,7 @@ * under the License. * ****************************************************************/ -package org.apache.james.mime4j.message; +package org.apache.james.mime4j.io; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; @@ -31,7 +31,7 @@ import org.apache.james.mime4j.util.Cont import org.junit.Assert; import org.junit.Test; -public class StringInputStreamTest { +public class TextInputStreamTest { private static final String SWISS_GERMAN_HELLO = "Gr\374ezi_z\344m\344"; private static final String RUSSIAN_HELLO = "\u0412\u0441\u0435\u043C_\u043F\u0440\u0438\u0432\u0435\u0442"; @@ -48,7 +48,7 @@ public class StringInputStreamTest { private static void singleByteReadTest(final String testString) throws IOException { byte[] bytes = ContentUtil.toByteArray(testString, Charsets.UTF_8); - InputStream in = new StringInputStream(testString, Charsets.UTF_8); + InputStream in = new TextInputStream(testString, Charsets.UTF_8, 1024); for (byte b : bytes) { int read = in.read(); assertTrue(read >= 0); @@ -62,7 +62,7 @@ public class StringInputStreamTest { private static void bufferedReadTest(final String testString) throws IOException { SecureRandom rnd = new SecureRandom(); byte[] expected = ContentUtil.toByteArray(testString, Charsets.UTF_8); - InputStream in = new StringInputStream(testString, Charsets.UTF_8); + InputStream in = new TextInputStream(testString, Charsets.UTF_8, 1024); byte[] buffer = new byte[128]; int offset = 0; while (true) { @@ -108,7 +108,7 @@ public class StringInputStreamTest { @Test public void testReadZero() throws Exception { - InputStream r = new StringInputStream("test", Charsets.UTF_8); + InputStream r = new TextInputStream("test", Charsets.UTF_8, 1024); byte[] bytes = new byte[30]; Assert.assertEquals(0, r.read(bytes, 0, 0)); r.close(); @@ -116,7 +116,7 @@ public class StringInputStreamTest { @Test public void testSkip() throws Exception { - InputStream r = new StringInputStream("test", Charsets.UTF_8); + InputStream r = new TextInputStream("test", Charsets.UTF_8, 1024); r.skip(1); r.skip(2); Assert.assertEquals('t', r.read()); @@ -127,7 +127,7 @@ public class StringInputStreamTest { @Test public void testMarkReset() throws Exception { - InputStream r = new StringInputStream("test", Charsets.UTF_8); + InputStream r = new TextInputStream("test", Charsets.UTF_8, 1024); r.skip(2); r.mark(0); Assert.assertEquals('s', r.read()); Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/TextInputStreamTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/TextInputStreamTest.java ------------------------------------------------------------------------------ svn:keywords = Date Revision Propchange: james/mime4j/trunk/core/src/test/java/org/apache/james/mime4j/io/TextInputStreamTest.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StringBody.java URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StringBody.java?rev=1482328&r1=1482327&r2=1482328&view=diff ============================================================================== --- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StringBody.java (original) +++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/StringBody.java Tue May 14 13:29:53 2013 @@ -28,6 +28,7 @@ import java.nio.charset.Charset; import org.apache.james.mime4j.Charsets; import org.apache.james.mime4j.dom.SingleBody; import org.apache.james.mime4j.dom.TextBody; +import org.apache.james.mime4j.io.InputStreams; class StringBody extends TextBody { @@ -52,8 +53,8 @@ class StringBody extends TextBody { @Override public InputStream getInputStream() throws IOException { - return new StringInputStream(this.content, - this.charset != null ? this.charset : Charsets.DEFAULT_CHARSET, 2048); + return InputStreams.create(this.content, + this.charset != null ? this.charset : Charsets.DEFAULT_CHARSET); } @Override