james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r894888 - in /james/mime4j/branches/cycleclean: benchmark/src/main/java/org/apache/james/mime4j/ core/src/main/java/org/apache/james/mime4j/message/ core/src/main/java/org/apache/james/mime4j/message/impl/ core/src/test/java/org/apache/jame...
Date Thu, 31 Dec 2009 17:01:22 GMT
Author: bago
Date: Thu Dec 31 17:01:21 2009
New Revision: 894888

URL: http://svn.apache.org/viewvc?rev=894888&view=rev
Log:
Extrapolated abstract Message object from current Message implementation. Moved "Fields" depending method from Message (api) to impl.MessageImpl (impl), leaving protected abstract placeholder in the abstract Message (MIME4J-156)

Added:
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageImpl.java   (contents, props changed)
      - copied, changed from r894882, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/Message.java
Modified:
    james/mime4j/branches/cycleclean/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/Message.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/BodyCopier.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/BodyPart.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageBuilder.java
    james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MultipartImpl.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/CopyConstructorTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageCompleteMailTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageHeadlessParserTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageWriteToTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java
    james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/impl/SingleBodyCopyTest.java
    james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/dom/MultipartMessage.java
    james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/dom/TextPlainMessage.java
    james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java
    james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/tree/MessageTree.java

Modified: james/mime4j/branches/cycleclean/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java (original)
+++ james/mime4j/branches/cycleclean/benchmark/src/main/java/org/apache/james/mime4j/LongMultipartReadBench.java Thu Dec 31 17:01:21 2009
@@ -27,7 +27,7 @@
 import org.apache.james.mime4j.codec.CodecUtil;
 import org.apache.james.mime4j.descriptor.BodyDescriptor;
 import org.apache.james.mime4j.message.Header;
-import org.apache.james.mime4j.message.Message;
+import org.apache.james.mime4j.message.impl.MessageImpl;
 import org.apache.james.mime4j.message.impl.SimpleContentHandler;
 import org.apache.james.mime4j.parser.AbstractContentHandler;
 import org.apache.james.mime4j.parser.ContentHandler;
@@ -171,7 +171,7 @@
             DefaultStorageProvider.setInstance(new MemoryStorageProvider());
 
             for (int i = 0; i < repetitions; i++) {
-                new Message(new ByteArrayInputStream(content));
+                new MessageImpl(new ByteArrayInputStream(content));
             }
         }
     }

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/Message.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/Message.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/Message.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/Message.java Thu Dec 31 17:01:21 2009
@@ -20,25 +20,17 @@
 package org.apache.james.mime4j.message;
 
 import java.io.IOException;
-import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
-import java.util.Map;
 import java.util.TimeZone;
 
-import org.apache.james.mime4j.MimeException;
-import org.apache.james.mime4j.MimeIOException;
 import org.apache.james.mime4j.field.AddressListField;
-import org.apache.james.mime4j.field.ContentDispositionField;
-import org.apache.james.mime4j.field.ContentTransferEncodingField;
-import org.apache.james.mime4j.field.ContentTypeField;
 import org.apache.james.mime4j.field.DateTimeField;
 import org.apache.james.mime4j.field.Field;
 import org.apache.james.mime4j.field.FieldName;
-import org.apache.james.mime4j.field.Fields;
 import org.apache.james.mime4j.field.MailboxField;
 import org.apache.james.mime4j.field.MailboxListField;
 import org.apache.james.mime4j.field.UnstructuredField;
@@ -46,118 +38,8 @@
 import org.apache.james.mime4j.field.address.AddressList;
 import org.apache.james.mime4j.field.address.Mailbox;
 import org.apache.james.mime4j.field.address.MailboxList;
