james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1060898 [2/2] - in /james/mime4j/trunk: ./ benchmark/src/main/java/org/apache/james/mime4j/ dom/src/main/java/org/apache/james/mime4j/dom/ dom/src/main/java/org/apache/james/mime4j/field/ dom/src/main/java/org/apache/james/mime4j/field/add...
Date Wed, 19 Jan 2011 18:50:35 GMT
Modified: james/mime4j/trunk/dom/src/main/jjtree/org/apache/james/mime4j/field/address/AddressListParser.jjt
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/jjtree/org/apache/james/mime4j/field/address/AddressListParser.jjt?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/jjtree/org/apache/james/mime4j/field/address/AddressListParser.jjt
(original)
+++ james/mime4j/trunk/dom/src/main/jjtree/org/apache/james/mime4j/field/address/AddressListParser.jjt
Wed Jan 19 18:50:34 2011
@@ -32,7 +32,7 @@ options {
 	VISITOR=true;
 	MULTI=true;
 	NODE_SCOPE_HOOK=true;
-	NODE_EXTENDS="org.apache.james.mime4j.field.address.parser.BaseNode"; 
+	NODE_EXTENDS="org.apache.james.mime4j.field.address.BaseNode"; 
 	//DEBUG_PARSER=true;
 	//DEBUG_TOKEN_MANAGER=true;
 }
