You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mime4j-dev@james.apache.org by ol...@apache.org on 2011/01/17 15:57:13 UTC

svn commit: r1059942 - in /james/mime4j/branches/dom-api-refactoring: dom/src/main/java/org/apache/james/mime4j/dom/ dom/src/main/java/org/apache/james/mime4j/field/address/parser/ dom/src/main/java/org/apache/james/mime4j/message/ dom/src/test/java/or...

Author: olegk
Date: Mon Jan 17 14:57:12 2011
New Revision: 1059942

URL: http://svn.apache.org/viewvc?rev=1059942&view=rev
Log:
Moved all implementation details from 'dom' to 'message'; 'dom' is mostly pure interfaces now

Added:
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/EntityBase.java
      - copied, changed from r1059932, james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Entity.java
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/HeaderBase.java
      - copied, changed from r1059932, james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Header.java
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageBase.java
      - copied, changed from r1059932, james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Message.java
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MultipartBase.java
      - copied, changed from r1059932, james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Multipart.java
Modified:
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Entity.java
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Header.java
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Message.java
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Multipart.java
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/field/address/parser/AddressBuilder.java
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/BodyPart.java
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/EntityBuilder.java
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/HeaderImpl.java
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MultipartImpl.java
    james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/SimpleContentHandler.java
    james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/CopyConstructorTest.java
    james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java
    james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java
    james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java
    james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java
    james/mime4j/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Entity.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Entity.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Entity.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Entity.java Mon Jan 17 14:57:12 2011
@@ -19,41 +19,18 @@
 
 package org.apache.james.mime4j.dom;
 
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.james.mime4j.dom.field.ContentDispositionField;
-import org.apache.james.mime4j.dom.field.ContentTransferEncodingField;
-import org.apache.james.mime4j.dom.field.ContentTypeField;
-import org.apache.james.mime4j.dom.field.Field;
-import org.apache.james.mime4j.dom.field.FieldName;
-
 /**
  * MIME entity. An entity has a header and a body (see RFC 2045).
  */