-import org.apache.james.mime4j.message.impl.BodyCopier;
-import org.apache.james.mime4j.message.impl.MessageBuilder;
-import org.apache.james.mime4j.parser.MimeEntityConfig;
-import org.apache.james.mime4j.parser.MimeStreamParser;
-import org.apache.james.mime4j.storage.DefaultStorageProvider;
-import org.apache.james.mime4j.storage.StorageProvider;
-import org.apache.james.mime4j.util.MimeUtil;
-
-/**
- * Represents a MIME message. The following code parses a stream into a
- * <code>Message</code> object.
- * 
- * <pre>
- * Message msg = new Message(new FileInputStream(&quot;mime.msg&quot;));
- * </pre>
- */
-public class Message extends Entity implements Body {
-
-    /**
-     * Creates a new empty <code>Message</code>.
-     */
-    public Message() {
-    }
-
-    /**
-     * Creates a new <code>Message</code> from the specified
-     * <code>Message</code>. The <code>Message</code> instance is
-     * initialized with copies of header and body of the specified
-     * <code>Message</code>. The parent entity of the new message is
-     * <code>null</code>.
-     * 
-     * @param other
-     *            message to copy.
-     * @throws UnsupportedOperationException
-     *             if <code>other</code> contains a {@link SingleBody} that
-     *             does not support the {@link SingleBody#copy() copy()}
-     *             operation.
-     * @throws IllegalArgumentException
-     *             if <code>other</code> contains a <code>Body</code> that
-     *             is neither a {@link Message}, {@link Multipart} or
-     *             {@link SingleBody}.
-     */
-    public Message(Message other) {
-        if (other.getHeader() != null) {
-            setHeader(new Header(other.getHeader()));
-        }
-
-        if (other.getBody() != null) {
-            Body bodyCopy = BodyCopier.copy(other.getBody());
-            setBody(bodyCopy);
-        }
-    }
-
-    /**
-     * Parses the specified MIME message stream into a <code>Message</code>
-     * instance.
-     * 
-     * @param is
-     *            the stream to parse.
-     * @throws IOException
-     *             on I/O errors.
-     * @throws MimeIOException
-     *             on MIME protocol violations.
-     */
-    public Message(InputStream is) throws IOException, MimeIOException {
-        this(is, null, DefaultStorageProvider.getInstance());
-    }
-
-    /**
-     * Parses the specified MIME message stream into a <code>Message</code>
-     * instance using given {@link MimeEntityConfig}.
-     * 
-     * @param is
-     *            the stream to parse.
-     * @throws IOException
-     *             on I/O errors.
-     * @throws MimeIOException
-     *             on MIME protocol violations.
-     */
-    public Message(InputStream is, MimeEntityConfig config) throws IOException,
-            MimeIOException {
-        this(is, config, DefaultStorageProvider.getInstance());
-    }
 
-    /**
-     * Parses the specified MIME message stream into a <code>Message</code>
-     * instance using given {@link MimeEntityConfig} and {@link StorageProvider}.
-     * 
-     * @param is
-     *            the stream to parse.
-     * @param config
-     *            {@link MimeEntityConfig} to use.
-     * @param storageProvider
-     *            {@link StorageProvider} to use for storing text and binary
-     *            message bodies.
-     * @throws IOException
-     *             on I/O errors.
-     * @throws MimeIOException
-     *             on MIME protocol violations.
-     */
-    public Message(InputStream is, MimeEntityConfig config,
-            StorageProvider storageProvider) throws IOException,
-            MimeIOException {
-        try {
-            MimeStreamParser parser = new MimeStreamParser(config);
-            parser.setContentDecoding(true);
-            parser.setContentHandler(new MessageBuilder(this, storageProvider));
-            parser.parse(is);
-        } catch (MimeException e) {
-            throw new MimeIOException(e);
-        }
-    }
+public abstract class Message extends Entity implements Body {
 
     /**
      * Write the content to the given output stream using the
@@ -169,9 +51,7 @@
      *             in case of an I/O error
      * @see MessageWriter
      */
-    public void writeTo(OutputStream out) throws IOException {
-        MessageWriter.DEFAULT.writeEntity(this, out);
-    }
+    public abstract void writeTo(OutputStream out) throws IOException;
 
     /**
      * Returns the value of the <i>Message-ID</i> header field of this message
@@ -202,6 +82,8 @@
         header.setField(newMessageId(hostname));
     }
 
+    protected abstract Field newMessageId(String hostname);
+
     /**
      * Returns the (decoded) value of the <i>Subject</i> header field of this
      * message or <code>null</code> if it is not present.
@@ -616,57 +498,15 @@
         }
     }
 
-	@Override
-	protected String newUniqueBoundary() {
-		return MimeUtil.createUniqueBoundary();
-	}
-
-	protected UnstructuredField newMessageId(String hostname) {
-		return Fields.messageId(hostname);
-	}
-
-	protected DateTimeField newDate(Date date, TimeZone zone) {
-		return Fields.date(FieldName.DATE, date, zone);
-	}
+    protected abstract AddressListField newAddressList(String fieldName, Collection<Address> addresses);
 
-	protected MailboxField newMailbox(String fieldName, Mailbox mailbox) {
-		return Fields.mailbox(fieldName, mailbox);
-	}
+    protected abstract UnstructuredField newSubject(String subject);
 
-	protected MailboxListField newMailboxList(String fieldName,
-			Collection<Mailbox> mailboxes) {
-		return Fields.mailboxList(fieldName, mailboxes);
-	}
+    protected abstract DateTimeField newDate(Date date, TimeZone zone);
 
-	private AddressListField newAddressList(String fieldName,
-			Collection<Address> addresses) {
-		return Fields.addressList(fieldName, addresses);
-	}
+    protected abstract MailboxField newMailbox(String fieldName, Mailbox mailbox);
 
-	protected UnstructuredField newSubject(String subject) {
-		return Fields.subject(subject);
-	}
-
-    protected ContentDispositionField newContentDisposition(
-            String dispositionType, String filename, long size,
-            Date creationDate, Date modificationDate, Date readDate) {
-        return Fields.contentDisposition(dispositionType, filename, size,
-                creationDate, modificationDate, readDate);
-    }
-
-    protected ContentDispositionField newContentDisposition(
-            String dispositionType, Map<String, String> parameters) {
-        return Fields.contentDisposition(dispositionType, parameters);
-    }
-
-    protected ContentTypeField newContentType(String mimeType,
-            Map<String, String> parameters) {
-        return Fields.contentType(mimeType, parameters);
-    }
-
-    protected ContentTransferEncodingField newContentTransferEncoding(
-            String contentTransferEncoding) {
-        return Fields.contentTransferEncoding(contentTransferEncoding);
-    }
+    protected abstract MailboxListField newMailboxList(String fieldName, Collection<Mailbox> mailboxes);
 
-}
+    
+}
\ No newline at end of file

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/BodyCopier.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/BodyCopier.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/BodyCopier.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/BodyCopier.java Thu Dec 31 17:01:21 2009
@@ -52,7 +52,7 @@
      * @throws IllegalArgumentException
      *             if <code>body</code> is <code>null</code> or
      *             <code>body</code> is a <code>Body</code> that is neither
-     *             a {@link Message}, {@link Multipart} or {@link SingleBody}
+     *             a {@link MessageImpl}, {@link Multipart} or {@link SingleBody}
      *             (or contains such a <code>Body</code>).
      */
     public static Body copy(Body body) {
@@ -60,7 +60,7 @@
             throw new IllegalArgumentException("Body is null");
 
         if (body instanceof Message)
-            return new Message((Message) body);
+            return new MessageImpl((Message) body);
 
         if (body instanceof Multipart)
             return new MultipartImpl((Multipart) body);

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/BodyPart.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/BodyPart.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/BodyPart.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/BodyPart.java Thu Dec 31 17:01:21 2009
@@ -29,7 +29,6 @@
 import org.apache.james.mime4j.message.Body;
 import org.apache.james.mime4j.message.Entity;
 import org.apache.james.mime4j.message.Header;
-import org.apache.james.mime4j.message.Message;
 import org.apache.james.mime4j.message.Multipart;
 import org.apache.james.mime4j.message.SingleBody;
 import org.apache.james.mime4j.util.MimeUtil;

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageBuilder.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageBuilder.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageBuilder.java Thu Dec 31 17:01:21 2009
@@ -75,7 +75,7 @@
             stack.push(this.entity);
         } else {
             expect(Entity.class);
-            Message m = new Message();
+            Message m = new MessageImpl();
             ((Entity) stack.peek()).setBody(m);
             stack.push(m);
         }

Copied: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageImpl.java (from r894882, james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/Message.java)
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageImpl.java?p2=james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageImpl.java&p1=james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/Message.java&r1=894882&r2=894888&rev=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/Message.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageImpl.java Thu Dec 31 17:01:21 2009
@@ -17,14 +17,12 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mime4j.message;
+package org.apache.james.mime4j.message.impl;
 
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
-import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Date;
 import java.util.Map;
 import java.util.TimeZone;
@@ -36,18 +34,19 @@
 import org.apache.james.mime4j.field.ContentTransferEncodingField;
 import org.apache.james.mime4j.field.ContentTypeField;
 import org.apache.james.mime4j.field.DateTimeField;
-import org.apache.james.mime4j.field.Field;
 import org.apache.james.mime4j.field.FieldName;
 import org.apache.james.mime4j.field.Fields;
 import org.apache.james.mime4j.field.MailboxField;
 import org.apache.james.mime4j.field.MailboxListField;
 import org.apache.james.mime4j.field.UnstructuredField;
 import org.apache.james.mime4j.field.address.Address;
-import org.apache.james.mime4j.field.address.AddressList;
 import org.apache.james.mime4j.field.address.Mailbox;
-import org.apache.james.mime4j.field.address.MailboxList;
-import org.apache.james.mime4j.message.impl.BodyCopier;
-import org.apache.james.mime4j.message.impl.MessageBuilder;
+import org.apache.james.mime4j.message.Body;
+import org.apache.james.mime4j.message.Header;
+import org.apache.james.mime4j.message.Message;
+import org.apache.james.mime4j.message.MessageWriter;
+import org.apache.james.mime4j.message.Multipart;
+import org.apache.james.mime4j.message.SingleBody;
 import org.apache.james.mime4j.parser.MimeEntityConfig;
 import org.apache.james.mime4j.parser.MimeStreamParser;
 import org.apache.james.mime4j.storage.DefaultStorageProvider;
@@ -62,12 +61,12 @@
  * Message msg = new Message(new FileInputStream(&quot;mime.msg&quot;));
  * </pre>
  */
-public class Message extends Entity implements Body {
+public class MessageImpl extends Message {
 
     /**
      * Creates a new empty <code>Message</code>.
      */
-    public Message() {
+    public MessageImpl() {
     }
 
     /**
@@ -85,10 +84,10 @@
      *             operation.
      * @throws IllegalArgumentException
      *             if <code>other</code> contains a <code>Body</code> that
-     *             is neither a {@link Message}, {@link Multipart} or
+     *             is neither a {@link MessageImpl}, {@link Multipart} or
      *             {@link SingleBody}.
      */
-    public Message(Message other) {
+    public MessageImpl(Message other) {
         if (other.getHeader() != null) {
             setHeader(new Header(other.getHeader()));
         }
@@ -110,7 +109,7 @@
      * @throws MimeIOException
      *             on MIME protocol violations.
      */
-    public Message(InputStream is) throws IOException, MimeIOException {
+    public MessageImpl(InputStream is) throws IOException, MimeIOException {
         this(is, null, DefaultStorageProvider.getInstance());
     }
 
@@ -125,7 +124,7 @@
      * @throws MimeIOException
      *             on MIME protocol violations.
      */
-    public Message(InputStream is, MimeEntityConfig config) throws IOException,
+    public MessageImpl(InputStream is, MimeEntityConfig config) throws IOException,
             MimeIOException {
         this(is, config, DefaultStorageProvider.getInstance());
     }
@@ -146,7 +145,7 @@
      * @throws MimeIOException
      *             on MIME protocol violations.
      */
-    public Message(InputStream is, MimeEntityConfig config,
+    public MessageImpl(InputStream is, MimeEntityConfig config,
             StorageProvider storageProvider) throws IOException,
             MimeIOException {
         try {
@@ -160,462 +159,12 @@
     }
 
     /**
-     * Write the content to the given output stream using the
-     * {@link MessageWriter#DEFAULT default} message writer.
-     * 
-     * @param out
-     *            the output stream to write to.
-     * @throws IOException
-     *             in case of an I/O error
-     * @see MessageWriter
+     * @see org.apache.james.mime4j.message.impl.Message#writeTo(java.io.OutputStream)
      */
     public void writeTo(OutputStream out) throws IOException {
         MessageWriter.DEFAULT.writeEntity(this, out);
     }
 
-    /**
-     * Returns the value of the <i>Message-ID</i> header field of this message
-     * or <code>null</code> if it is not present.
-     * 
-     * @return the identifier of this message.
-     */
-    public String getMessageId() {
-        Field field = obtainField(FieldName.MESSAGE_ID);
-        if (field == null)
-            return null;
-
-        return field.getBody();
-    }
-
-    /**
-     * Creates and sets a new <i>Message-ID</i> header field for this message.
-     * A <code>Header</code> is created if this message does not already have
-     * one.
-     * 
-     * @param hostname
-     *            host name to be included in the identifier or
-     *            <code>null</code> if no host name should be included.
-     */
-    public void createMessageId(String hostname) {
-        Header header = obtainHeader();
-
-        header.setField(newMessageId(hostname));
-    }
-
-    /**
-     * Returns the (decoded) value of the <i>Subject</i> header field of this
-     * message or <code>null</code> if it is not present.
-     * 
-     * @return the subject of this message.
-     */
-    public String getSubject() {
-        UnstructuredField field = obtainField(FieldName.SUBJECT);
-        if (field == null)
-            return null;
-
-        return field.getValue();
-    }
-
-    /**
-     * Sets the <i>Subject</i> header field for this message. The specified
-     * string may contain non-ASCII characters, in which case it gets encoded as
-     * an 'encoded-word' automatically. A <code>Header</code> is created if
-     * this message does not already have one.
-     * 
-     * @param subject
-     *            subject to set or <code>null</code> to remove the subject
-     *            header field.
-     */
-    public void setSubject(String subject) {
-        Header header = obtainHeader();
-
-        if (subject == null) {
-            header.removeFields(FieldName.SUBJECT);
-        } else {
-            header.setField(newSubject(subject));
-        }
-    }
-
-    /**
-     * Returns the value of the <i>Date</i> header field of this message as
-     * <code>Date</code> object or <code>null</code> if it is not present.
-     * 
-     * @return the date of this message.
-     */
-    public Date getDate() {
-        DateTimeField dateField = obtainField(FieldName.DATE);
-        if (dateField == null)
-            return null;
-
-        return dateField.getDate();
-    }
-
-    /**
-     * Sets the <i>Date</i> header field for this message. This method uses the
-     * default <code>TimeZone</code> of this host to encode the specified
-     * <code>Date</code> object into a string.
-     * 
-     * @param date
-     *            date to set or <code>null</code> to remove the date header
-     *            field.
-     */
-    public void setDate(Date date) {
-        setDate(date, null);
-    }
-
-    /**
-     * Sets the <i>Date</i> header field for this message. The specified
-     * <code>TimeZone</code> is used to encode the specified <code>Date</code>
-     * object into a string.
-     * 
-     * @param date
-     *            date to set or <code>null</code> to remove the date header
-     *            field.
-     * @param zone
-     *            a time zone.
-     */
-    public void setDate(Date date, TimeZone zone) {
-        Header header = obtainHeader();
-
-        if (date == null) {
-            header.removeFields(FieldName.DATE);
-        } else {
-            header.setField(newDate(date, zone));
-        }
-    }
-
-    /**
-     * Returns the value of the <i>Sender</i> header field of this message as
-     * <code>Mailbox</code> object or <code>null</code> if it is not
-     * present.
-     * 
-     * @return the sender of this message.
-     */
-    public Mailbox getSender() {
-        return getMailbox(FieldName.SENDER);
-    }
-
-    /**
-     * Sets the <i>Sender</i> header field of this message to the specified
-     * mailbox address.
-     * 
-     * @param sender
-     *            address to set or <code>null</code> to remove the header
-     *            field.
-     */
-    public void setSender(Mailbox sender) {
-        setMailbox(FieldName.SENDER, sender);
-    }
-
-    /**
-     * Returns the value of the <i>From</i> header field of this message as
-     * <code>MailboxList</code> object or <code>null</code> if it is not
-     * present.
-     * 
-     * @return value of the from field of this message.
-     */
-    public MailboxList getFrom() {
-        return getMailboxList(FieldName.FROM);
-    }
-
-    /**
-     * Sets the <i>From</i> header field of this message to the specified
-     * mailbox address.
-     * 
-     * @param from
-     *            address to set or <code>null</code> to remove the header
-     *            field.
-     */
-    public void setFrom(Mailbox from) {
-        setMailboxList(FieldName.FROM, from);
-    }
-
-    /**
-     * Sets the <i>From</i> header field of this message to the specified
-     * mailbox addresses.
-     * 
-     * @param from
-     *            addresses to set or <code>null</code> or no arguments to
-     *            remove the header field.
-     */
-    public void setFrom(Mailbox... from) {
-        setMailboxList(FieldName.FROM, from);
-    }
-
-    /**
-     * Sets the <i>From</i> header field of this message to the specified
-     * mailbox addresses.
-     * 
-     * @param from
-     *            addresses to set or <code>null</code> or an empty collection
-     *            to remove the header field.
-     */
-    public void setFrom(Collection<Mailbox> from) {
-        setMailboxList(FieldName.FROM, from);
-    }
-
-    /**
-     * Returns the value of the <i>To</i> header field of this message as
-     * <code>AddressList</code> object or <code>null</code> if it is not
-     * present.
-     * 
-     * @return value of the to field of this message.
-     */
-    public AddressList getTo() {
-        return getAddressList(FieldName.TO);
-    }
-
-    /**
-     * Sets the <i>To</i> header field of this message to the specified
-     * address.
-     * 
-     * @param to
-     *            address to set or <code>null</code> to remove the header
-     *            field.
-     */
-    public void setTo(Address to) {
-        setAddressList(FieldName.TO, to);
-    }
-
-    /**
-     * Sets the <i>To</i> header field of this message to the specified
-     * addresses.
-     * 
-     * @param to
-     *            addresses to set or <code>null</code> or no arguments to
-     *            remove the header field.
-     */
-    public void setTo(Address... to) {
-        setAddressList(FieldName.TO, to);
-    }
-
-    /**
-     * Sets the <i>To</i> header field of this message to the specified
-     * addresses.
-     * 
-     * @param to
-     *            addresses to set or <code>null</code> or an empty collection
-     *            to remove the header field.
-     */
-    public void setTo(Collection<Address> to) {
-        setAddressList(FieldName.TO, to);
-    }
-
-    /**
-     * Returns the value of the <i>Cc</i> header field of this message as
-     * <code>AddressList</code> object or <code>null</code> if it is not
-     * present.
-     * 
-     * @return value of the cc field of this message.
-     */
-    public AddressList getCc() {
-        return getAddressList(FieldName.CC);
-    }
-
-    /**
-     * Sets the <i>Cc</i> header field of this message to the specified
-     * address.
-     * 
-     * @param cc
-     *            address to set or <code>null</code> to remove the header
-     *            field.
-     */
-    public void setCc(Address cc) {
-        setAddressList(FieldName.CC, cc);
-    }
-
-    /**
-     * Sets the <i>Cc</i> header field of this message to the specified
-     * addresses.
-     * 
-     * @param cc
-     *            addresses to set or <code>null</code> or no arguments to
-     *            remove the header field.
-     */
-    public void setCc(Address... cc) {
-        setAddressList(FieldName.CC, cc);
-    }
-
-    /**
-     * Sets the <i>Cc</i> header field of this message to the specified
-     * addresses.
-     * 
-     * @param cc
-     *            addresses to set or <code>null</code> or an empty collection
-     *            to remove the header field.
-     */
-    public void setCc(Collection<Address> cc) {
-        setAddressList(FieldName.CC, cc);
-    }
-
-    /**
-     * Returns the value of the <i>Bcc</i> header field of this message as
-     * <code>AddressList</code> object or <code>null</code> if it is not
-     * present.
-     * 
-     * @return value of the bcc field of this message.
-     */
-    public AddressList getBcc() {
-        return getAddressList(FieldName.BCC);
-    }
-
-    /**
-     * Sets the <i>Bcc</i> header field of this message to the specified
-     * address.
-     * 
-     * @param bcc
-     *            address to set or <code>null</code> to remove the header
-     *            field.
-     */
-    public void setBcc(Address bcc) {
-        setAddressList(FieldName.BCC, bcc);
-    }
-
-    /**
-     * Sets the <i>Bcc</i> header field of this message to the specified
-     * addresses.
-     * 
-     * @param bcc
-     *            addresses to set or <code>null</code> or no arguments to
-     *            remove the header field.
-     */
-    public void setBcc(Address... bcc) {
-        setAddressList(FieldName.BCC, bcc);
-    }
-
-    /**
-     * Sets the <i>Bcc</i> header field of this message to the specified
-     * addresses.
-     * 
-     * @param bcc
-     *            addresses to set or <code>null</code> or an empty collection
-     *            to remove the header field.
-     */
-    public void setBcc(Collection<Address> bcc) {
-        setAddressList(FieldName.BCC, bcc);
-    }
-
-    /**
-     * Returns the value of the <i>Reply-To</i> header field of this message as
-     * <code>AddressList</code> object or <code>null</code> if it is not
-     * present.
-     * 
-     * @return value of the reply to field of this message.
-     */
-    public AddressList getReplyTo() {
-        return getAddressList(FieldName.REPLY_TO);
-    }
-
-    /**
-     * Sets the <i>Reply-To</i> header field of this message to the specified
-     * address.
-     * 
-     * @param replyTo
-     *            address to set or <code>null</code> to remove the header
-     *            field.
-     */
-    public void setReplyTo(Address replyTo) {
-        setAddressList(FieldName.REPLY_TO, replyTo);
-    }
-
-    /**
-     * Sets the <i>Reply-To</i> header field of this message to the specified
-     * addresses.
-     * 
-     * @param replyTo
-     *            addresses to set or <code>null</code> or no arguments to
-     *            remove the header field.
-     */
-    public void setReplyTo(Address... replyTo) {
-        setAddressList(FieldName.REPLY_TO, replyTo);
-    }
-
-    /**
-     * Sets the <i>Reply-To</i> header field of this message to the specified
-     * addresses.
-     * 
-     * @param replyTo
-     *            addresses to set or <code>null</code> or an empty collection
-     *            to remove the header field.
-     */
-    public void setReplyTo(Collection<Address> replyTo) {
-        setAddressList(FieldName.REPLY_TO, replyTo);
-    }
-
-    private Mailbox getMailbox(String fieldName) {
-        MailboxField field = obtainField(fieldName);
-        if (field == null)
-            return null;
-
-        return field.getMailbox();
-    }
-
-    private void setMailbox(String fieldName, Mailbox mailbox) {
-        Header header = obtainHeader();
-
-        if (mailbox == null) {
-            header.removeFields(fieldName);
-        } else {
-            header.setField(newMailbox(fieldName, mailbox));
-        }
-    }
-
-    private MailboxList getMailboxList(String fieldName) {
-        MailboxListField field = obtainField(fieldName);
-        if (field == null)
-            return null;
-
-        return field.getMailboxList();
-    }
-
-    private void setMailboxList(String fieldName, Mailbox mailbox) {
-        setMailboxList(fieldName, mailbox == null ? null : Collections
-                .singleton(mailbox));
-    }
-
-    private void setMailboxList(String fieldName, Mailbox... mailboxes) {
-        setMailboxList(fieldName, mailboxes == null ? null : Arrays
-                .asList(mailboxes));
-    }
-
-    private void setMailboxList(String fieldName, Collection<Mailbox> mailboxes) {
-        Header header = obtainHeader();
-
-        if (mailboxes == null || mailboxes.isEmpty()) {
-            header.removeFields(fieldName);
-        } else {
-            header.setField(newMailboxList(fieldName, mailboxes));
-        }
-    }
-
-    private AddressList getAddressList(String fieldName) {
-        AddressListField field = obtainField(fieldName);
-        if (field == null)
-            return null;
-
-        return field.getAddressList();
-    }
-
-    private void setAddressList(String fieldName, Address address) {
-        setAddressList(fieldName, address == null ? null : Collections
-                .singleton(address));
-    }
-
-    private void setAddressList(String fieldName, Address... addresses) {
-        setAddressList(fieldName, addresses == null ? null : Arrays
-                .asList(addresses));
-    }
-
-    private void setAddressList(String fieldName, Collection<Address> addresses) {
-        Header header = obtainHeader();
-
-        if (addresses == null || addresses.isEmpty()) {
-            header.removeFields(fieldName);
-        } else {
-            header.setField(newAddressList(fieldName, addresses));
-        }
-    }
-
 	@Override
 	protected String newUniqueBoundary() {
 		return MimeUtil.createUniqueBoundary();
@@ -638,7 +187,7 @@
 		return Fields.mailboxList(fieldName, mailboxes);
 	}
 
-	private AddressListField newAddressList(String fieldName,
+	protected AddressListField newAddressList(String fieldName,
 			Collection<Address> addresses) {
 		return Fields.addressList(fieldName, addresses);
 	}

Propchange: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MessageImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MultipartImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MultipartImpl.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MultipartImpl.java (original)
+++ james/mime4j/branches/cycleclean/core/src/main/java/org/apache/james/mime4j/message/impl/MultipartImpl.java Thu Dec 31 17:01:21 2009
@@ -64,7 +64,7 @@
      *             operation.
      * @throws IllegalArgumentException
      *             if <code>other</code> contains a <code>Body</code> that
-     *             is neither a {@link Message}, {@link MultipartImpl} or
+     *             is neither a {@link Message}, {@link Multipart} or
      *             {@link SingleBody}.
      */
     public MultipartImpl(Multipart other) {

Modified: james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/CopyConstructorTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/CopyConstructorTest.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/CopyConstructorTest.java (original)
+++ james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/CopyConstructorTest.java Thu Dec 31 17:01:21 2009
@@ -26,6 +26,7 @@
 import org.apache.james.mime4j.field.Field;
 import org.apache.james.mime4j.message.impl.BodyFactory;
 import org.apache.james.mime4j.message.impl.BodyPart;
+import org.apache.james.mime4j.message.impl.MessageImpl;
 import org.apache.james.mime4j.message.impl.MultipartImpl;
 
 import junit.framework.TestCase;
@@ -33,9 +34,9 @@
 public class CopyConstructorTest extends TestCase {
 
     public void testCopyEmptyMessage() throws Exception {
-        Message original = new Message();
+        MessageImpl original = new MessageImpl();
 
-        Message copy = new Message(original);
+        MessageImpl copy = new MessageImpl(original);
 
         assertNull(copy.getHeader());
         assertNull(copy.getBody());
@@ -43,16 +44,16 @@
     }
 
     public void testCopyMessage() throws Exception {
-        Message parent = new Message();
+        MessageImpl parent = new MessageImpl();
         Header header = new Header();
         Body body = new BodyFactory().textBody("test");
 
-        Message original = new Message();
+        MessageImpl original = new MessageImpl();
         original.setHeader(header);
         original.setBody(body);
         original.setParent(parent);
 
-        Message copy = new Message(original);
+        MessageImpl copy = new MessageImpl(original);
 
         assertNotNull(copy.getHeader());
         assertNotSame(header, copy.getHeader());
@@ -76,7 +77,7 @@
     }
 
     public void testCopyBodyPart() throws Exception {
-        Message parent = new Message();
+        MessageImpl parent = new MessageImpl();
         Header header = new Header();
         Body body = new BodyFactory().textBody("test");
 
@@ -111,7 +112,7 @@
     }
 
     public void testCopyMultipart() throws Exception {
-        Message parent = new Message();
+        MessageImpl parent = new MessageImpl();
         BodyPart bodyPart = new BodyPart();
 
         Multipart original = new MultipartImpl("mixed");
@@ -143,11 +144,11 @@
         multipart.addBodyPart(bodyPart1);
         multipart.addBodyPart(bodyPart2);
 
-        Message original = new Message();
+        MessageImpl original = new MessageImpl();
         original.setHeader(new Header());
         original.setBody(multipart);
 
-        Message copy = new Message(original);
+        MessageImpl copy = new MessageImpl(original);
 
         Multipart multipartCopy = (Multipart) copy.getBody();
         List<Entity> bodyParts = multipartCopy.getBodyParts();

Modified: james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java (original)
+++ james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/ExampleMessagesRoundtripTest.java Thu Dec 31 17:01:21 2009
@@ -33,6 +33,7 @@
 import junit.framework.TestSuite;
 
 import org.apache.james.mime4j.codec.CodecUtil;
+import org.apache.james.mime4j.message.impl.MessageImpl;
 import org.apache.james.mime4j.parser.MimeEntityConfig;
 import org.apache.log4j.BasicConfigurator;
 
@@ -67,7 +68,7 @@
         	config.setMalformedHeaderStartsBody(true);
         }
         config.setMaxLineLen(-1);
-        Message inputMessage = new Message(new FileInputStream(file), config);
+        Message inputMessage = new MessageImpl(new FileInputStream(file), config);
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         inputMessage.writeTo(out);
         

Modified: james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageCompleteMailTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageCompleteMailTest.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageCompleteMailTest.java (original)
+++ james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageCompleteMailTest.java Thu Dec 31 17:01:21 2009
@@ -24,6 +24,7 @@
 import junit.framework.TestCase;
 
 import org.apache.james.mime4j.ExampleMail;
+import org.apache.james.mime4j.message.impl.MessageImpl;
 
 public class MessageCompleteMailTest extends TestCase {
 
@@ -38,22 +39,22 @@
     }
     
     public void testMultipartAlternative() throws Exception {
-        Message message = createMessage(ExampleMail.MIME_MULTIPART_ALTERNATIVE_BYTES);
+        MessageImpl 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 {
-        Message message = createMessage(ExampleMail.MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_BYTES);
+        MessageImpl 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 Message createMessage(byte[] octets) throws Exception {
+    private MessageImpl createMessage(byte[] octets) throws Exception {
         ByteArrayInputStream in = new ByteArrayInputStream(octets);
-        Message message = new Message(in);
+        MessageImpl message = new MessageImpl(in);
         return message;
     }
 }

Modified: james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageHeadlessParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageHeadlessParserTest.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageHeadlessParserTest.java (original)
+++ james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageHeadlessParserTest.java Thu Dec 31 17:01:21 2009
@@ -26,6 +26,7 @@
 
 import org.apache.james.mime4j.field.ContentTypeField;
 import org.apache.james.mime4j.field.FieldName;
+import org.apache.james.mime4j.message.impl.MessageImpl;
 import org.apache.james.mime4j.parser.MimeEntityConfig;
 
 public class MessageHeadlessParserTest extends TestCase {
@@ -41,7 +42,7 @@
 
 		MimeEntityConfig mimeEntityConfig = new MimeEntityConfig();
 		mimeEntityConfig.setMalformedHeaderStartsBody(true);
-		Message message = new Message(new ByteArrayInputStream(headlessContent
+		MessageImpl message = new MessageImpl(new ByteArrayInputStream(headlessContent
 				.getBytes("UTF-8")), mimeEntityConfig);
 		assertEquals("text/plain", message.getMimeType());
 		assertEquals(1, message.getHeader().getFields().size());
@@ -59,7 +60,7 @@
 
 		MimeEntityConfig mimeEntityConfig = new MimeEntityConfig();
 		mimeEntityConfig.setMalformedHeaderStartsBody(true);
-		Message message = new Message(new ByteArrayInputStream(headlessContent
+		MessageImpl message = new MessageImpl(new ByteArrayInputStream(headlessContent
 				.getBytes("UTF-8")), mimeEntityConfig);
 		assertEquals("text/plain", message.getMimeType());
 		assertEquals(0, message.getHeader().getFields().size());
@@ -86,7 +87,7 @@
 
 		MimeEntityConfig mimeEntityConfig = new MimeEntityConfig();
 		mimeEntityConfig.setDefaultContentType(contentType);
-		Message message = new Message(new ByteArrayInputStream(headlessContent
+		MessageImpl message = new MessageImpl(new ByteArrayInputStream(headlessContent
 				.getBytes("UTF-8")), mimeEntityConfig);
 		assertEquals("multipart/form-data", message.getMimeType());
 		assertEquals(1, message.getHeader().getFields().size());

Modified: james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java (original)
+++ james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java Thu Dec 31 17:01:21 2009
@@ -21,6 +21,7 @@
 
 import org.apache.commons.io.IOUtils;
 import org.apache.james.mime4j.field.Field;
+import org.apache.james.mime4j.message.impl.MessageImpl;
 import org.apache.james.mime4j.parser.MimeEntityConfig;
 import org.apache.james.mime4j.util.ContentUtil;
 import org.apache.james.mime4j.util.CharsetUtil;
@@ -101,7 +102,7 @@
         	config.setMalformedHeaderStartsBody(true);
         }
         config.setMaxLineLen(-1);
-        Message m = new Message(new FileInputStream(f), config);
+        MessageImpl m = new MessageImpl(new FileInputStream(f), config);
         
         String prefix = f.getName().substring(0, f.getName().length() - 4);
         String xmlFileName = fileName.substring(0, fileName.length() - 4) 
@@ -144,7 +145,7 @@
         
         StringBuilder sb = new StringBuilder();
         
-        if (e instanceof Message) {
+        if (e instanceof MessageImpl) {
             sb.append("<message>\r\n");
         } else {
             sb.append("<body-part>\r\n");
@@ -179,8 +180,8 @@
             
             sb.append("</multipart>\r\n");
             
-        } else if (e.getBody() instanceof Message) {
-            sb.append(getStructure((Message) e.getBody(), prefix, id + "_1"));
+        } else if (e.getBody() instanceof MessageImpl) {
+            sb.append(getStructure((MessageImpl) e.getBody(), prefix, id + "_1"));
         } else {
             Body b = e.getBody();
             String name = prefix + "_decoded_" + id 
@@ -222,7 +223,7 @@
         }
         
         
-        if (e instanceof Message) {
+        if (e instanceof MessageImpl) {
             sb.append("</message>\r\n");
         } else {
             sb.append("</body-part>\r\n");

Modified: james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageTest.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageTest.java (original)
+++ james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageTest.java Thu Dec 31 17:01:21 2009
@@ -37,6 +37,7 @@
 import org.apache.james.mime4j.field.address.Group;
 import org.apache.james.mime4j.field.address.Mailbox;
 import org.apache.james.mime4j.message.impl.BodyPart;
+import org.apache.james.mime4j.message.impl.MessageImpl;
 import org.apache.james.mime4j.message.impl.MultipartImpl;
 
 public class MessageTest extends TestCase {
@@ -65,11 +66,11 @@
     }
 
     public void testGetMimeType() {
-        Message parent = null;
-        Message child = null;
+        MessageImpl parent = null;
+        MessageImpl child = null;
         
-        parent = new Message();
-        child = new Message();
+        parent = new MessageImpl();
+        child = new MessageImpl();
         child.setParent(parent);
         parent.setHeader(headerMultipartDigest);
         child.setHeader(headerEmpty);
@@ -82,8 +83,8 @@
         assertEquals("multipart/digest, message/rfc822", "message/rfc822", 
                 child.getMimeType());
         
-        parent = new Message();
-        child = new Message();
+        parent = new MessageImpl();
+        child = new MessageImpl();
         child.setParent(parent);
         parent.setHeader(headerMultipartMixed);
         child.setHeader(headerEmpty);
@@ -96,7 +97,7 @@
         assertEquals("multipart/mixed, message/rfc822", "message/rfc822", 
                 child.getMimeType());
         
-        child = new Message();
+        child = new MessageImpl();
         child.setHeader(headerEmpty);
         assertEquals("null, empty", "text/plain", child.getMimeType());
         child.setHeader(headerTextPlain);
@@ -107,7 +108,7 @@
     }
 
     public void testIsMultipart() {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
         
         m.setHeader(headerEmpty);
         assertTrue("empty", !m.isMultipart());
@@ -125,7 +126,7 @@
     public void testWriteTo() throws Exception {
         byte[] inputByte = getRawMessageAsByteArray();
 
-        Message m = new Message(new ByteArrayInputStream(inputByte));
+        Message m = new MessageImpl(new ByteArrayInputStream(inputByte));
         ByteArrayOutputStream out = new ByteArrayOutputStream();
 
         m.writeTo(out);
@@ -147,7 +148,7 @@
 
         byte[] inputByte = getRawMessageAsByteArray();
 
-        Message m = new Message(new ByteArrayInputStream(inputByte));
+        MessageImpl m = new MessageImpl(new ByteArrayInputStream(inputByte));
         m.getHeader().addField(DefaultFieldParser.parse(testheader));
 
         assertEquals("header added", m.getHeader().getField(headerName)
@@ -163,7 +164,7 @@
     }
 
     public void testGetMessageId() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
         assertNull(m.getMessageId());
 
         String id = "<msg17@localhost>";
@@ -174,7 +175,7 @@
     }
 
     public void testCreateMessageId() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
         m.createMessageId("hostname");
 
         String id = m.getMessageId();
@@ -184,7 +185,7 @@
     }
 
     public void testGetSubject() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
         assertNull(m.getSubject());
 
         String subject = "testing 1 2";
@@ -198,7 +199,7 @@
     }
 
     public void testSetSubject() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
 
         m.setSubject("Semmelbr\366sel");
         assertEquals("Semmelbr\366sel", m.getSubject());
@@ -210,7 +211,7 @@
     }
 
     public void testGetDate() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
         assertNull(m.getDate());
 
         Header header = new Header();
@@ -221,7 +222,7 @@
     }
 
     public void testSetDate() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
 
         m.setDate(new Date(86400000), TimeZone.getTimeZone("GMT"));
         assertEquals(new Date(86400000), m.getDate());
@@ -233,7 +234,7 @@
     }
 
     public void testGetSender() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
         assertNull(m.getSender());
 
         Header header = new Header();
@@ -244,7 +245,7 @@
     }
 
     public void testSetSender() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
 
         m.setSender(Mailbox.parse("john.doe@example.net"));
         assertEquals("john.doe@example.net", m.getHeader().getField("Sender")
@@ -255,7 +256,7 @@
     }
 
     public void testGetFrom() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
         assertNull(m.getFrom());
 
         Header header = new Header();
@@ -266,7 +267,7 @@
     }
 
     public void testSetFrom() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
 
         Mailbox mailbox1 = Mailbox.parse("john.doe@example.net");
         Mailbox mailbox2 = Mailbox.parse("jane.doe@example.net");
@@ -288,7 +289,7 @@
     }
 
     public void testGetTo() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
         assertNull(m.getTo());
 
         Header header = new Header();
@@ -300,7 +301,7 @@
     }
 
     public void testSetTo() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
 
         Mailbox mailbox1 = Mailbox.parse("john.doe@example.net");
         Mailbox mailbox2 = Mailbox.parse("jane.doe@example.net");
@@ -326,7 +327,7 @@
     }
 
     public void testGetCc() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
         assertNull(m.getCc());
 
         Header header = new Header();
@@ -338,7 +339,7 @@
     }
 
     public void testSetCc() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
 
         Mailbox mailbox1 = Mailbox.parse("john.doe@example.net");
         Mailbox mailbox2 = Mailbox.parse("jane.doe@example.net");
@@ -364,7 +365,7 @@
     }
 
     public void testGetBcc() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
         assertNull(m.getBcc());
 
         Header header = new Header();
@@ -376,7 +377,7 @@
     }
 
     public void testSetBcc() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
 
         Mailbox mailbox1 = Mailbox.parse("john.doe@example.net");
         Mailbox mailbox2 = Mailbox.parse("jane.doe@example.net");
@@ -402,7 +403,7 @@
     }
 
     public void testGetReplyTo() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
         assertNull(m.getReplyTo());
 
         Header header = new Header();
@@ -414,7 +415,7 @@
     }
 
     public void testSetReplyTo() throws Exception {
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
 
         Mailbox mailbox1 = Mailbox.parse("john.doe@example.net");
         Mailbox mailbox2 = Mailbox.parse("jane.doe@example.net");
@@ -454,7 +455,7 @@
         mp.addBodyPart(part1);
         mp.addBodyPart(part2);
 
-        Message m = new Message();
+        MessageImpl m = new MessageImpl();
         m.setHeader(headerMultipartMixed);
         m.setBody(mp);
 

Modified: james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageWriteToTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageWriteToTest.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageWriteToTest.java (original)
+++ james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MessageWriteToTest.java Thu Dec 31 17:01:21 2009
@@ -23,6 +23,7 @@
 import java.io.ByteArrayOutputStream;
 
 import org.apache.james.mime4j.ExampleMail;
+import org.apache.james.mime4j.message.impl.MessageImpl;
 
 import junit.framework.TestCase;
 
@@ -39,7 +40,7 @@
     }
     
     public void testSimpleMail() throws Exception {
-        Message message = createMessage(ExampleMail.RFC822_SIMPLE_BYTES);
+        MessageImpl message = createMessage(ExampleMail.RFC822_SIMPLE_BYTES);
         assertFalse("Not multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         message.writeTo(out);
@@ -56,16 +57,16 @@
     }
     
     public void testBinaryAttachment() throws Exception {
-        Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES);
+        MessageImpl message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES);
         assertTrue("Is multipart", message.isMultipart());
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         message.writeTo(out);
         assertEquals(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES, out.toByteArray());
     }
     
-    private Message createMessage(byte[] octets) throws Exception {
+    private MessageImpl createMessage(byte[] octets) throws Exception {
         ByteArrayInputStream in = new ByteArrayInputStream(octets);
-        Message message = new Message(in);
+        MessageImpl message = new MessageImpl(in);
         return message;
     }
 }

Modified: james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java (original)
+++ james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java Thu Dec 31 17:01:21 2009
@@ -26,6 +26,7 @@
 import org.apache.james.mime4j.field.DefaultFieldParser;
 import org.apache.james.mime4j.message.impl.BodyFactory;
 import org.apache.james.mime4j.message.impl.BodyPart;
+import org.apache.james.mime4j.message.impl.MessageImpl;
 import org.apache.james.mime4j.message.impl.MultipartImpl;
 
 public class MultipartFormTest extends TestCase {
@@ -33,7 +34,7 @@
     public void testMultipartFormContent() throws Exception {
         BodyFactory bodyFactory = new BodyFactory();
         
-        Message message = new Message();
+        MessageImpl message = new MessageImpl();
         Header header = new Header();
         header.addField(
                 DefaultFieldParser.parse("Content-Type: multipart/form-data; boundary=foo"));

Modified: james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/impl/SingleBodyCopyTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/impl/SingleBodyCopyTest.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/impl/SingleBodyCopyTest.java (original)
+++ james/mime4j/branches/cycleclean/core/src/test/java/org/apache/james/mime4j/message/impl/SingleBodyCopyTest.java Thu Dec 31 17:01:21 2009
@@ -24,7 +24,6 @@
 
 import junit.framework.TestCase;
 
-import org.apache.james.mime4j.message.Message;
 import org.apache.james.mime4j.message.SingleBody;
 import org.apache.james.mime4j.message.impl.StorageBinaryBody;
 import org.apache.james.mime4j.message.impl.StorageTextBody;
@@ -79,7 +78,7 @@
     }
 
     private void copyTest(SingleBody body) throws Exception {
-        Message parent = new Message();
+        MessageImpl parent = new MessageImpl();
         parent.setBody(body);
 
         SingleBody copy = body.copy();

Modified: james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/dom/MultipartMessage.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/dom/MultipartMessage.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/dom/MultipartMessage.java (original)
+++ james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/dom/MultipartMessage.java Thu Dec 31 17:01:21 2009
@@ -31,11 +31,11 @@
 
 import org.apache.james.mime4j.field.address.Mailbox;
 import org.apache.james.mime4j.message.BinaryBody;
-import org.apache.james.mime4j.message.Message;
 import org.apache.james.mime4j.message.Multipart;
 import org.apache.james.mime4j.message.TextBody;
 import org.apache.james.mime4j.message.impl.BodyFactory;
 import org.apache.james.mime4j.message.impl.BodyPart;
+import org.apache.james.mime4j.message.impl.MessageImpl;
 import org.apache.james.mime4j.message.impl.MultipartImpl;
 import org.apache.james.mime4j.storage.Storage;
 import org.apache.james.mime4j.storage.StorageOutputStream;
@@ -51,7 +51,7 @@
     public static void main(String[] args) throws Exception {
         // 1) start with an empty message
 
-        Message message = new Message();
+        MessageImpl message = new MessageImpl();
 
         // 2) set header fields
 

Modified: james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/dom/TextPlainMessage.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/dom/TextPlainMessage.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/dom/TextPlainMessage.java (original)
+++ james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/dom/TextPlainMessage.java Thu Dec 31 17:01:21 2009
@@ -23,9 +23,9 @@
 import java.util.Date;
 
 import org.apache.james.mime4j.field.address.Mailbox;
-import org.apache.james.mime4j.message.Message;
 import org.apache.james.mime4j.message.TextBody;
 import org.apache.james.mime4j.message.impl.BodyFactory;
+import org.apache.james.mime4j.message.impl.MessageImpl;
 
 /**
  * This example generates a message very similar to the one from RFC 5322
@@ -35,7 +35,7 @@
     public static void main(String[] args) throws IOException {
         // 1) start with an empty message
 
-        Message message = new Message();
+        MessageImpl message = new MessageImpl();
 
         // 2) set header fields
 

Modified: james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java (original)
+++ james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java Thu Dec 31 17:01:21 2009
@@ -27,11 +27,11 @@
 import org.apache.james.mime4j.field.address.Mailbox;
 import org.apache.james.mime4j.message.Body;
 import org.apache.james.mime4j.message.Entity;
-import org.apache.james.mime4j.message.Message;
 import org.apache.james.mime4j.message.Multipart;
 import org.apache.james.mime4j.message.TextBody;
 import org.apache.james.mime4j.message.impl.BodyFactory;
 import org.apache.james.mime4j.message.impl.BodyPart;
+import org.apache.james.mime4j.message.impl.MessageImpl;
 import org.apache.james.mime4j.message.impl.MultipartImpl;
 import org.apache.james.mime4j.storage.DefaultStorageProvider;
 import org.apache.james.mime4j.storage.StorageProvider;
@@ -55,10 +55,10 @@
         // Create a template message. It would be possible to load a message
         // from an input stream but for this example a message object is created
         // from scratch for demonstration purposes.
-        Message template = createTemplate();
+        MessageImpl template = createTemplate();
 
         // Create a new message by transforming the template.
-        Message transformed = transform(template);
+        MessageImpl transformed = transform(template);
 
         // Print transformed message.
         System.out.println("\n\nTransformed message:\n--------------------\n");
@@ -84,10 +84,10 @@
     /**
      * Copies the given message and makes some arbitrary changes to the copy.
      */
-    private static Message transform(Message original) throws IOException {
+    private static MessageImpl transform(MessageImpl original) throws IOException {
         // Create a copy of the template. The copy can be modified without
         // affecting the original.
-        Message message = new Message(original);
+        MessageImpl message = new MessageImpl(original);
 
         // In this example we know we have a multipart message. Use
         // Message#isMultipart() if uncertain.
@@ -123,7 +123,7 @@
      * Creates a multipart/mixed message that consists of three parts (one text,
      * two binary).
      */
-    private static Message createTemplate() throws IOException {
+    private static MessageImpl createTemplate() throws IOException {
         Multipart multipart = new MultipartImpl("mixed");
 
         BodyPart part1 = createTextPart("This is the first part of the template..");
@@ -135,7 +135,7 @@
         BodyPart part3 = createRandomBinaryPart(300);
         multipart.addBodyPart(part3);
 
-        Message message = new Message();
+        MessageImpl message = new MessageImpl();
         message.setMultipart(multipart);
 
         message.setSubject("Template message");

Modified: james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/tree/MessageTree.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/tree/MessageTree.java?rev=894888&r1=894887&r2=894888&view=diff
==============================================================================
--- james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/tree/MessageTree.java (original)
+++ james/mime4j/branches/cycleclean/examples/src/main/java/org/apache/james/mime4j/samples/tree/MessageTree.java Thu Dec 31 17:01:21 2009
@@ -51,10 +51,10 @@
 import org.apache.james.mime4j.message.Body;
 import org.apache.james.mime4j.message.Entity;
 import org.apache.james.mime4j.message.Header;
-import org.apache.james.mime4j.message.Message;
 import org.apache.james.mime4j.message.Multipart;
 import org.apache.james.mime4j.message.TextBody;
 import org.apache.james.mime4j.message.impl.BodyPart;
+import org.apache.james.mime4j.message.impl.MessageImpl;
 
 /**
  * Displays a parsed Message in a window. The window will be divided into
@@ -100,7 +100,7 @@
      * 
      * @param message the message to display.
      */
-    public MessageTree(Message message) {
+    public MessageTree(MessageImpl message) {
         super(new GridLayout(1,0));
 
         DefaultMutableTreeNode root = createNode(message);
@@ -210,12 +210,12 @@
              */
             
             node.add(createNode((Multipart) body));
-        } else if (body instanceof Message) {
+        } else if (body instanceof MessageImpl) {
             /*
              * The body is another Message.
              */
             
-            node.add(createNode((Message) body));
+            node.add(createNode((MessageImpl) body));
             
         } else {
             /*
@@ -339,7 +339,7 @@
      * 
      * @param message the Message to display in the tree.
      */
-    private static void createAndShowGUI(Message message) {
+    private static void createAndShowGUI(MessageImpl message) {
         /*
          * Create and set up the window.
          */
@@ -363,7 +363,7 @@
     public static void main(String[] args) {
         try {
             
-            final Message message = new Message(new FileInputStream(args[0]));
+            final MessageImpl message = new MessageImpl(new FileInputStream(args[0]));
             
             javax.swing.SwingUtilities.invokeLater(new Runnable() {
                 public void run() {



Mime
View raw message