@@ -56,7 +56,7 @@ PARSER_BEGIN(AddressListParser)
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.mime4j.field.address.parser;
+package org.apache.james.mime4j.field.address;
 
 public class AddressListParser {
     public static void main(String args[]) throws ParseException {

Modified: james/mime4j/trunk/dom/src/main/jjtree/org/apache/james/mime4j/field/address/ParseException.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/jjtree/org/apache/james/mime4j/field/address/ParseException.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/jjtree/org/apache/james/mime4j/field/address/ParseException.java
(original)
+++ james/mime4j/trunk/dom/src/main/jjtree/org/apache/james/mime4j/field/address/ParseException.java
Wed Jan 19 18:50:34 2011
@@ -17,7 +17,7 @@
  * specific language governing permissions and limitations      *
  * under the License.                                           *
  ****************************************************************/
-package org.apache.james.mime4j.field.address.parser;
+package org.apache.james.mime4j.field.address;
 
 /**
  * This exception is thrown when parse errors are encountered.

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java Wed Jan
19 18:50:34 2011
@@ -25,6 +25,7 @@ import org.apache.james.mime4j.dom.Heade
 import org.apache.james.mime4j.field.DefaultFieldParser;
 import org.apache.james.mime4j.message.BodyFactory;
 import org.apache.james.mime4j.message.BodyPart;
+import org.apache.james.mime4j.message.HeaderImpl;
 
 import junit.framework.TestCase;
 
@@ -69,11 +70,11 @@ public class EntityTest extends TestCase
     }
 
     public void testGetDispositionType() throws Exception {
-        Entity entity = new BodyPart();
+        BodyPart entity = new BodyPart();
 
         assertNull(entity.getDispositionType());
 
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Content-Disposition: inline"));
         entity.setHeader(header);
 
@@ -81,7 +82,7 @@ public class EntityTest extends TestCase
     }
 
     public void testSetContentDispositionType() throws Exception {
-        Entity entity = new BodyPart();
+        BodyPart entity = new BodyPart();
 
         entity.setContentDisposition("attachment");
 
@@ -90,7 +91,7 @@ public class EntityTest extends TestCase
     }
 
     public void testSetContentDispositionTypeFilename() throws Exception {
-        Entity entity = new BodyPart();
+        BodyPart entity = new BodyPart();
 
         entity.setContentDisposition("attachment", "some file.dat");
 
@@ -99,11 +100,11 @@ public class EntityTest extends TestCase
     }
 
     public void testGetFilename() throws Exception {
-        Entity entity = new BodyPart();
+        BodyPart entity = new BodyPart();
 
         assertNull(entity.getFilename());
 
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Content-Disposition: attachment; "
                 + "filename=\"some file.dat\""));
         entity.setHeader(header);
@@ -112,7 +113,7 @@ public class EntityTest extends TestCase
     }
 
     public void testSetFilename() throws Exception {
-        Entity entity = new BodyPart();
+        BodyPart entity = new BodyPart();
 
         entity.setFilename("file name.ext");
 

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java
(original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java
Wed Jan 19 18:50:34 2011
@@ -35,7 +35,7 @@ import junit.framework.TestSuite;
 
 import org.apache.james.mime4j.codec.CodecUtil;
 import org.apache.james.mime4j.dom.Message;
-import org.apache.james.mime4j.message.MessageImpl;
+import org.apache.james.mime4j.message.MimeBuilder;
 import org.apache.james.mime4j.stream.MimeEntityConfig;
 
 /**
@@ -58,7 +58,7 @@ public class ExampleMessagesRoundtripTes
             config.setMalformedHeaderStartsBody(true);
         }
         config.setMaxLineLen(-1);
-        Message inputMessage = new MessageImpl(url.openStream(), config);
+        Message inputMessage = MimeBuilder.parse(url.openStream(), config);
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         inputMessage.writeTo(out);
         

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java Wed Jan
19 18:50:34 2011
@@ -25,6 +25,7 @@ import org.apache.commons.io.output.Byte
 import org.apache.james.mime4j.dom.Header;
 import org.apache.james.mime4j.dom.field.Field;
 import org.apache.james.mime4j.field.DefaultFieldParser;
+import org.apache.james.mime4j.message.HeaderImpl;
 import org.apache.james.mime4j.message.MessageWriter;
 import org.apache.james.mime4j.util.CharsetUtil;
 
@@ -35,7 +36,7 @@ public class HeaderTest extends TestCase
     public static final String TO = "To: anyuser <any@user>";
 
     public void testHeader() throws Exception {
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.addField(DefaultFieldParser.parse(SUBJECT));
         header.addField(DefaultFieldParser.parse(TO));
 
@@ -50,7 +51,7 @@ public class HeaderTest extends TestCase
 
     public void testWriteSpecialCharacters() throws Exception {
         String hello = SWISS_GERMAN_HELLO;
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.addField(DefaultFieldParser.parse("Hello: " + hello));
         
         Field field = header.getField("Hello");
@@ -68,7 +69,7 @@ public class HeaderTest extends TestCase
     }
 
     public void testRemoveFields() throws Exception {
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.addField(DefaultFieldParser.parse("Received: from foo by bar for james"));
         header.addField(DefaultFieldParser.parse("Content-type: text/plain; charset=US-ASCII"));
         header.addField(DefaultFieldParser.parse("ReCeIvEd: from bar by foo for james"));
@@ -87,7 +88,7 @@ public class HeaderTest extends TestCase
     }
 
     public void testRemoveNonExistantField() throws Exception {
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.addField(DefaultFieldParser.parse("Received: from foo by bar for james"));
         header.addField(DefaultFieldParser.parse("Content-type: text/plain; charset=US-ASCII"));
         header.addField(DefaultFieldParser.parse("ReCeIvEd: from bar by foo for james"));
@@ -100,7 +101,7 @@ public class HeaderTest extends TestCase
     }
 
     public void testSetField() throws Exception {
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.addField(DefaultFieldParser.parse("From: mime4j@james.apache.org"));
         header.addField(DefaultFieldParser.parse("Received: from foo by bar for james"));
         header.addField(DefaultFieldParser.parse("Content-type: text/plain; charset=US-ASCII"));
@@ -117,7 +118,7 @@ public class HeaderTest extends TestCase
     }
 
     public void testSetNonExistantField() throws Exception {
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.addField(DefaultFieldParser.parse("Received: from foo by bar for james"));
         header.addField(DefaultFieldParser.parse("Content-type: text/plain; charset=US-ASCII"));
         header.addField(DefaultFieldParser.parse("ReCeIvEd: from bar by foo for james"));

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java
(original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java
Wed Jan 19 18:50:34 2011
@@ -25,7 +25,7 @@ import junit.framework.TestCase;
 
 import org.apache.james.mime4j.ExampleMail;
 import org.apache.james.mime4j.dom.Multipart;
-import org.apache.james.mime4j.message.MessageImpl;
+import org.apache.james.mime4j.message.MimeBuilder;
 
 public class MessageCompleteMailTest extends TestCase {
 
@@ -40,22 +40,22 @@ public class MessageCompleteMailTest ext
     }
     
     public void testMultipartAlternative() throws Exception {
-        MessageImpl message = createMessage(ExampleMail.MIME_MULTIPART_ALTERNATIVE_BYTES);
+        Message message = createMessage(ExampleMail.MIME_MULTIPART_ALTERNATIVE_BYTES);
         assertTrue("Should be a multipart/alternative mail", message.isMultipart());
         Multipart part = (Multipart)message.getBody();
         assertEquals("alternative", part.getSubType());
     }    
     
     public void testMultipartMixed() throws Exception {
-        MessageImpl message = createMessage(ExampleMail.MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_BYTES);
+        Message message = createMessage(ExampleMail.MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_BYTES);
         assertTrue("Should be a multipart/mixed mail", message.isMultipart());
         Multipart part = (Multipart)message.getBody();
         assertEquals("mixed", part.getSubType());
     }
 
-    private MessageImpl createMessage(byte[] octets) throws Exception {
+    private Message createMessage(byte[] octets) throws Exception {
         ByteArrayInputStream in = new ByteArrayInputStream(octets);
-        MessageImpl message = new MessageImpl(in);
+        Message message = MimeBuilder.parse(in);
         return message;
     }
 }

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java
(original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java
Wed Jan 19 18:50:34 2011
@@ -28,7 +28,7 @@ import org.apache.james.mime4j.dom.Multi
 import org.apache.james.mime4j.dom.TextBody;
 import org.apache.james.mime4j.dom.field.ContentTypeField;
 import org.apache.james.mime4j.dom.field.FieldName;
-import org.apache.james.mime4j.message.MessageImpl;
+import org.apache.james.mime4j.message.MimeBuilder;
 import org.apache.james.mime4j.stream.MimeEntityConfig;
 
 public class MessageHeadlessParserTest extends TestCase {
@@ -44,7 +44,7 @@ public class MessageHeadlessParserTest e
 
 		MimeEntityConfig mimeEntityConfig = new MimeEntityConfig();
 		mimeEntityConfig.setMalformedHeaderStartsBody(true);
-		MessageImpl message = new MessageImpl(new ByteArrayInputStream(headlessContent
+		Message message = MimeBuilder.parse(new ByteArrayInputStream(headlessContent
 				.getBytes("UTF-8")), mimeEntityConfig);
 		assertEquals("text/plain", message.getMimeType());
 		assertEquals(1, message.getHeader().getFields().size());
@@ -62,7 +62,7 @@ public class MessageHeadlessParserTest e
 
 		MimeEntityConfig mimeEntityConfig = new MimeEntityConfig();
 		mimeEntityConfig.setMalformedHeaderStartsBody(true);
-		MessageImpl message = new MessageImpl(new ByteArrayInputStream(headlessContent
+		Message message = MimeBuilder.parse(new ByteArrayInputStream(headlessContent
 				.getBytes("UTF-8")), mimeEntityConfig);
 		assertEquals("text/plain", message.getMimeType());
 		assertEquals(0, message.getHeader().getFields().size());
@@ -89,7 +89,7 @@ public class MessageHeadlessParserTest e
 
 		MimeEntityConfig mimeEntityConfig = new MimeEntityConfig();
 		mimeEntityConfig.setHeadlessParsing(contentType);
-		MessageImpl message = new MessageImpl(new ByteArrayInputStream(headlessContent
+		Message message = MimeBuilder.parse(new ByteArrayInputStream(headlessContent
 				.getBytes("UTF-8")), mimeEntityConfig);
 		assertEquals("multipart/form-data", message.getMimeType());
 		assertEquals(1, message.getHeader().getFields().size());

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java
(original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java
Wed Jan 19 18:50:34 2011
@@ -43,6 +43,7 @@ import org.apache.james.mime4j.dom.TextB
 import org.apache.james.mime4j.dom.field.Field;
 import org.apache.james.mime4j.field.FieldsTest;
 import org.apache.james.mime4j.message.MessageImpl;
+import org.apache.james.mime4j.message.MimeBuilder;
 import org.apache.james.mime4j.stream.MimeEntityConfig;
 import org.apache.james.mime4j.util.CharsetUtil;
 
@@ -101,7 +102,7 @@ public class MessageParserTest extends T
             config.setMalformedHeaderStartsBody(true);
         }
         config.setMaxLineLen(-1);
-        MessageImpl m = new MessageImpl(url.openStream(), config);
+        Message m = MimeBuilder.parse(url.openStream(), config);
         
         String s = url.toString();
         String prefix = s.substring(0, s.lastIndexOf('.'));

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java Wed
Jan 19 18:50:34 2011
@@ -40,9 +40,11 @@ import org.apache.james.mime4j.dom.Singl
 import org.apache.james.mime4j.dom.address.Group;
 import org.apache.james.mime4j.dom.address.Mailbox;
 import org.apache.james.mime4j.field.DefaultFieldParser;
-import org.apache.james.mime4j.field.address.parser.AddressBuilder;
+import org.apache.james.mime4j.field.address.AddressBuilder;
 import org.apache.james.mime4j.message.BodyPart;
+import org.apache.james.mime4j.message.HeaderImpl;
 import org.apache.james.mime4j.message.MessageImpl;
+import org.apache.james.mime4j.message.MimeBuilder;
 import org.apache.james.mime4j.message.MultipartImpl;
 
 public class MessageTest extends TestCase {
@@ -54,11 +56,11 @@ public class MessageTest extends TestCas
 
     @Override
     public void setUp() throws Exception {
-        headerTextPlain = new Header();
-        headerMessageRFC822 = new Header();
-        headerEmpty = new Header();
-        headerMultipartMixed = new Header();
-        headerMultipartDigest = new Header();
+        headerTextPlain = new HeaderImpl();
+        headerMessageRFC822 = new HeaderImpl();
+        headerEmpty = new HeaderImpl();
+        headerMultipartMixed = new HeaderImpl();
+        headerMultipartDigest = new HeaderImpl();
         
         headerTextPlain.addField(
                 DefaultFieldParser.parse("Content-Type: text/plain"));
@@ -131,7 +133,7 @@ public class MessageTest extends TestCas
     public void testWriteTo() throws Exception {
         byte[] inputByte = getRawMessageAsByteArray();
 
-        Message m = new MessageImpl(new ByteArrayInputStream(inputByte));
+        Message m = MimeBuilder.parse(new ByteArrayInputStream(inputByte));
         ByteArrayOutputStream out = new ByteArrayOutputStream();
 
         m.writeTo(out);
@@ -153,7 +155,7 @@ public class MessageTest extends TestCas
 
         byte[] inputByte = getRawMessageAsByteArray();
 
-        MessageImpl m = new MessageImpl(new ByteArrayInputStream(inputByte));
+        Message m = MimeBuilder.parse(new ByteArrayInputStream(inputByte));
         m.getHeader().addField(DefaultFieldParser.parse(testheader));
 
         assertEquals("header added", m.getHeader().getField(headerName)
@@ -173,7 +175,7 @@ public class MessageTest extends TestCas
         assertNull(m.getMessageId());
 
         String id = "<msg17@localhost>";
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Message-ID: " + id));
         m.setHeader(header);
         assertEquals(id, m.getMessageId());
@@ -194,7 +196,7 @@ public class MessageTest extends TestCas
         assertNull(m.getSubject());
 
         String subject = "testing 1 2";
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Subject: " + subject));
         m.setHeader(header);
         assertEquals(subject, m.getSubject());
@@ -219,7 +221,7 @@ public class MessageTest extends TestCas
         MessageImpl m = new MessageImpl();
         assertNull(m.getDate());
 
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Date: Thu, 1 Jan 1970 05:30:00 +0530"));
         m.setHeader(header);
 
@@ -242,7 +244,7 @@ public class MessageTest extends TestCas
         MessageImpl m = new MessageImpl();
         assertNull(m.getSender());
 
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Sender: john.doe@example.net"));
         m.setHeader(header);
 
@@ -264,7 +266,7 @@ public class MessageTest extends TestCas
         MessageImpl m = new MessageImpl();
         assertNull(m.getFrom());
 
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("From: john.doe@example.net"));
         m.setHeader(header);
 
@@ -297,7 +299,7 @@ public class MessageTest extends TestCas
         MessageImpl m = new MessageImpl();
         assertNull(m.getTo());
 
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("To: john.doe@example.net"));
         m.setHeader(header);
 
@@ -335,7 +337,7 @@ public class MessageTest extends TestCas
         MessageImpl m = new MessageImpl();
         assertNull(m.getCc());
 
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Cc: john.doe@example.net"));
         m.setHeader(header);
 
@@ -373,7 +375,7 @@ public class MessageTest extends TestCas
         MessageImpl m = new MessageImpl();
         assertNull(m.getBcc());
 
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Bcc: john.doe@example.net"));
         m.setHeader(header);
 
@@ -411,7 +413,7 @@ public class MessageTest extends TestCas
         MessageImpl m = new MessageImpl();
         assertNull(m.getReplyTo());
 
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.setField(DefaultFieldParser.parse("Reply-To: john.doe@example.net"));
         m.setHeader(header);
 

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java
(original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java
Wed Jan 19 18:50:34 2011
@@ -23,7 +23,7 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 
 import org.apache.james.mime4j.ExampleMail;
-import org.apache.james.mime4j.message.MessageImpl;
+import org.apache.james.mime4j.message.MimeBuilder;
 
 import junit.framework.TestCase;
 
@@ -40,7 +40,7 @@ public class MessageWriteToTest extends 
     }
     
     public void testSimpleMail() throws Exception {
-        MessageImpl message = createMessage(ExampleMail.RFC822_SIMPLE_BYTES);
+        Message message = createMessage(ExampleMail.RFC822_SIMPLE_BYTES);
         assertFalse("Not multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         message.writeTo(out);
@@ -58,7 +58,7 @@ public class MessageWriteToTest extends 
     }
     
     public void testBinaryAttachment() throws Exception {
-        MessageImpl message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES);
+        Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES);
         assertTrue("Is multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         message.writeTo(out);
@@ -66,7 +66,7 @@ public class MessageWriteToTest extends 
     }
     
     public void testBinaryAttachmentNoPreamble() throws Exception {
-        MessageImpl message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_NOPREAMBLE_BYTES);
+        Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_NOPREAMBLE_BYTES);
         assertTrue("Is multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         message.writeTo(out);
@@ -74,16 +74,16 @@ public class MessageWriteToTest extends 
     }
     
     public void testBinaryAttachmentPreambleEpilogue() throws Exception {
-        MessageImpl message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_PREAMBLE_EPILOGUE_BYTES);
+        Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_PREAMBLE_EPILOGUE_BYTES);
         assertTrue("Is multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         message.writeTo(out);
         assertEquals(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_PREAMBLE_EPILOGUE_BYTES,
out.toByteArray());
     }
     
-    private MessageImpl createMessage(byte[] octets) throws Exception {
+    private Message createMessage(byte[] octets) throws Exception {
         ByteArrayInputStream in = new ByteArrayInputStream(octets);
-        MessageImpl message = new MessageImpl(in);
+        Message message = MimeBuilder.parse(in);
         return message;
     }
 }

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java
(original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java
Wed Jan 19 18:50:34 2011
@@ -28,6 +28,7 @@ import org.apache.james.mime4j.dom.Multi
 import org.apache.james.mime4j.field.DefaultFieldParser;
 import org.apache.james.mime4j.message.BodyFactory;
 import org.apache.james.mime4j.message.BodyPart;
+import org.apache.james.mime4j.message.HeaderImpl;
 import org.apache.james.mime4j.message.MessageImpl;
 import org.apache.james.mime4j.message.MessageWriter;
 import org.apache.james.mime4j.message.MultipartImpl;
@@ -38,7 +39,7 @@ public class MultipartFormTest extends T
         BodyFactory bodyFactory = new BodyFactory();
         
         MessageImpl message = new MessageImpl();
-        Header header = new Header();
+        Header header = new HeaderImpl();
         header.addField(
                 DefaultFieldParser.parse("Content-Type: multipart/form-data; boundary=foo"));
         message.setHeader(header);
@@ -46,17 +47,17 @@ public class MultipartFormTest extends T
         Multipart multipart = new MultipartImpl("alternative");
         multipart.setParent(message);
         BodyPart p1 = new BodyPart();
-        Header h1 = new Header();
+        Header h1 = new HeaderImpl();
         h1.addField(DefaultFieldParser.parse("Content-Type: text/plain"));
         p1.setHeader(h1);
         p1.setBody(bodyFactory.textBody("this stuff"));
         BodyPart p2 = new BodyPart();
-        Header h2 = new Header();
+        Header h2 = new HeaderImpl();
         h2.addField(DefaultFieldParser.parse("Content-Type: text/plain"));
         p2.setHeader(h2);
         p2.setBody(bodyFactory.textBody("that stuff"));
         BodyPart p3 = new BodyPart();
-        Header h3 = new Header();
+        Header h3 = new HeaderImpl();
         h3.addField(DefaultFieldParser.parse("Content-Type: text/plain"));
         p3.setHeader(h3);
         p3.setBody(bodyFactory.textBody("all kind of stuff"));

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/FieldsTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/FieldsTest.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/FieldsTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/FieldsTest.java Wed
Jan 19 18:50:34 2011
@@ -40,7 +40,7 @@ import org.apache.james.mime4j.dom.field
 import org.apache.james.mime4j.dom.field.MailboxField;
 import org.apache.james.mime4j.dom.field.MailboxListField;
 import org.apache.james.mime4j.field.Fields;
-import org.apache.james.mime4j.field.address.parser.AddressBuilder;
+import org.apache.james.mime4j.field.address.AddressBuilder;
 import org.apache.james.mime4j.util.ByteArrayBuffer;
 import org.apache.james.mime4j.util.ContentUtil;
 import org.apache.james.mime4j.util.MimeUtil;

Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/AddressTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/AddressTest.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/AddressTest.java
(original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/field/address/AddressTest.java
Wed Jan 19 18:50:34 2011
@@ -26,9 +26,7 @@ import org.apache.james.mime4j.dom.addre
 import org.apache.james.mime4j.dom.address.Group;
 import org.apache.james.mime4j.dom.address.Mailbox;
 import org.apache.james.mime4j.dom.address.MailboxList;
-import org.apache.james.mime4j.field.address.formatter.AddressFormatter;
-import org.apache.james.mime4j.field.address.parser.AddressBuilder;
-import org.apache.james.mime4j.field.address.parser.ParseException;
+import org.apache.james.mime4j.field.address.ParseException;
 
 import java.util.ArrayList;
 import java.util.Arrays;

Modified: james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/MultipartMessage.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/MultipartMessage.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/MultipartMessage.java
(original)
+++ james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/MultipartMessage.java
Wed Jan 19 18:50:34 2011
@@ -32,7 +32,7 @@ import javax.imageio.ImageIO;
 import org.apache.james.mime4j.dom.BinaryBody;
 import org.apache.james.mime4j.dom.Multipart;
 import org.apache.james.mime4j.dom.TextBody;
-import org.apache.james.mime4j.field.address.parser.AddressBuilder;
+import org.apache.james.mime4j.field.address.AddressBuilder;
 import org.apache.james.mime4j.message.BodyFactory;
 import org.apache.james.mime4j.message.BodyPart;
 import org.apache.james.mime4j.message.MessageImpl;

Modified: james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/TextPlainMessage.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/TextPlainMessage.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/TextPlainMessage.java
(original)
+++ james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/dom/TextPlainMessage.java
Wed Jan 19 18:50:34 2011
@@ -23,8 +23,8 @@ import java.io.IOException;
 import java.util.Date;
 
 import org.apache.james.mime4j.dom.TextBody;
-import org.apache.james.mime4j.field.address.parser.AddressBuilder;
-import org.apache.james.mime4j.field.address.parser.ParseException;
+import org.apache.james.mime4j.field.address.AddressBuilder;
+import org.apache.james.mime4j.field.address.ParseException;
 import org.apache.james.mime4j.message.BodyFactory;
 import org.apache.james.mime4j.message.MessageImpl;
 

Modified: james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java
(original)
+++ james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java
Wed Jan 19 18:50:34 2011
@@ -30,10 +30,11 @@ import org.apache.james.mime4j.dom.Messa
 import org.apache.james.mime4j.dom.Multipart;
 import org.apache.james.mime4j.dom.TextBody;
 import org.apache.james.mime4j.dom.field.ParseException;
-import org.apache.james.mime4j.field.address.parser.AddressBuilder;
+import org.apache.james.mime4j.field.address.AddressBuilder;
 import org.apache.james.mime4j.message.BodyFactory;
 import org.apache.james.mime4j.message.BodyPart;
 import org.apache.james.mime4j.message.MessageImpl;
+import org.apache.james.mime4j.message.MimeBuilder;
 import org.apache.james.mime4j.message.MultipartImpl;
 import org.apache.james.mime4j.storage.DefaultStorageProvider;
 import org.apache.james.mime4j.storage.StorageProvider;
@@ -90,7 +91,7 @@ public class TransformMessage {
     private static Message transform(Message original) throws IOException, ParseException
{
         // Create a copy of the template. The copy can be modified without
         // affecting the original.
-        MessageImpl message = new MessageImpl(original);
+        Message message = MimeBuilder.copy(original);
 
         // In this example we know we have a multipart message. Use
         // Message#isMultipart() if uncertain.
@@ -138,7 +139,7 @@ public class TransformMessage {
         BodyPart part3 = createRandomBinaryPart(300);
         multipart.addBodyPart(part3);
 
-        Message message = new MessageImpl();
+        MessageImpl message = new MessageImpl();
         message.setMultipart(multipart);
 
         message.setSubject("Template message");

Modified: james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/tree/MessageTree.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/tree/MessageTree.java?rev=1060898&r1=1060897&r2=1060898&view=diff
==============================================================================
--- james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/tree/MessageTree.java
(original)
+++ james/mime4j/trunk/examples/src/main/java/org/apache/james/mime4j/samples/tree/MessageTree.java
Wed Jan 19 18:50:34 2011
@@ -44,6 +44,7 @@ import org.apache.james.mime4j.dom.Binar
 import org.apache.james.mime4j.dom.Body;
 import org.apache.james.mime4j.dom.Entity;
 import org.apache.james.mime4j.dom.Header;
+import org.apache.james.mime4j.dom.Message;
 import org.apache.james.mime4j.dom.Multipart;
 import org.apache.james.mime4j.dom.TextBody;
 import org.apache.james.mime4j.dom.address.Mailbox;
@@ -53,13 +54,14 @@ import org.apache.james.mime4j.dom.field
 import org.apache.james.mime4j.dom.field.DateTimeField;
 import org.apache.james.mime4j.dom.field.Field;
 import org.apache.james.mime4j.dom.field.UnstructuredField;
-import org.apache.james.mime4j.field.address.formatter.AddressFormatter;
+import org.apache.james.mime4j.field.address.AddressFormatter;
 import org.apache.james.mime4j.message.BodyPart;
 import org.apache.james.mime4j.message.MessageImpl;
+import org.apache.james.mime4j.message.MimeBuilder;
 
 /**
  * Displays a parsed Message in a window. The window will be divided into
- * two panels. The left panel displays the Message tree. Clicking on a 
+ * two panels. The left panel displays the Message tree. Clicking on a
  * node in the tree shows information on that node in the right panel.
  *
  * Some of this code have been copied from the Java tutorial's JTree section.
@@ -72,36 +74,36 @@ public class MessageTree extends JPanel 
     private JTree tree;
 
     /**
-     * Wraps an Object and associates it with a text. All message parts 
+     * Wraps an Object and associates it with a text. All message parts
      * (headers, bodies, multiparts, body parts) will be wrapped in
      * ObjectWrapper instances before they are added to the JTree instance.
      */
     public static class ObjectWrapper {
         private String text = "";
         private Object object = null;
-        
+
         public ObjectWrapper(String text, Object object) {
             this.text = text;
             this.object = object;
         }
-        
+
         @Override
         public String toString() {
             return text;
         }
-        
+
         public Object getObject() {
             return object;
         }
     }
-    
+
     /**
-     * Creates a new <code>MessageTree</code> instance displaying the 
+     * Creates a new <code>MessageTree</code> instance displaying the
      * specified <code>Message</code>.
-     * 
+     *
      * @param message the message to display.
      */
-    public MessageTree(MessageImpl message) {
+    public MessageTree(Message message) {
         super(new GridLayout(1,0));
 
         DefaultMutableTreeNode root = createNode(message);
@@ -128,17 +130,17 @@ public class MessageTree extends JPanel 
         splitPane.setPreferredSize(new Dimension(750, 500));
 
         add(splitPane);
-        
+
         textView = new JTextArea();
         textView.setEditable(false);
         textView.setLineWrap(true);
         contentPane.add(textView);
     }
-    
+
     /**
      * Create a node given a Multipart body.
      * Add the Preamble, all Body parts and the Epilogue to the node.
-     * 
+     *
      * @param multipart the Multipart.
      * @return the root node of the tree.
      */
@@ -148,17 +150,17 @@ public class MessageTree extends JPanel 
 
         for (Field field : header.getFields()) {
             String name = field.getName();
-            
+
             node.add(new DefaultMutableTreeNode(new ObjectWrapper(name, field)));
-        }        
+        }
 
         return node;
     }
-    
+
     /**
      * Create a node given a Multipart body.
      * Add the Preamble, all Body parts and the Epilogue to the node.
-     * 
+     *
      * @param multipart the Multipart.
      * @return the root node of the tree.
      */
@@ -176,17 +178,17 @@ public class MessageTree extends JPanel 
 
         return node;
     }