-public abstract class Entity implements Disposable {
-    private Header header = null;
-    private Body body = null;
-    private Entity parent = null;
-
-    /**
-     * Creates a new <code>Entity</code>. Typically invoked implicitly by a
-     * subclass constructor.
-     */
-    protected Entity() {
-    }
-
+public interface Entity extends Disposable {
+    
     /**
      * Gets the parent entity of this entity.
      * Returns <code>null</code> if this is the root entity.
      * 
      * @return the parent or <code>null</code>.
      */
-    public Entity getParent() {
-        return parent;
-    }
+    Entity getParent();
     
     /**
      * Sets the parent entity of this entity.
@@ -61,36 +38,28 @@ public abstract class Entity implements 
      * @param parent the parent entity or <code>null</code> if
      *        this will be the root entity.
      */
-    public void setParent(Entity parent) {
-        this.parent = parent;
-    }
-    
+    void setParent(Entity parent);
+
     /**
      * Gets the entity header.
      * 
      * @return the header.
      */
-    public Header getHeader() {
-        return header;
-    }
+    Header getHeader();
     
     /**
      * Sets the entity header.
      * 
      * @param header the header.
      */
-    public void setHeader(Header header) {
-        this.header = header;
-    }
+    void setHeader(Header header);
     
     /**
      * Gets the body of this entity.
      * 
      * @return the body,
      */
-    public Body getBody() {
-        return body;
-    }
+    Body getBody();
 
     /**
      * Sets the body of this entity.
@@ -98,14 +67,8 @@ public abstract class Entity implements 
      * @param body the body.
      * @throws IllegalStateException if the body has already been set.
      */
-    public void setBody(Body body) {
-        if (this.body != null)
-            throw new IllegalStateException("body already set");
-
-        this.body = body;
-        body.setParent(this);
-    }
-
+    void setBody(Body body);
+    
     /**
      * Removes and returns the body of this entity. The removed body may be
      * attached to another entity. If it is no longer needed it should be
@@ -113,141 +76,8 @@ public abstract class Entity implements 
      * 
      * @return the removed body or <code>null</code> if no body was set.
      */
-    public Body removeBody() {
-        if (body == null)
-            return null;
-
-        Body body = this.body;
-        this.body = null;
-        body.setParent(null);
-
-        return body;
-    }
-
-    /**
-     * Sets the specified message as body of this entity and the content type to
-     * &quot;message/rfc822&quot;. A <code>Header</code> is created if this
-     * entity does not already have one.
-     * 
-     * @param message
-     *            the message to set as body.
-     */
-    public void setMessage(Message message) {
-        setBody(message, "message/rfc822", null);
-    }
-
-    /**
-     * Sets the specified multipart as body of this entity. Also sets the
-     * content type accordingly and creates a message boundary string. A
-     * <code>Header</code> is created if this entity does not already have
-     * one.
-     * 
-     * @param multipart
-     *            the multipart to set as body.
-     */
-    public void setMultipart(Multipart multipart) {
-        String mimeType = "multipart/" + multipart.getSubType();
-        Map<String, String> parameters = Collections.singletonMap("boundary",
-                newUniqueBoundary());
-
-        setBody(multipart, mimeType, parameters);
-    }
-
-    /**
-     * Sets the specified multipart as body of this entity. Also sets the
-     * content type accordingly and creates a message boundary string. A
-     * <code>Header</code> is created if this entity does not already have
-     * one.
-     * 
-     * @param multipart
-     *            the multipart to set as body.
-     * @param parameters
-     *            additional parameters for the Content-Type header field.
-     */
-    public void setMultipart(Multipart multipart, Map<String, String> parameters) {
-        String mimeType = "multipart/" + multipart.getSubType();
-        if (!parameters.containsKey("boundary")) {
-            parameters = new HashMap<String, String>(parameters);
-            parameters.put("boundary", newUniqueBoundary());
-        }
-
-        setBody(multipart, mimeType, parameters);
-    }
-
-    /**
-     * Sets the specified <code>TextBody</code> as body of this entity and the
-     * content type to &quot;text/plain&quot;. A <code>Header</code> is
-     * created if this entity does not already have one.
-     * 
-     * @param textBody
-     *            the <code>TextBody</code> to set as body.
-     * @see org.apache.james.mime4j.message.BodyFactory#textBody(String)
-     */
-    public void setText(TextBody textBody) {
-        setText(textBody, "plain");
-    }
-
-    /**
-     * Sets the specified <code>TextBody</code> as body of this entity. Also
-     * sets the content type according to the specified sub-type. A
-     * <code>Header</code> is created if this entity does not already have
-     * one.
-     * 
-     * @param textBody
-     *            the <code>TextBody</code> to set as body.
-     * @param subtype
-     *            the text subtype (e.g. &quot;plain&quot;, &quot;html&quot; or
-     *            &quot;xml&quot;).
-     * @see org.apache.james.mime4j.message.BodyFactory#textBody(String)
-     */
-    public void setText(TextBody textBody, String subtype) {
-        String mimeType = "text/" + subtype;
-
-        Map<String, String> parameters = null;
-        String mimeCharset = textBody.getMimeCharset();
-        if (mimeCharset != null && !mimeCharset.equalsIgnoreCase("us-ascii")) {
-            parameters = Collections.singletonMap("charset", mimeCharset);
-        }
-
-        setBody(textBody, mimeType, parameters);
-    }
-
-    /**
-     * Sets the body of this entity and sets the content-type to the specified
-     * value. A <code>Header</code> is created if this entity does not already
-     * have one.
-     * 
-     * @param body
-     *            the body.
-     * @param mimeType
-     *            the MIME media type of the specified body
-     *            (&quot;type/subtype&quot;).
-     */
-    public void setBody(Body body, String mimeType) {
-        setBody(body, mimeType, null);
-    }
-
-    /**
-     * Sets the body of this entity and sets the content-type to the specified
-     * value. A <code>Header</code> is created if this entity does not already
-     * have one.
-     * 
-     * @param body
-     *            the body.
-     * @param mimeType
-     *            the MIME media type of the specified body
-     *            (&quot;type/subtype&quot;).
-     * @param parameters
-     *            additional parameters for the Content-Type header field.
-     */
-    public void setBody(Body body, String mimeType,
-            Map<String, String> parameters) {
-        setBody(body);
-
-        Header header = obtainHeader();
-        header.setField(newContentType(mimeType, parameters));
-    }
-
+    Body removeBody();
+    
     /**
      * Determines the MIME type of this <code>Entity</code>. The MIME type
      * is derived by looking at the parent's Content-Type field if no
@@ -255,296 +85,20 @@ public abstract class Entity implements 
      * 
      * @return the MIME type.
      */
-    public String getMimeType() {
-        ContentTypeField child = 
-            getContentTypeField();
-        ContentTypeField parent = getParent() != null 
-            ? (ContentTypeField) getParent().getHeader().
-                                                getField(FieldName.CONTENT_TYPE)
-            : null;
-        
-        return calcMimeType(child, parent);
-    }
+    String getMimeType();
 
-    private ContentTypeField getContentTypeField() {
-        return (ContentTypeField) getHeader().getField(FieldName.CONTENT_TYPE);
-    }
-    
     /**
      * Determines the MIME character set encoding of this <code>Entity</code>.
      * 
      * @return the MIME character set encoding.
      */
-    public String getCharset() {
-        return calcCharset((ContentTypeField) getHeader().getField(FieldName.CONTENT_TYPE));
-    }
+    String getCharset();
     
     /**
      * Determines the transfer encoding of this <code>Entity</code>.
      * 
      * @return the transfer encoding.
      */
-    public String getContentTransferEncoding() {
-        ContentTransferEncodingField f = (ContentTransferEncodingField) 
-                        getHeader().getField(FieldName.CONTENT_TRANSFER_ENCODING);
-        
-        return calcTransferEncoding(f);
-    }
-
-    /**
-     * Sets the transfer encoding of this <code>Entity</code> to the specified
-     * value.
-     * 
-     * @param contentTransferEncoding
-     *            transfer encoding to use.
-     */
-    public void setContentTransferEncoding(String contentTransferEncoding) {
-        Header header = obtainHeader();
-        header.setField(newContentTransferEncoding(contentTransferEncoding));
-    }
-
-    /**
-     * Return the disposition type of the content disposition of this
-     * <code>Entity</code>.
-     * 
-     * @return the disposition type or <code>null</code> if no disposition
-     *         type has been set.
-     */
-    public String getDispositionType() {
-        ContentDispositionField field = obtainField(FieldName.CONTENT_DISPOSITION);
-        if (field == null)
-            return null;
-
-        return field.getDispositionType();
-    }
-
-    /**
-     * Sets the content disposition of this <code>Entity</code> to the
-     * specified disposition type. No filename, size or date parameters
-     * are included in the content disposition.
-     * 
-     * @param dispositionType
-     *            disposition type value (usually <code>inline</code> or
-     *            <code>attachment</code>).
-     */
-    public void setContentDisposition(String dispositionType) {
-        Header header = obtainHeader();
-        header.setField(newContentDisposition(dispositionType, null, -1, null,
-                null, null));
-    }
-
-    /**
-     * Sets the content disposition of this <code>Entity</code> to the
-     * specified disposition type and filename. No size or date parameters are
-     * included in the content disposition.
-     * 
-     * @param dispositionType
-     *            disposition type value (usually <code>inline</code> or
-     *            <code>attachment</code>).
-     * @param filename
-     *            filename parameter value or <code>null</code> if the
-     *            parameter should not be included.
-     */
-    public void setContentDisposition(String dispositionType, String filename) {
-        Header header = obtainHeader();
-        header.setField(newContentDisposition(dispositionType, filename, -1,
-                null, null, null));
-    }
-
-    /**
-     * Sets the content disposition of this <code>Entity</code> to the
-     * specified values. No date parameters are included in the content
-     * disposition.
-     * 
-     * @param dispositionType
-     *            disposition type value (usually <code>inline</code> or
-     *            <code>attachment</code>).
-     * @param filename
-     *            filename parameter value or <code>null</code> if the
-     *            parameter should not be included.
-     * @param size
-     *            size parameter value or <code>-1</code> if the parameter
-     *            should not be included.
-     */
-    public void setContentDisposition(String dispositionType, String filename,
-            long size) {
-        Header header = obtainHeader();
-        header.setField(newContentDisposition(dispositionType, filename, size,
-                null, null, null));
-    }
-
-    /**
-     * Sets the content disposition of this <code>Entity</code> to the
-     * specified values.
-     * 
-     * @param dispositionType
-     *            disposition type value (usually <code>inline</code> or
-     *            <code>attachment</code>).
-     * @param filename
-     *            filename parameter value or <code>null</code> if the
-     *            parameter should not be included.
-     * @param size
-     *            size parameter value or <code>-1</code> if the parameter
-     *            should not be included.
-     * @param creationDate
-     *            creation-date parameter value or <code>null</code> if the
-     *            parameter should not be included.
-     * @param modificationDate
-     *            modification-date parameter value or <code>null</code> if
-     *            the parameter should not be included.
-     * @param readDate
-     *            read-date parameter value or <code>null</code> if the
-     *            parameter should not be included.
-     */
-    public void setContentDisposition(String dispositionType, String filename,
-            long size, Date creationDate, Date modificationDate, Date readDate) {
-        Header header = obtainHeader();
-        header.setField(newContentDisposition(dispositionType, filename, size,
-                creationDate, modificationDate, readDate));
-    }
-
-    /**
-     * Returns the filename parameter of the content disposition of this
-     * <code>Entity</code>.
-     * 
-     * @return the filename parameter of the content disposition or
-     *         <code>null</code> if the filename has not been set.
-     */
-    public String getFilename() {
-        ContentDispositionField field = obtainField(FieldName.CONTENT_DISPOSITION);
-        if (field == null)
-            return null;
-
-        return field.getFilename();
-    }
-    
-    /**
-     * Sets the filename parameter of the content disposition of this
-     * <code>Entity</code> to the specified value. If this entity does not
-     * have a content disposition header field a new one with disposition type
-     * <code>attachment</code> is created.
-     * 
-     * @param filename
-     *            filename parameter value or <code>null</code> if the
-     *            parameter should be removed.
-     */
-    public void setFilename(String filename) {
-        Header header = obtainHeader();
-        ContentDispositionField field = (ContentDispositionField) header
-                .getField(FieldName.CONTENT_DISPOSITION);
-        if (field == null) {
-            if (filename != null) {
-                header.setField(newContentDisposition(
-                        ContentDispositionField.DISPOSITION_TYPE_ATTACHMENT,
-                        filename, -1, null, null, null));
-            }
-        } else {
-            String dispositionType = field.getDispositionType();
-            Map<String, String> parameters = new HashMap<String, String>(field
-                    .getParameters());
-            if (filename == null) {
-                parameters.remove(ContentDispositionField.PARAM_FILENAME);
-            } else {
-                parameters
-                        .put(ContentDispositionField.PARAM_FILENAME, filename);
-            }
-            header.setField(newContentDisposition(dispositionType, parameters));
-        }
-    }
-
-    /**
-     * Determines if the MIME type of this <code>Entity</code> matches the
-     * given one. MIME types are case-insensitive.
-     * 
-     * @param type the MIME type to match against.
-     * @return <code>true</code> on match, <code>false</code> otherwise.
-     */
-    public boolean isMimeType(String type) {
-        return getMimeType().equalsIgnoreCase(type);
-    }
-    
-    /**
-     * Determines if the MIME type of this <code>Entity</code> is
-     * <code>multipart/*</code>. Since multipart-entities must have
-     * a boundary parameter in the <code>Content-Type</code> field this
-     * method returns <code>false</code> if no boundary exists.
-     * 
-     * @return <code>true</code> on match, <code>false</code> otherwise.
-     */
-    public boolean isMultipart() {
-        ContentTypeField f = getContentTypeField();
-        return f != null
-                && f.getBoundary() != null
-                && getMimeType().startsWith(
-                        ContentTypeField.TYPE_MULTIPART_PREFIX);
-    }
-
-    /**
-     * Disposes of the body of this entity. Note that the dispose call does not
-     * get forwarded to the parent entity of this Entity.
-     * 
-     * Subclasses that need to free resources should override this method and
-     * invoke super.dispose().
-     * 
-     * @see org.apache.james.mime4j.dom.Disposable#dispose()
-     */
-    public void dispose() {
-        if (body != null) {
-            body.dispose();
-        }
-    }
-
-    /**
-     * Obtains the header of this entity. Creates and sets a new header if this
-     * entity's header is currently <code>null</code>.
-     * 
-     * @return the header of this entity; never <code>null</code>.
-     */
-    Header obtainHeader() {
-        if (header == null) {
-            header = new Header();
-        }
-        return header;
-    }
-
-    /**
-     * Obtains the header field with the specified name.
-     * 
-     * @param <F>
-     *            concrete field type.
-     * @param fieldName
-     *            name of the field to retrieve.
-     * @return the header field or <code>null</code> if this entity has no
-     *         header or the header contains no such field.
-     */
-    <F extends Field> F obtainField(String fieldName) {
-        Header header = getHeader();
-        if (header == null)
-            return null;
-
-        @SuppressWarnings("unchecked")
-        F field = (F) header.getField(fieldName);
-        return field;
-    }
-
-    protected abstract String newUniqueBoundary();
-
-    protected abstract ContentDispositionField newContentDisposition(
-            String dispositionType, String filename, long size,
-            Date creationDate, Date modificationDate, Date readDate);
-
-    protected abstract ContentDispositionField newContentDisposition(
-            String dispositionType, Map<String, String> parameters);
-
-    protected abstract ContentTypeField newContentType(String mimeType,
-            Map<String, String> parameters);
-
-    protected abstract ContentTransferEncodingField newContentTransferEncoding(
-            String contentTransferEncoding);
-
-    protected abstract String calcMimeType(ContentTypeField child, ContentTypeField parent);
-
-    protected abstract String calcTransferEncoding(ContentTransferEncodingField f);
+    String getContentTransferEncoding();
 
-    protected abstract String calcCharset(ContentTypeField contentType);
-}
+}
\ No newline at end of file

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Header.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Header.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Header.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Header.java Mon Jan 17 14:57:12 2011
@@ -19,59 +19,22 @@
 
 package org.apache.james.mime4j.dom;
 
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.Iterator;
-import java.util.LinkedList;
 import java.util.List;
