Author: rdonkin
Date: Sun Jan 18 14:48:40 2009
New Revision: 735569
URL: http://svn.apache.org/viewvc?rev=735569&view=rev
Log:
Removed method used only for testing
Added:
james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/StringBuilderChannel.java
james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/StringBuilderChannel.java
Modified:
james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MessageResult.java
james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/ByteContent.java
james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/FullContent.java
james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/ResultHeader.java
james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/PartContentBuilderComplexMultipartTest.java
james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/PartContentBuilderMultipartAlternativeTest.java
james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/ByteContent.java
james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/FullContent.java
james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/Header.java
james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderComplexMultipartTest.java
james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderMultipartAlternativeTest.java
Modified:
james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MessageResult.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MessageResult.java?rev=735569&r1=735568&r2=735569&view=diff
==============================================================================
---
james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MessageResult.java
(original)
+++
james/protocols/imap/trunk/mailbox/src/main/java/org/apache/james/imap/mailbox/MessageResult.java
Sun Jan 18 14:48:40 2009
@@ -307,14 +307,6 @@
* out. This interface allows direct writing whilst exposing total size.
*/
public interface Content {
- /**
- * Writes content into the given buffer.
- *
- * @param buffer
- * <code>StringBuffer</code>, not null
- * @throws MessagingException
- */
- public void writeTo(StringBuffer buffer);
/**
* Writes content to the given channel.
Modified:
james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/ByteContent.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/ByteContent.java?rev=735569&r1=735568&r2=735569&view=diff
==============================================================================
---
james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/ByteContent.java
(original)
+++
james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/ByteContent.java
Sun Jan 18 14:48:40 2009
@@ -43,10 +43,6 @@
return size;
}
- public void writeTo(StringBuffer buffer) {
- ContentUtils.normalisedWriteTo(contents, buffer);
- }
-
public void writeTo(WritableByteChannel channel) throws IOException {
ByteBuffer buffer = ByteBuffer.wrap(contents);
while (channel.write(buffer) > 0) {
Modified:
james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/FullContent.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/FullContent.java?rev=735569&r1=735568&r2=735569&view=diff
==============================================================================
---
james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/FullContent.java
(original)
+++
james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/FullContent.java
Sun Jan 18 14:48:40 2009
@@ -58,21 +58,6 @@
return result;
}
- public void writeTo(StringBuffer buffer) {
- for (final Iterator it = headers.iterator(); it.hasNext();) {
- final MessageResult.Header header = (MessageResult.Header) it
- .next();
- if (header != null) {
- header.writeTo(buffer);
- }
- buffer.append('\r');
- buffer.append('\n');
- }
- buffer.append('\r');
- buffer.append('\n');
- ContentUtils.normalisedWriteTo(contents, buffer);
- }
-
public long size() {
return size;
}
Modified:
james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/ResultHeader.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/ResultHeader.java?rev=735569&r1=735568&r2=735569&view=diff
==============================================================================
---
james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/ResultHeader.java
(original)
+++
james/protocols/imap/trunk/store/src/main/java/org/apache/james/imap/store/ResultHeader.java
Sun Jan 18 14:48:40 2009
@@ -66,18 +66,6 @@
return size;
}
- public void writeTo(StringBuffer buffer) {
- // TODO: sort out encoding
- for (int i = 0; i < name.length(); i++) {
- buffer.append((char) (byte) name.charAt(i));
- }
- buffer.append(':');
- buffer.append(' ');
- for (int i = 0; i < value.length(); i++) {
- buffer.append((char) (byte) value.charAt(i));
- }
- }
-
public void writeTo(WritableByteChannel channel) throws IOException {
writeAll(channel, ResultUtils.US_ASCII.encode(name));
ByteBuffer buffer = ByteBuffer
Modified:
james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/PartContentBuilderComplexMultipartTest.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/PartContentBuilderComplexMultipartTest.java?rev=735569&r1=735568&r2=735569&view=diff
==============================================================================
---
james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/PartContentBuilderComplexMultipartTest.java
(original)
+++
james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/PartContentBuilderComplexMultipartTest.java
Sun Jan 18 14:48:40 2009
@@ -183,14 +183,14 @@
private String fullContent(int[] position) throws Exception {
to(position);
- StringBuffer buffer = new StringBuffer();
+ StringBuilderChannel buffer = new StringBuilderChannel();
builder.getFullContent().writeTo(buffer);
return buffer.toString();
}
private String bodyContent(int[] position) throws Exception {
to(position);
- StringBuffer buffer = new StringBuffer();
+ StringBuilderChannel buffer = new StringBuilderChannel();
builder.getMimeBodyContent().writeTo(buffer);
return buffer.toString();
}
Modified:
james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/PartContentBuilderMultipartAlternativeTest.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/PartContentBuilderMultipartAlternativeTest.java?rev=735569&r1=735568&r2=735569&view=diff
==============================================================================
---
james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/PartContentBuilderMultipartAlternativeTest.java
(original)
+++
james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/PartContentBuilderMultipartAlternativeTest.java
Sun Jan 18 14:48:40 2009
@@ -102,7 +102,7 @@
.encode(mail).array());
builder.parse(in);
builder.to(position);
- StringBuffer buffer = new StringBuffer();
+ StringBuilderChannel buffer = new StringBuilderChannel();
builder.getFullContent().writeTo(buffer);
return buffer.toString();
}
@@ -112,7 +112,7 @@
.encode(mail).array());
builder.parse(in);
builder.to(position);
- StringBuffer buffer = new StringBuffer();
+ StringBuilderChannel buffer = new StringBuilderChannel();
builder.getMimeBodyContent().writeTo(buffer);
return buffer.toString();
}
Added:
james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/StringBuilderChannel.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/StringBuilderChannel.java?rev=735569&view=auto
==============================================================================
---
james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/StringBuilderChannel.java
(added)
+++
james/protocols/imap/trunk/store/src/test/java/org/apache/james/imap/store/StringBuilderChannel.java
Sun Jan 18 14:48:40 2009
@@ -0,0 +1,51 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+package org.apache.james.imap.store;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.WritableByteChannel;
+import java.nio.charset.Charset;
+
+public class StringBuilderChannel implements WritableByteChannel {
+
+ private static final Charset ASCII = Charset.forName("US-ASCII");
+
+ public final StringBuilder builder = new StringBuilder(1024);
+
+ public boolean isClosed = false;
+
+ public int write(ByteBuffer src) throws IOException {
+ final int result = src.limit() - src.position();
+ builder.append(ASCII.decode(src));
+ return result;
+ }
+
+ public void close() throws IOException {
+ isClosed = true;
+ }
+
+ public boolean isOpen() {
+ return !isClosed;
+ }
+
+ public String toString() {
+ return builder.toString();
+ }
+}
Modified:
james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/ByteContent.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/ByteContent.java?rev=735569&r1=735568&r2=735569&view=diff
==============================================================================
---
james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/ByteContent.java
(original)
+++
james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/ByteContent.java
Sun Jan 18 14:48:40 2009
@@ -43,10 +43,6 @@
return size;
}
- public void writeTo(StringBuffer buffer) {
- MessageUtils.normalisedWriteTo(contents, buffer);
- }
-
public void writeTo(WritableByteChannel channel) throws IOException {
ByteBuffer buffer = ByteBuffer.wrap(contents);
while (channel.write(buffer) > 0) {
Modified:
james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/FullContent.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/FullContent.java?rev=735569&r1=735568&r2=735569&view=diff
==============================================================================
---
james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/FullContent.java
(original)
+++
james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/FullContent.java
Sun Jan 18 14:48:40 2009
@@ -58,21 +58,6 @@
return result;
}
- public void writeTo(StringBuffer buffer) {
- for (final Iterator it = headers.iterator(); it.hasNext();) {
- final MessageResult.Header header = (MessageResult.Header) it
- .next();
- if (header != null) {
- header.writeTo(buffer);
- }
- buffer.append('\r');
- buffer.append('\n');
- }
- buffer.append('\r');
- buffer.append('\n');
- MessageUtils.normalisedWriteTo(contents, buffer);
- }
-
public long size() {
return size;
}
Modified:
james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/Header.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/Header.java?rev=735569&r1=735568&r2=735569&view=diff
==============================================================================
---
james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/Header.java
(original)
+++
james/protocols/imap/trunk/torque/src/main/java/org/apache/james/mailboxmanager/torque/Header.java
Sun Jan 18 14:48:40 2009
@@ -66,18 +66,6 @@
return size;
}
- public void writeTo(StringBuffer buffer) {
- // TODO: sort out encoding
- for (int i = 0; i < name.length(); i++) {
- buffer.append((char) (byte) name.charAt(i));
- }
- buffer.append(':');
- buffer.append(' ');
- for (int i = 0; i < value.length(); i++) {
- buffer.append((char) (byte) value.charAt(i));
- }
- }
-
public void writeTo(WritableByteChannel channel) throws IOException {
writeAll(channel, MessageRowUtils.US_ASCII.encode(name));
ByteBuffer buffer = ByteBuffer
Modified:
james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderComplexMultipartTest.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderComplexMultipartTest.java?rev=735569&r1=735568&r2=735569&view=diff
==============================================================================
---
james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderComplexMultipartTest.java
(original)
+++
james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderComplexMultipartTest.java
Sun Jan 18 14:48:40 2009
@@ -181,14 +181,14 @@
private String fullContent(int[] position) throws Exception {
to(position);
- StringBuffer buffer = new StringBuffer();
+ StringBuilderChannel buffer = new StringBuilderChannel();
builder.getFullContent().writeTo(buffer);
return buffer.toString();
}
private String bodyContent(int[] position) throws Exception {
to(position);
- StringBuffer buffer = new StringBuffer();
+ StringBuilderChannel buffer = new StringBuilderChannel();
builder.getMimeBodyContent().writeTo(buffer);
return buffer.toString();
}
Modified:
james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderMultipartAlternativeTest.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderMultipartAlternativeTest.java?rev=735569&r1=735568&r2=735569&view=diff
==============================================================================
---
james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderMultipartAlternativeTest.java
(original)
+++
james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/PartContentBuilderMultipartAlternativeTest.java
Sun Jan 18 14:48:40 2009
@@ -24,6 +24,7 @@
import java.nio.charset.Charset;
import java.util.List;
+
import junit.framework.TestCase;
public class PartContentBuilderMultipartAlternativeTest extends TestCase {
@@ -99,7 +100,7 @@
.encode(mail).array());
builder.parse(in);
builder.to(position);
- StringBuffer buffer = new StringBuffer();
+ StringBuilderChannel buffer = new StringBuilderChannel();
builder.getFullContent().writeTo(buffer);
return buffer.toString();
}
@@ -109,7 +110,7 @@
.encode(mail).array());
builder.parse(in);
builder.to(position);
- StringBuffer buffer = new StringBuffer();
+ StringBuilderChannel buffer = new StringBuilderChannel();
builder.getMimeBodyContent().writeTo(buffer);
return buffer.toString();
}
Added:
james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/StringBuilderChannel.java
URL:
http://svn.apache.org/viewvc/james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/StringBuilderChannel.java?rev=735569&view=auto
==============================================================================
---
james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/StringBuilderChannel.java
(added)
+++
james/protocols/imap/trunk/torque/src/test/java/org/apache/james/mailboxmanager/torque/StringBuilderChannel.java
Sun Jan 18 14:48:40 2009
@@ -0,0 +1,51 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+package org.apache.james.mailboxmanager.torque;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.WritableByteChannel;
+import java.nio.charset.Charset;
+
+public class StringBuilderChannel implements WritableByteChannel {
+
+ private static final Charset ASCII = Charset.forName("US-ASCII");
+
+ public final StringBuilder builder = new StringBuilder(1024);
+
+ public boolean isClosed = false;
+
+ public int write(ByteBuffer src) throws IOException {
+ final int result = src.limit() - src.position();
+ builder.append(ASCII.decode(src));
+ return result;
+ }
+
+ public void close() throws IOException {
+ isClosed = true;
+ }
+
+ public boolean isOpen() {
+ return !isClosed;
+ }
+
+ public String toString() {
+ return builder.toString();
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]