-    
+
     /**
-     * Creates the tree nodes given a MIME entity (either a Message or 
+     * Creates the tree nodes given a MIME entity (either a Message or
      * a BodyPart).
-     * 
+     *
      * @param entity the entity.
-     * @return the root node of the tree displaying the specified entity and 
+     * @return the root node of the tree displaying the specified entity and
      *         its children.
      */
     private DefaultMutableTreeNode createNode(Entity entity) {
-        
+
         /*
          * Create the root node for the entity. It's either a
          * Message or a Body part.
@@ -202,22 +204,22 @@ public class MessageTree extends JPanel 
          * Add the node encapsulating the entity Header.
          */
         node.add(createNode(entity.getHeader()));
-        
+
         Body body = entity.getBody();
-        
+
         if (body instanceof Multipart) {
             /*
              * The body of the entity is a Multipart.
              */
-            
+
             node.add(createNode((Multipart) body));
         } else if (body instanceof MessageImpl) {
             /*
              * The body is another Message.
              */
-            
+
             node.add(createNode((MessageImpl) body));
-            
+
         } else {
             /*
              * Discrete Body (either of type TextBody or BinaryBody).
@@ -226,19 +228,19 @@ public class MessageTree extends JPanel 
             if (body instanceof BinaryBody) {
                 type = "Binary body";
             }
-            
+
             type += " (" + entity.getMimeType() + ")";
             node.add(new DefaultMutableTreeNode(new ObjectWrapper(type, body)));
-            
+
         }
-        
+
         return node;
     }
-    
+
     /**
      * Called whenever the selection changes in the JTree instance showing
      * the Message nodes.
-     * 
+     *
      * @param e the event.
      */
     public void valueChanged(TreeSelectionEvent e) {
@@ -246,15 +248,15 @@ public class MessageTree extends JPanel 
                 tree.getLastSelectedPathComponent();
 
         textView.setText("");
-        
+
         if (node == null) {
             return;
         }
-        
+
         Object o = ((ObjectWrapper) node.getUserObject()).getObject();
 
         if (node.isLeaf()) {
-            
+
             if (o instanceof TextBody){
                 /*
                  * A text body. Display its contents.
@@ -271,7 +273,7 @@ public class MessageTree extends JPanel 
                     ex.printStackTrace();
                 }
                 textView.setText(sb.toString());
-                
+
             } else if (o instanceof BinaryBody){
                 /*
                  * A binary body. Display its MIME type and length in bytes.
@@ -287,10 +289,10 @@ public class MessageTree extends JPanel 
                     ex.printStackTrace();
                 }
                 textView.setText("Binary body\n"
-                               + "MIME type: " 
-                                   + body.getParent().getMimeType() + "\n" 
+                               + "MIME type: "
+                                   + body.getParent().getMimeType() + "\n"
                                + "Size of decoded data: " + size + " bytes");
-                
+
             } else if (o instanceof ContentTypeField) {
                 /*
                  * Content-Type field.
@@ -303,7 +305,7 @@ public class MessageTree extends JPanel 
                     sb.append(name + " = " + params.get(name) + "\n");
                 }
                 textView.setText(sb.toString());
-                
+
             } else if (o instanceof AddressListField) {
                 /*
                  * An address field (From, To, Cc, etc)
@@ -316,31 +318,31 @@ public class MessageTree extends JPanel 
                     sb.append(AddressFormatter.format(mb, false) + "\n");
                 }
                 textView.setText(sb.toString());
-                
+
             } else if (o instanceof DateTimeField) {
                 Date date = ((DateTimeField) o).getDate();
-                textView.setText(date.toString());                
+                textView.setText(date.toString());
             } else if (o instanceof UnstructuredField){
-                textView.setText(((UnstructuredField) o).getValue());                
+                textView.setText(((UnstructuredField) o).getValue());
             } else if (o instanceof Field){
-                textView.setText(((Field) o).getBody());                
+                textView.setText(((Field) o).getBody());
             } else {
                 /*
-                 * The Object should be a Header or a String containing a 
+                 * The Object should be a Header or a String containing a
                  * Preamble or Epilogue.
                  */
-                textView.setText(o.toString());                
+                textView.setText(o.toString());
             }
-            
+
         }
     }
-    
+
     /**
      * Creates and displays the gui.
-     * 
+     *
      * @param message the Message to display in the tree.
      */
-    private static void createAndShowGUI(MessageImpl message) {
+    private static void createAndShowGUI(Message message) {
         /*
          * Create and set up the window.
          */
@@ -360,18 +362,18 @@ public class MessageTree extends JPanel 
         frame.pack();
         frame.setVisible(true);
     }
-    
+
     public static void main(String[] args) {
         try {
-            
-            final MessageImpl message = new MessageImpl(new FileInputStream(args[0]));
-            
+
+            final Message message = MimeBuilder.parse(new FileInputStream(args[0]));
+
             javax.swing.SwingUtilities.invokeLater(new Runnable() {
                 public void run() {
                     createAndShowGUI(message);
                 }
             });
-        
+
         } catch (ArrayIndexOutOfBoundsException e) {
             System.err.println("Wrong number of arguments.");
             System.err.println("Usage: org.mime4j.samples.tree.MessageTree"



Mime
View raw message