-import java.util.Map;
 
 import org.apache.james.mime4j.dom.field.Field;
 
 /**
  * The header of an entity (see RFC 2045).
  */
-public class Header implements Iterable<Field> {
-
-    private List<Field> fields = new LinkedList<Field>();
-    private Map<String, List<Field>> fieldMap = new HashMap<String, List<Field>>();
-    
-    /**
-     * Creates a new empty <code>Header</code>.
-     */
-    public Header() {
-    }
-
-    /**
-     * Creates a new <code>Header</code> from the specified
-     * <code>Header</code>. The <code>Header</code> instance is initialized
-     * with a copy of the list of {@link Field}s of the specified
-     * <code>Header</code>. The <code>Field</code> objects are not copied
-     * because they are immutable and can safely be shared between headers.
-     * 
-     * @param other
-     *            header to copy.
-     */
-    public Header(Header other) {
-        for (Field otherField : other.fields) {
-            addField(otherField);
-        }
-    }
+public interface Header extends Iterable<Field> {
 
     /**
      * Adds a field to the end of the list of fields.
      * 
      * @param field the field to add.
      */
-    public void addField(Field field) {
-        List<Field> values = fieldMap.get(field.getName().toLowerCase());
-        if (values == null) {
-            values = new LinkedList<Field>();
-            fieldMap.put(field.getName().toLowerCase(), values);
-        }
-        values.add(field);
-        fields.add(field);
-    }
+    void addField(Field field);
     
     /**
      * Gets the fields of this header. The returned list will not be
@@ -79,9 +42,7 @@ public class Header implements Iterable<
      * 
      * @return the list of <code>Field</code> objects.
      */
-    public List<Field> getFields() {
-        return Collections.unmodifiableList(fields);
-    }
+    List<Field> getFields();
 
     /**
      * Gets a <code>Field</code> given a field name. If there are multiple
@@ -90,13 +51,7 @@ public class Header implements Iterable<
      * @param name the field name (e.g. From, Subject).
      * @return the field or <code>null</code> if none found.
      */
-    public Field getField(String name) {
-        List<Field> l = fieldMap.get(name.toLowerCase());
-        if (l != null && !l.isEmpty()) {
-            return l.get(0);
-        }
-        return null;
-    }
+    Field getField(String name);
     
     /**
      * Gets all <code>Field</code>s having the specified field name. 
@@ -104,26 +59,14 @@ public class Header implements Iterable<
      * @param name the field name (e.g. From, Subject).
      * @return the list of fields.
      */
-    public List<Field> getFields(final String name) {
-        final String lowerCaseName = name.toLowerCase();
-        final List<Field> l = fieldMap.get(lowerCaseName);
-        final List<Field> results;
-        if (l == null || l.isEmpty()) {
-            results = Collections.emptyList();
-        } else {
-            results = Collections.unmodifiableList(l);
-        }
-        return results;
-    }
+    List<Field> getFields(final String name);
 
     /**
      * Returns an iterator over the list of fields of this header.
      * 
      * @return an iterator.
      */
-    public Iterator<Field> iterator() {
-        return Collections.unmodifiableList(fields).iterator();
-    }
+    Iterator<Field> iterator();
 
     /**
      * Removes all <code>Field</code>s having the specified field name.
@@ -132,20 +75,7 @@ public class Header implements Iterable<
      *            the field name (e.g. From, Subject).
      * @return number of fields removed.
      */
-    public int removeFields(String name) {
-        final String lowerCaseName = name.toLowerCase();
-        List<Field> removed = fieldMap.remove(lowerCaseName);
-        if (removed == null || removed.isEmpty())
-            return 0;
-
-        for (Iterator<Field> iterator = fields.iterator(); iterator.hasNext();) {
-            Field field = iterator.next();
-            if (field.getName().equalsIgnoreCase(name))
-                iterator.remove();
-        }
-
-        return removed.size();
-    }
+    int removeFields(String name);
 
     /**
      * Sets or replaces a field. This method is useful for header fields such as
@@ -159,46 +89,6 @@ public class Header implements Iterable<
      * 
      * @param field the field to set.
      */
-    public void setField(Field field) {
-        final String lowerCaseName = field.getName().toLowerCase();
-        List<Field> l = fieldMap.get(lowerCaseName);
-        if (l == null || l.isEmpty()) {
-            addField(field);
-            return;
-        }
-
-        l.clear();
-        l.add(field);
-
-        int firstOccurrence = -1;
-        int index = 0;
-        for (Iterator<Field> iterator = fields.iterator(); iterator.hasNext(); index++) {
-            Field f = iterator.next();
-            if (f.getName().equalsIgnoreCase(field.getName())) {
-                iterator.remove();
-
-                if (firstOccurrence == -1)
-                    firstOccurrence = index;
-            }
-        }
-
-        fields.add(firstOccurrence, field);
-    }
-
-    /**
-     * Return Header Object as String representation. Each headerline is
-     * seperated by "\r\n"
-     * 
-     * @return headers
-     */
-    @Override
-    public String toString() {
-        StringBuilder str = new StringBuilder(128);
-        for (Field field : fields) {
-            str.append(field.toString());
-            str.append("\r\n");
-        }
-        return str.toString();
-    }
-
+    void setField(Field field);
+    
 }

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Message.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Message.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Message.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Message.java Mon Jan 17 14:57:12 2011
@@ -21,9 +21,7 @@ package org.apache.james.mime4j.dom;
 
 import java.io.IOException;
 import java.io.OutputStream;
-import java.util.Arrays;
 import java.util.Collection;
-import java.util.Collections;
 import java.util.Date;
 import java.util.TimeZone;
 
@@ -31,27 +29,18 @@ import org.apache.james.mime4j.dom.addre
 import org.apache.james.mime4j.dom.address.AddressList;
 import org.apache.james.mime4j.dom.address.Mailbox;
 import org.apache.james.mime4j.dom.address.MailboxList;
-import org.apache.james.mime4j.dom.field.AddressListField;
-import org.apache.james.mime4j.dom.field.DateTimeField;
-import org.apache.james.mime4j.dom.field.Field;
-import org.apache.james.mime4j.dom.field.FieldName;
-import org.apache.james.mime4j.dom.field.MailboxField;
-import org.apache.james.mime4j.dom.field.MailboxListField;
-import org.apache.james.mime4j.dom.field.UnstructuredField;
 
-public abstract class Message extends Entity implements Body {
+public interface Message extends Entity, Body {
 
     /**
-     * Write the content to the given output stream using the
-     * {@link org.apache.james.mime4j.message.MessageWriter#DEFAULT default} message writer.
+     * Write the content to the given output stream.
      * 
      * @param out
      *            the output stream to write to.
      * @throws IOException
      *             in case of an I/O error
-     * @see org.apache.james.mime4j.message.MessageWriter
      */
-    public abstract void writeTo(OutputStream out) throws IOException;
+    void writeTo(OutputStream out) throws IOException;
 
     /**
      * Returns the value of the <i>Message-ID</i> header field of this message
@@ -59,13 +48,7 @@ public abstract class Message extends En
      * 
      * @return the identifier of this message.
      */
-    public String getMessageId() {
-        Field field = obtainField(FieldName.MESSAGE_ID);
-        if (field == null)
-            return null;
-
-        return field.getBody();
-    }
+    String getMessageId();
 
     /**
      * Creates and sets a new <i>Message-ID</i> header field for this message.
@@ -76,13 +59,7 @@ public abstract class Message extends En
      *            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));
-    }
-
-    protected abstract Field newMessageId(String hostname);
+    void createMessageId(String hostname);
 
     /**
      * Returns the (decoded) value of the <i>Subject</i> header field of this
@@ -90,13 +67,7 @@ public abstract class Message extends En
      * 
      * @return the subject of this message.
      */
-    public String getSubject() {
-        UnstructuredField field = obtainField(FieldName.SUBJECT);
-        if (field == null)
-            return null;
-
-        return field.getValue();
-    }
+    String getSubject();
 
     /**
      * Sets the <i>Subject</i> header field for this message. The specified
@@ -108,15 +79,7 @@ public abstract class Message extends En
      *            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));
-        }
-    }
+    void setSubject(String subject);
 
     /**
      * Returns the value of the <i>Date</i> header field of this message as
@@ -124,13 +87,7 @@ public abstract class Message extends En
      * 
      * @return the date of this message.
      */
-    public Date getDate() {
-        DateTimeField dateField = obtainField(FieldName.DATE);
-        if (dateField == null)
-            return null;
-
-        return dateField.getDate();
-    }
+    Date getDate();
 
     /**
      * Sets the <i>Date</i> header field for this message. This method uses the
@@ -141,9 +98,7 @@ public abstract class Message extends En
      *            date to set or <code>null</code> to remove the date header
      *            field.
      */
-    public void setDate(Date date) {
-        setDate(date, null);
-    }
+    void setDate(Date date);
 
     /**
      * Sets the <i>Date</i> header field for this message. The specified
@@ -156,15 +111,7 @@ public abstract class Message extends En
      * @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));
-        }
-    }
+    void setDate(Date date, TimeZone zone);
 
     /**
      * Returns the value of the <i>Sender</i> header field of this message as
@@ -173,9 +120,7 @@ public abstract class Message extends En
      * 
      * @return the sender of this message.
      */
-    public Mailbox getSender() {
-        return getMailbox(FieldName.SENDER);
-    }
+    Mailbox getSender();
 
     /**
      * Sets the <i>Sender</i> header field of this message to the specified
@@ -185,9 +130,7 @@ public abstract class Message extends En
      *            address to set or <code>null</code> to remove the header
      *            field.
      */
-    public void setSender(Mailbox sender) {
-        setMailbox(FieldName.SENDER, sender);
-    }
+    void setSender(Mailbox sender);
 
     /**
      * Returns the value of the <i>From</i> header field of this message as
@@ -196,9 +139,7 @@ public abstract class Message extends En
      * 
      * @return value of the from field of this message.
      */
-    public MailboxList getFrom() {
-        return getMailboxList(FieldName.FROM);
-    }
+    MailboxList getFrom();
 
     /**
      * Sets the <i>From</i> header field of this message to the specified
@@ -208,9 +149,7 @@ public abstract class Message extends En
      *            address to set or <code>null</code> to remove the header
      *            field.
      */
-    public void setFrom(Mailbox from) {
-        setMailboxList(FieldName.FROM, from);
-    }
+    void setFrom(Mailbox from);
 
     /**
      * Sets the <i>From</i> header field of this message to the specified
@@ -220,9 +159,7 @@ public abstract class Message extends En
      *            addresses to set or <code>null</code> or no arguments to
      *            remove the header field.
      */
-    public void setFrom(Mailbox... from) {
-        setMailboxList(FieldName.FROM, from);
-    }
+    void setFrom(Mailbox... from);
 
     /**
      * Sets the <i>From</i> header field of this message to the specified
@@ -232,9 +169,7 @@ public abstract class Message extends En
      *            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);
-    }
+    void setFrom(Collection<Mailbox> from);
 
     /**
      * Returns the value of the <i>To</i> header field of this message as
@@ -243,9 +178,7 @@ public abstract class Message extends En
      * 
      * @return value of the to field of this message.
      */
-    public AddressList getTo() {
-        return getAddressList(FieldName.TO);
-    }
+    AddressList getTo();
 
     /**
      * Sets the <i>To</i> header field of this message to the specified
@@ -255,9 +188,7 @@ public abstract class Message extends En
      *            address to set or <code>null</code> to remove the header
      *            field.
      */
-    public void setTo(Address to) {
-        setAddressList(FieldName.TO, to);
-    }
+    void setTo(Address to);
 
     /**
      * Sets the <i>To</i> header field of this message to the specified
@@ -267,9 +198,7 @@ public abstract class Message extends En
      *            addresses to set or <code>null</code> or no arguments to
      *            remove the header field.
      */
-    public void setTo(Address... to) {
-        setAddressList(FieldName.TO, to);
-    }
+    void setTo(Address... to);
 
     /**
      * Sets the <i>To</i> header field of this message to the specified
@@ -279,9 +208,7 @@ public abstract class Message extends En
      *            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);
-    }
+    void setTo(Collection<Address> to);
 
     /**
      * Returns the value of the <i>Cc</i> header field of this message as
@@ -290,9 +217,7 @@ public abstract class Message extends En
      * 
      * @return value of the cc field of this message.
      */
-    public AddressList getCc() {
-        return getAddressList(FieldName.CC);
-    }
+    AddressList getCc();
 
     /**
      * Sets the <i>Cc</i> header field of this message to the specified
@@ -302,9 +227,7 @@ public abstract class Message extends En
      *            address to set or <code>null</code> to remove the header
      *            field.
      */
-    public void setCc(Address cc) {
-        setAddressList(FieldName.CC, cc);
-    }
+    void setCc(Address cc);
 
     /**
      * Sets the <i>Cc</i> header field of this message to the specified
@@ -314,9 +237,7 @@ public abstract class Message extends En
      *            addresses to set or <code>null</code> or no arguments to
      *            remove the header field.
      */
-    public void setCc(Address... cc) {
-        setAddressList(FieldName.CC, cc);
-    }
+    void setCc(Address... cc);
 
     /**
      * Sets the <i>Cc</i> header field of this message to the specified
@@ -326,9 +247,7 @@ public abstract class Message extends En
      *            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);
-    }
+    void setCc(Collection<Address> cc);
 
     /**
      * Returns the value of the <i>Bcc</i> header field of this message as
@@ -337,9 +256,7 @@ public abstract class Message extends En
      * 
      * @return value of the bcc field of this message.
      */
-    public AddressList getBcc() {
-        return getAddressList(FieldName.BCC);
-    }
+    AddressList getBcc();
 
     /**
      * Sets the <i>Bcc</i> header field of this message to the specified
@@ -349,9 +266,7 @@ public abstract class Message extends En
      *            address to set or <code>null</code> to remove the header
      *            field.
      */
-    public void setBcc(Address bcc) {
-        setAddressList(FieldName.BCC, bcc);
-    }
+    void setBcc(Address bcc);
 
     /**
      * Sets the <i>Bcc</i> header field of this message to the specified
@@ -361,9 +276,7 @@ public abstract class Message extends En
      *            addresses to set or <code>null</code> or no arguments to
      *            remove the header field.
      */
-    public void setBcc(Address... bcc) {
-        setAddressList(FieldName.BCC, bcc);
-    }
+    void setBcc(Address... bcc);
 
     /**
      * Sets the <i>Bcc</i> header field of this message to the specified
@@ -373,9 +286,7 @@ public abstract class Message extends En
      *            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);
-    }
+    void setBcc(Collection<Address> bcc);
 
     /**
      * Returns the value of the <i>Reply-To</i> header field of this message as
@@ -384,9 +295,7 @@ public abstract class Message extends En
      * 
      * @return value of the reply to field of this message.
      */
-    public AddressList getReplyTo() {
-        return getAddressList(FieldName.REPLY_TO);
-    }
+    AddressList getReplyTo();
 
     /**
      * Sets the <i>Reply-To</i> header field of this message to the specified
@@ -396,9 +305,7 @@ public abstract class Message extends En
      *            address to set or <code>null</code> to remove the header
      *            field.
      */
-    public void setReplyTo(Address replyTo) {
-        setAddressList(FieldName.REPLY_TO, replyTo);
-    }
+    void setReplyTo(Address replyTo);
 
     /**
      * Sets the <i>Reply-To</i> header field of this message to the specified
@@ -408,9 +315,7 @@ public abstract class Message extends En
      *            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);
-    }
+    void setReplyTo(Address... replyTo);
 
     /**
      * Sets the <i>Reply-To</i> header field of this message to the specified
@@ -420,93 +325,6 @@ public abstract class Message extends En
      *            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));
-        }
-    }
-
-    protected abstract AddressListField newAddressList(String fieldName, Collection<Address> addresses);
-
-    protected abstract UnstructuredField newSubject(String subject);
-
-    protected abstract DateTimeField newDate(Date date, TimeZone zone);
-
-    protected abstract MailboxField newMailbox(String fieldName, Mailbox mailbox);
-
-    protected abstract MailboxListField newMailboxList(String fieldName, Collection<Mailbox> mailboxes);
+    void setReplyTo(Collection<Address> replyTo);
 
-    
 }
\ No newline at end of file

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Multipart.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Multipart.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Multipart.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Multipart.java Mon Jan 17 14:57:12 2011
@@ -19,8 +19,6 @@
 
 package org.apache.james.mime4j.dom;
 
-import java.util.Collections;
-import java.util.LinkedList;
 import java.util.List;
 
 /**
@@ -30,19 +28,7 @@ import java.util.List;
  * first body part while the epilogue consists of whatever characters come after
  * the last body part.
  */
-public abstract class Multipart implements Body {
-
-    protected List<Entity> bodyParts = new LinkedList<Entity>();
-    private Entity parent = null;
-
-    private String subType;
-
-    /**
-     * Creates a new empty <code>Multipart</code> instance.
-     */
-    public Multipart(String subType) {
-        this.subType = subType;
-    }
+public interface Multipart extends Body {
 
     /**
      * Gets the multipart sub-type. E.g. <code>alternative</code> (the
@@ -51,56 +37,21 @@ public abstract class Multipart implemen
      * 
      * @return the multipart sub-type.
      */
-    public String getSubType() {
-        return subType;
-    }
-
-    /**
-     * Sets the multipart sub-type. E.g. <code>alternative</code> or
-     * <code>parallel</code>. See RFC 2045 for common sub-types and their
-     * meaning.
-     * 
-     * @param subType
-     *            the sub-type.
-     */
-    public void setSubType(String subType) {
-        this.subType = subType;
-    }
-
-    /**
-     * @see org.apache.james.mime4j.dom.Body#getParent()
-     */
-    public Entity getParent() {
-        return parent;
-    }
-
-    /**
-     * @see org.apache.james.mime4j.dom.Body#setParent(org.apache.james.mime4j.dom.Entity)
-     */
-    public void setParent(Entity parent) {
-        this.parent = parent;
-        for (Entity bodyPart : bodyParts) {
-            bodyPart.setParent(parent);
-        }
-    }
-
+    String getSubType();
+    
     /**
      * Returns the number of body parts.
      * 
      * @return number of <code>Entity</code> objects.
      */
-    public int getCount() {
-        return bodyParts.size();
-    }
+    int getCount();
 
     /**
      * Gets the list of body parts. The list is immutable.
      * 
      * @return the list of <code>Entity</code> objects.
      */
-    public List<Entity> getBodyParts() {
-        return Collections.unmodifiableList(bodyParts);
-    }
+    public List<Entity> getBodyParts();
 
     /**
      * Sets the list of body parts.
@@ -108,12 +59,7 @@ public abstract class Multipart implemen
      * @param bodyParts
      *            the new list of <code>Entity</code> objects.
      */
-    public void setBodyParts(List<Entity> bodyParts) {
-        this.bodyParts = bodyParts;
-        for (Entity bodyPart : bodyParts) {
-            bodyPart.setParent(parent);
-        }
-    }
+    void setBodyParts(List<Entity> bodyParts);
 
     /**
      * Adds a body part to the end of the list of body parts.
@@ -121,13 +67,7 @@ public abstract class Multipart implemen
      * @param bodyPart
      *            the body part.
      */
-    public void addBodyPart(Entity bodyPart) {
-        if (bodyPart == null)
-            throw new IllegalArgumentException();
-
-        bodyParts.add(bodyPart);
-        bodyPart.setParent(parent);
-    }
+    void addBodyPart(Entity bodyPart);
 
     /**
      * Inserts a body part at the specified position in the list of body parts.
@@ -140,13 +80,7 @@ public abstract class Multipart implemen
      *             if the index is out of range (index &lt; 0 || index &gt;
      *             getCount()).
      */
-    public void addBodyPart(Entity bodyPart, int index) {
-        if (bodyPart == null)
-            throw new IllegalArgumentException();
-
-        bodyParts.add(index, bodyPart);
-        bodyPart.setParent(parent);
-    }
+    void addBodyPart(Entity bodyPart, int index);
 
     /**
      * Removes the body part at the specified position in the list of body
@@ -159,11 +93,7 @@ public abstract class Multipart implemen
      *             if the index is out of range (index &lt; 0 || index &gt;=
      *             getCount()).
      */
-    public Entity removeBodyPart(int index) {
-        Entity bodyPart = bodyParts.remove(index);
-        bodyPart.setParent(null);
-        return bodyPart;
-    }
+    Entity removeBodyPart(int index);
 
     /**
      * Replaces the body part at the specified position in the list of body
@@ -178,27 +108,14 @@ public abstract class Multipart implemen
      *             if the index is out of range (index &lt; 0 || index &gt;=
      *             getCount()).
      */
-    public Entity replaceBodyPart(Entity bodyPart, int index) {
-        if (bodyPart == null)
-            throw new IllegalArgumentException();
-
-        Entity replacedEntity = bodyParts.set(index, bodyPart);
-        if (bodyPart == replacedEntity)
-            throw new IllegalArgumentException(
-                    "Cannot replace body part with itself");
-
-        bodyPart.setParent(parent);
-        replacedEntity.setParent(null);
-
-        return replacedEntity;
-    }
+    Entity replaceBodyPart(Entity bodyPart, int index);
 
     /**
      * Gets the preamble or null if the message has no preamble.
      * 
      * @return the preamble.
      */
-    public abstract String getPreamble();
+    String getPreamble();
 
     /**
      * Sets the preamble with a value or null to remove the preamble.
@@ -206,14 +123,14 @@ public abstract class Multipart implemen
      * @param preamble
      *            the preamble.
      */
-    public abstract void setPreamble(String preamble);
-
+    void setPreamble(String preamble);
+    
     /**
      * Gets the epilogue or null if the message has no epilogue
      * 
      * @return the epilogue.
      */
-    public abstract String getEpilogue();
+    String getEpilogue();
 
     /**
      * Sets the epilogue value, or remove it if the value passed is null.
@@ -221,18 +138,6 @@ public abstract class Multipart implemen
      * @param epilogue
      *            the epilogue.
      */
-    public abstract void setEpilogue(String epilogue);
-
-    /**
-     * Disposes of the BodyParts of this Multipart. Note that the dispose call
-     * does not get forwarded to the parent entity of this Multipart.
-     * 
-     * @see org.apache.james.mime4j.dom.Disposable#dispose()
-     */
-    public void dispose() {
-        for (Entity bodyPart : bodyParts) {
-            bodyPart.dispose();
-        }
-    }
-
+    void setEpilogue(String epilogue);
+    
 }

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/field/address/parser/AddressBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/field/address/parser/AddressBuilder.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/field/address/parser/AddressBuilder.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/field/address/parser/AddressBuilder.java Mon Jan 17 14:57:12 2011
@@ -59,11 +59,7 @@ public class AddressBuilder {
             throws ParseException {
         AddressListParser parser = new AddressListParser(new StringReader(
                 rawAddressList));
-        try {
-            return Builder.getInstance().buildAddressList(parser.parseAddressList(), monitor);
-        } catch (RuntimeException e) {
-            throw new ParseException(e.getMessage());
-        }
+        return Builder.getInstance().buildAddressList(parser.parseAddressList(), monitor);
     }
 
     public static AddressList parseAddressList(String rawAddressList) throws ParseException {

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/BodyPart.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/BodyPart.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/BodyPart.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/BodyPart.java Mon Jan 17 14:57:12 2011
@@ -24,7 +24,6 @@ import java.util.Map;
 
 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.SingleBody;
@@ -39,7 +38,7 @@ import org.apache.james.mime4j.util.Mime
 /**
  * Represents a MIME body part  (see RFC 2045).
  */
-public class BodyPart extends Entity {
+public class BodyPart extends EntityBase {
 
     /**
      * Creates a new empty <code>BodyPart</code>.
@@ -66,7 +65,7 @@ public class BodyPart extends Entity {
      */
     public BodyPart(Entity other) {
         if (other.getHeader() != null) {
-            setHeader(new Header(other.getHeader()));
+            setHeader(new HeaderImpl(other.getHeader()));
         }
 
         if (other.getBody() != null) {

Copied: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/EntityBase.java (from r1059932, james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Entity.java)
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/EntityBase.java?p2=james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/EntityBase.java&p1=james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Entity.java&r1=1059932&r2=1059942&rev=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Entity.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/EntityBase.java Mon Jan 17 14:57:12 2011
@@ -17,13 +17,20 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mime4j.dom;
+package org.apache.james.mime4j.message;
 
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.james.mime4j.dom.Body;
+import org.apache.james.mime4j.dom.Disposable;
+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.field.ContentDispositionField;
 import org.apache.james.mime4j.dom.field.ContentTransferEncodingField;
 import org.apache.james.mime4j.dom.field.ContentTypeField;
@@ -33,7 +40,7 @@ import org.apache.james.mime4j.dom.field
 /**
  * MIME entity. An entity has a header and a body (see RFC 2045).
  */
-public abstract class Entity implements Disposable {
+public abstract class EntityBase implements Entity {
     private Header header = null;
     private Body body = null;
     private Entity parent = null;
@@ -42,7 +49,7 @@ public abstract class Entity implements 
      * Creates a new <code>Entity</code>. Typically invoked implicitly by a
      * subclass constructor.
      */
-    protected Entity() {
+    protected EntityBase() {
     }
 
     /**
@@ -502,7 +509,7 @@ public abstract class Entity implements 
      */
     Header obtainHeader() {
         if (header == null) {
-            header = new Header();
+            header = new HeaderImpl();
         }
         return header;
     }

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/EntityBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/EntityBuilder.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/EntityBuilder.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/EntityBuilder.java Mon Jan 17 14:57:12 2011
@@ -98,7 +98,7 @@ public class EntityBuilder implements Co
      * @see org.apache.james.mime4j.parser.ContentHandler#startHeader()
      */
     public void startHeader() throws MimeException {
-        stack.push(new Header());
+        stack.push(new HeaderImpl());
     }
     
     /**

Copied: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/HeaderBase.java (from r1059932, james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Header.java)
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/HeaderBase.java?p2=james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/HeaderBase.java&p1=james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Header.java&r1=1059932&r2=1059942&rev=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Header.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/HeaderBase.java Mon Jan 17 14:57:12 2011
@@ -17,7 +17,7 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mime4j.dom;
+package org.apache.james.mime4j.message;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -26,12 +26,13 @@ import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.james.mime4j.dom.Header;
 import org.apache.james.mime4j.dom.field.Field;
 
 /**
  * The header of an entity (see RFC 2045).
  */
-public class Header implements Iterable<Field> {
+public abstract class HeaderBase implements Header {
 
     private List<Field> fields = new LinkedList<Field>();
     private Map<String, List<Field>> fieldMap = new HashMap<String, List<Field>>();
@@ -39,7 +40,7 @@ public class Header implements Iterable<
     /**
      * Creates a new empty <code>Header</code>.
      */
-    public Header() {
+    public HeaderBase() {
     }
 
     /**
@@ -52,8 +53,8 @@ public class Header implements Iterable<
      * @param other
      *            header to copy.
      */
-    public Header(Header other) {
-        for (Field otherField : other.fields) {
+    public HeaderBase(Header other) {
+        for (Field otherField : other.getFields()) {
             addField(otherField);
         }
     }

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/HeaderImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/HeaderImpl.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/HeaderImpl.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/HeaderImpl.java Mon Jan 17 14:57:12 2011
@@ -35,7 +35,7 @@ import org.apache.james.mime4j.stream.Ra
 /**
  * The header of an entity (see RFC 2045).
  */
-public class HeaderImpl extends Header {
+public class HeaderImpl extends HeaderBase {
 
     /**
      * Creates a new empty <code>Header</code>.

Copied: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageBase.java (from r1059932, james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Message.java)
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageBase.java?p2=james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageBase.java&p1=james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Message.java&r1=1059932&r2=1059942&rev=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Message.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageBase.java Mon Jan 17 14:57:12 2011
@@ -17,16 +17,16 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mime4j.dom;
+package org.apache.james.mime4j.message;
 
-import java.io.IOException;
-import java.io.OutputStream;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.TimeZone;
 
+import org.apache.james.mime4j.dom.Header;
+import org.apache.james.mime4j.dom.Message;
 import org.apache.james.mime4j.dom.address.Address;
 import org.apache.james.mime4j.dom.address.AddressList;
 import org.apache.james.mime4j.dom.address.Mailbox;
@@ -39,19 +39,7 @@ import org.apache.james.mime4j.dom.field
 import org.apache.james.mime4j.dom.field.MailboxListField;
 import org.apache.james.mime4j.dom.field.UnstructuredField;
 
-public abstract class Message extends Entity implements Body {
-
-    /**
-     * Write the content to the given output stream using the
-     * {@link org.apache.james.mime4j.message.MessageWriter#DEFAULT default} message writer.
-     * 
-     * @param out
-     *            the output stream to write to.
-     * @throws IOException
-     *             in case of an I/O error
-     * @see org.apache.james.mime4j.message.MessageWriter
-     */
-    public abstract void writeTo(OutputStream out) throws IOException;
+public abstract class MessageBase extends EntityBase implements Message {
 
     /**
      * Returns the value of the <i>Message-ID</i> header field of this message

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java Mon Jan 17 14:57:12 2011
@@ -31,7 +31,6 @@ import org.apache.james.mime4j.MimeExcep
 import org.apache.james.mime4j.MimeIOException;
 import org.apache.james.mime4j.codec.DecodeMonitor;
 import org.apache.james.mime4j.dom.Body;
-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.SingleBody;
@@ -64,7 +63,7 @@ import org.apache.james.mime4j.util.Mime
  * Message msg = new Message(new FileInputStream(&quot;mime.msg&quot;));
  * </pre>
  */
-public class MessageImpl extends Message {
+public class MessageImpl extends MessageBase {
 
     /**
      * Creates a new empty <code>Message</code>.
@@ -92,7 +91,7 @@ public class MessageImpl extends Message
      */
     public MessageImpl(Message other) {
         if (other.getHeader() != null) {
-            setHeader(new Header(other.getHeader()));
+            setHeader(new HeaderImpl(other.getHeader()));
         }
 
         if (other.getBody() != null) {

Copied: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MultipartBase.java (from r1059932, james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Multipart.java)
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MultipartBase.java?p2=james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MultipartBase.java&p1=james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Multipart.java&r1=1059932&r2=1059942&rev=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/dom/Multipart.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MultipartBase.java Mon Jan 17 14:57:12 2011
@@ -17,12 +17,15 @@
  * under the License.                                           *
  ****************************************************************/
 
-package org.apache.james.mime4j.dom;
+package org.apache.james.mime4j.message;
 
 import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
 
+import org.apache.james.mime4j.dom.Entity;
+import org.apache.james.mime4j.dom.Multipart;
+
 /**
  * Represents a MIME multipart body (see RFC 2045).A multipart body has a
  * ordered list of body parts. The multipart body also has a preamble and
@@ -30,7 +33,7 @@ import java.util.List;
  * first body part while the epilogue consists of whatever characters come after
  * the last body part.
  */
-public abstract class Multipart implements Body {
+public abstract class MultipartBase implements Multipart {
 
     protected List<Entity> bodyParts = new LinkedList<Entity>();
     private Entity parent = null;
@@ -40,7 +43,7 @@ public abstract class Multipart implemen
     /**
      * Creates a new empty <code>Multipart</code> instance.
      */
-    public Multipart(String subType) {
+    public MultipartBase(String subType) {
         this.subType = subType;
     }
 

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MultipartImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MultipartImpl.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MultipartImpl.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/MultipartImpl.java Mon Jan 17 14:57:12 2011
@@ -33,7 +33,7 @@ import org.apache.james.mime4j.util.Cont
  * first body part while the epilogue consists of whatever characters come after
  * the last body part.
  */
-public class MultipartImpl extends Multipart {
+public class MultipartImpl extends MultipartBase {
 
     private ByteSequence preamble;
     private transient String preambleStrCache;

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/SimpleContentHandler.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/SimpleContentHandler.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/SimpleContentHandler.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/main/java/org/apache/james/mime4j/message/SimpleContentHandler.java Mon Jan 17 14:57:12 2011
@@ -61,7 +61,7 @@ public abstract class SimpleContentHandl
      */
     @Override
     public final void startHeader() {
-        currHeader = new Header();
+        currHeader = new HeaderImpl();
     }
 
     /**

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/CopyConstructorTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/CopyConstructorTest.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/CopyConstructorTest.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/CopyConstructorTest.java Mon Jan 17 14:57:12 2011
@@ -30,6 +30,7 @@ import org.apache.james.mime4j.dom.field
 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.MultipartImpl;
 
@@ -49,7 +50,7 @@ public class CopyConstructorTest extends
 
     public void testCopyMessage() throws Exception {
         MessageImpl parent = new MessageImpl();
-        Header header = new Header();
+        Header header = new HeaderImpl();
         Body body = new BodyFactory().textBody("test");
 
         MessageImpl original = new MessageImpl();
@@ -82,7 +83,7 @@ public class CopyConstructorTest extends
 
     public void testCopyBodyPart() throws Exception {
         MessageImpl parent = new MessageImpl();
-        Header header = new Header();
+        Header header = new HeaderImpl();
         Body body = new BodyFactory().textBody("test");
 
         BodyPart original = new BodyPart();
@@ -119,7 +120,7 @@ public class CopyConstructorTest extends
         MessageImpl parent = new MessageImpl();
         BodyPart bodyPart = new BodyPart();
 
-        Multipart original = new MultipartImpl("mixed");
+        MultipartImpl original = new MultipartImpl("mixed");
         original.setPreamble("preamble");
         original.setEpilogue("epilogue");
         original.setParent(parent);
@@ -149,7 +150,7 @@ public class CopyConstructorTest extends
         multipart.addBodyPart(bodyPart2);
 
         MessageImpl original = new MessageImpl();
-        original.setHeader(new Header());
+        original.setHeader(new HeaderImpl());
         original.setBody(multipart);
 
         MessageImpl copy = new MessageImpl(original);
@@ -173,12 +174,12 @@ public class CopyConstructorTest extends
         Field f2 = DefaultFieldParser.parse("name2: value");
         Field f3 = DefaultFieldParser.parse("name1: value2");
 
-        Header original = new Header();
+        Header original = new HeaderImpl();
         original.addField(f1);
         original.addField(f2);
         original.addField(f3);
 
-        Header copy = new Header(original);
+        Header copy = new HeaderImpl(original);
 
         // copy must have same fields as original
         assertEquals(Arrays.asList(f1, f2, f3), copy.getFields());

Modified: james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java Mon Jan 17 14:57:12 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/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java Mon Jan 17 14:57:12 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 <an...@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/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java Mon Jan 17 14:57:12 2011
@@ -42,6 +42,7 @@ import org.apache.james.mime4j.dom.addre
 import org.apache.james.mime4j.field.DefaultFieldParser;
 import org.apache.james.mime4j.field.address.parser.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.MultipartImpl;
 
@@ -54,11 +55,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"));
@@ -173,7 +174,7 @@ public class MessageTest extends TestCas
         assertNull(m.getMessageId());
 
         String id = "<ms...@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 +195,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 +220,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 +243,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 +265,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 +298,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 +336,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 +374,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 +412,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/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java (original)
+++ james/mime4j/branches/dom-api-refactoring/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java Mon Jan 17 14:57:12 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/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java
URL: http://svn.apache.org/viewvc/james/mime4j/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java?rev=1059942&r1=1059941&r2=1059942&view=diff
==============================================================================
--- james/mime4j/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java (original)
+++ james/mime4j/branches/dom-api-refactoring/examples/src/main/java/org/apache/james/mime4j/samples/transform/TransformMessage.java Mon Jan 17 14:57:12 2011
@@ -138,7 +138,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");