Removed mutators from DOM interfaces (Message, BodyPart, Multipart, etc) that are now provided by corresponding builders
git-svn-id: https://svn.apache.org/repos/asf/james/mime4j/trunk@1618036 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/dom/src/main/java/org/apache/james/mime4j/dom/Message.java b/dom/src/main/java/org/apache/james/mime4j/dom/Message.java
index 05182f2..17132e4 100644
--- a/dom/src/main/java/org/apache/james/mime4j/dom/Message.java
+++ b/dom/src/main/java/org/apache/james/mime4j/dom/Message.java
@@ -19,11 +19,8 @@
package org.apache.james.mime4j.dom;
-import java.util.Collection;
import java.util.Date;
-import java.util.TimeZone;
-import org.apache.james.mime4j.dom.address.Address;
import org.apache.james.mime4j.dom.address.AddressList;
import org.apache.james.mime4j.dom.address.Mailbox;
import org.apache.james.mime4j.dom.address.MailboxList;
@@ -42,17 +39,6 @@
String getMessageId();
/**
- * 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.
- */
- void createMessageId(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.
*
@@ -61,18 +47,6 @@
String getSubject();
/**
- * 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.
- */
- void setSubject(String 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.
*
@@ -81,30 +55,6 @@
Date 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.
- */
- void setDate(Date date);
-
- /**
- * 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.
- */
- void setDate(Date date, TimeZone 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.
@@ -114,16 +64,6 @@
Mailbox getSender();
/**
- * 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.
- */
- void setSender(Mailbox 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.
@@ -133,36 +73,6 @@
MailboxList getFrom();
/**
- * 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.
- */
- void setFrom(Mailbox 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.
- */
- void setFrom(Mailbox... 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.
- */
- void setFrom(Collection<Mailbox> 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.
@@ -172,36 +82,6 @@
AddressList getTo();
/**
- * 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.
- */
- void setTo(Address 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.
- */
- void setTo(Address... 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.
- */
- void setTo(Collection<? extends Address> 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.
@@ -211,36 +91,6 @@
AddressList getCc();
/**
- * 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.
- */
- void setCc(Address 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.
- */
- void setCc(Address... 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.
- */
- void setCc(Collection<? extends Address> 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.
@@ -250,36 +100,6 @@
AddressList getBcc();
/**
- * 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.
- */
- void setBcc(Address 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.
- */
- void setBcc(Address... 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.
- */
- void setBcc(Collection<? extends Address> 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.
@@ -288,34 +108,4 @@
*/
AddressList getReplyTo();
- /**
- * 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.
- */
- void setReplyTo(Address 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.
- */
- void setReplyTo(Address... 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.
- */
- void setReplyTo(Collection<? extends Address> replyTo);
-
}
diff --git a/dom/src/main/java/org/apache/james/mime4j/message/AbstractEntity.java b/dom/src/main/java/org/apache/james/mime4j/message/AbstractEntity.java
index 19cfa04..d050059 100644
--- a/dom/src/main/java/org/apache/james/mime4j/message/AbstractEntity.java
+++ b/dom/src/main/java/org/apache/james/mime4j/message/AbstractEntity.java
@@ -19,18 +19,10 @@
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;
@@ -131,145 +123,11 @@
return body;
}
- /**
- * Sets the specified message as body of this entity and the content type to
- * "message/rfc822". 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 "text/plain". 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(java.io.InputStream, 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. "plain", "html" or
- * "xml").
- */
- 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
- * ("type/subtype").
- */
- 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
- * ("type/subtype").
- * @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));
- }
-
- /**
- * 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
- * Content-Type field is set for this <code>Entity</code>.
- *
- * @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);
+ ContentTypeField childType = getContentTypeField();
+ Entity parent = getParent();
+ ContentTypeField parentType = parent != null ? (ContentTypeField) (parent).getHeader().getField(FieldName.CONTENT_TYPE) : null;
+ return calcMimeType(childType, parentType);
}
private ContentTypeField getContentTypeField() {
@@ -298,18 +156,6 @@
}
/**
- * 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>.
*
@@ -325,91 +171,6 @@
}
/**
- * 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>.
*
@@ -425,51 +186,6 @@
}
/**
- * 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
@@ -531,21 +247,6 @@
return (F) header.getField(fieldName);
}
- 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);
diff --git a/dom/src/main/java/org/apache/james/mime4j/message/AbstractMessage.java b/dom/src/main/java/org/apache/james/mime4j/message/AbstractMessage.java
index f043a06..170dd9f 100644
--- a/dom/src/main/java/org/apache/james/mime4j/message/AbstractMessage.java
+++ b/dom/src/main/java/org/apache/james/mime4j/message/AbstractMessage.java
@@ -19,15 +19,9 @@
package org.apache.james.mime4j.message;
-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;
import org.apache.james.mime4j.dom.address.MailboxList;
@@ -36,7 +30,6 @@
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.ParsedField;
import org.apache.james.mime4j.dom.field.UnstructuredField;
import org.apache.james.mime4j.stream.Field;
@@ -60,23 +53,6 @@
}
/**
- * 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));
- }
-
- protected abstract ParsedField 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.
*
@@ -91,26 +67,6 @@
}
/**
- * 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.
*
@@ -125,40 +81,6 @@
}
/**
- * 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.
@@ -170,18 +92,6 @@
}
/**
- * 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.
@@ -193,42 +103,6 @@
}
/**
- * 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.
@@ -240,42 +114,6 @@
}
/**
- * 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<? extends 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.
@@ -287,42 +125,6 @@
}
/**
- * 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<? extends 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.
@@ -334,42 +136,6 @@
}
/**
- * 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<? extends 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.
@@ -380,42 +146,6 @@
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<? extends Address> replyTo) {
- setAddressList(FieldName.REPLY_TO, replyTo);
- }
-
private Mailbox getMailbox(String fieldName) {
MailboxField field = obtainField(fieldName);
if (field == null)
@@ -424,16 +154,6 @@
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)
@@ -442,26 +162,6 @@
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)
@@ -470,35 +170,4 @@
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<? extends 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<? extends 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);
-
-
}
diff --git a/dom/src/main/java/org/apache/james/mime4j/message/BodyPart.java b/dom/src/main/java/org/apache/james/mime4j/message/BodyPart.java
index 9f6ec2a..f1f945a 100644
--- a/dom/src/main/java/org/apache/james/mime4j/message/BodyPart.java
+++ b/dom/src/main/java/org/apache/james/mime4j/message/BodyPart.java
@@ -19,16 +19,10 @@
package org.apache.james.mime4j.message;
-import java.util.Date;
-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.field.ContentTransferEncodingFieldImpl;
import org.apache.james.mime4j.field.ContentTypeFieldImpl;
-import org.apache.james.mime4j.field.Fields;
-import org.apache.james.mime4j.util.MimeUtil;
/**
* A MIME body part (as defined in RFC 2045).
@@ -42,37 +36,6 @@
}
@Override
- protected String newUniqueBoundary() {
- return MimeUtil.createUniqueBoundary();
- }
-
- @Override
- protected ContentDispositionField newContentDisposition(
- String dispositionType, String filename, long size,
- Date creationDate, Date modificationDate, Date readDate) {
- return Fields.contentDisposition(dispositionType, filename, size,
- creationDate, modificationDate, readDate);
- }
-
- @Override
- protected ContentDispositionField newContentDisposition(
- String dispositionType, Map<String, String> parameters) {
- return Fields.contentDisposition(dispositionType, parameters);
- }
-
- @Override
- protected ContentTypeField newContentType(String mimeType,
- Map<String, String> parameters) {
- return Fields.contentType(mimeType, parameters);
- }
-
- @Override
- protected ContentTransferEncodingField newContentTransferEncoding(
- String contentTransferEncoding) {
- return Fields.contentTransferEncoding(contentTransferEncoding);
- }
-
- @Override
protected String calcTransferEncoding(ContentTransferEncodingField f) {
return ContentTransferEncodingFieldImpl.getEncoding(f);
}
diff --git a/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java b/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
index e23abe5..cab7678 100644
--- a/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
+++ b/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
@@ -19,31 +19,16 @@
package org.apache.james.mime4j.message;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Map;
-import java.util.TimeZone;
-
import org.apache.james.mime4j.codec.DecodeMonitor;
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.Mailbox;
-import org.apache.james.mime4j.dom.field.AddressListField;
-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.DateTimeField;
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;
import org.apache.james.mime4j.field.ContentTransferEncodingFieldImpl;
import org.apache.james.mime4j.field.ContentTypeFieldImpl;
-import org.apache.james.mime4j.field.Fields;
import org.apache.james.mime4j.field.MimeVersionFieldLenientImpl;
import org.apache.james.mime4j.stream.RawField;
-import org.apache.james.mime4j.util.MimeUtil;
/**
* Default implementation of {@link Message}.
@@ -61,69 +46,6 @@
}
@Override
- protected String newUniqueBoundary() {
- return MimeUtil.createUniqueBoundary();
- }
-
- @Override
- protected UnstructuredField newMessageId(String hostname) {
- return Fields.generateMessageId(hostname);
- }
-
- @Override
- protected DateTimeField newDate(Date date, TimeZone zone) {
- return Fields.date(FieldName.DATE, date, zone);
- }
-
- @Override
- protected MailboxField newMailbox(String fieldName, Mailbox mailbox) {
- return Fields.mailbox(fieldName, mailbox);
- }
-
- @Override
- protected MailboxListField newMailboxList(String fieldName,
- Collection<Mailbox> mailboxes) {
- return Fields.mailboxList(fieldName, mailboxes);
- }
-
- @Override
- protected AddressListField newAddressList(String fieldName,
- Collection<? extends Address> addresses) {
- return Fields.addressList(fieldName, addresses);
- }
-
- @Override
- protected UnstructuredField newSubject(String subject) {
- return Fields.subject(subject);
- }
-
- @Override
- protected ContentDispositionField newContentDisposition(
- String dispositionType, String filename, long size,
- Date creationDate, Date modificationDate, Date readDate) {
- return Fields.contentDisposition(dispositionType, filename, size,
- creationDate, modificationDate, readDate);
- }
-
- @Override
- protected ContentDispositionField newContentDisposition(
- String dispositionType, Map<String, String> parameters) {
- return Fields.contentDisposition(dispositionType, parameters);
- }
-
- @Override
- protected ContentTypeField newContentType(String mimeType,
- Map<String, String> parameters) {
- return Fields.contentType(mimeType, parameters);
- }
-
- @Override
- protected ContentTransferEncodingField newContentTransferEncoding(
- String contentTransferEncoding) {
- return Fields.contentTransferEncoding(contentTransferEncoding);
- }
-
- @Override
protected String calcTransferEncoding(ContentTransferEncodingField f) {
return ContentTransferEncodingFieldImpl.getEncoding(f);
}
diff --git a/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java b/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java
index 70260d6..7900963 100644
--- a/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java
+++ b/dom/src/test/java/org/apache/james/mime4j/dom/EntityTest.java
@@ -83,26 +83,6 @@
}
@Test
- public void testSetContentDispositionType() throws Exception {
- BodyPart entity = new BodyPart();
-
- entity.setContentDisposition("attachment");
-
- Assert.assertEquals("attachment", entity.getHeader().getField(
- "Content-Disposition").getBody());
- }
-
- @Test
- public void testSetContentDispositionTypeFilename() throws Exception {
- BodyPart entity = new BodyPart();
-
- entity.setContentDisposition("attachment", "some file.dat");
-
- Assert.assertEquals("attachment; filename=\"some file.dat\"", entity
- .getHeader().getField("Content-Disposition").getBody());
- }
-
- @Test
public void testGetFilename() throws Exception {
BodyPart entity = new BodyPart();
@@ -116,19 +96,4 @@
Assert.assertEquals("some file.dat", entity.getFilename());
}
- @Test
- public void testSetFilename() throws Exception {
- BodyPart entity = new BodyPart();
-
- entity.setFilename("file name.ext");
-
- Assert.assertEquals("attachment; filename=\"file name.ext\"", entity
- .getHeader().getField("Content-Disposition").getBody());
-
- entity.setFilename(null);
-
- Assert.assertEquals("attachment", entity.getHeader().getField(
- "Content-Disposition").getBody());
- }
-
}
diff --git a/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java b/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java
index 857d722..d495a95 100644
--- a/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java
+++ b/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java
@@ -1,31 +1,38 @@
/****************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one *
- * or more contributor license agreements. See the NOTICE file *
- * distributed with this work for additional information *
- * regarding copyright ownership. The ASF licenses this file *
- * to you under the Apache License, Version 2.0 (the *
- * "License"); you may not use this file except in compliance *
- * with the License. You may obtain a copy of the License at *
- * *
- * http://www.apache.org/licenses/LICENSE-2.0 *
- * *
- * Unless required by applicable law or agreed to in writing, *
- * software distributed under the License is distributed on an *
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
- * KIND, either express or implied. See the License for the *
- * specific language governing permissions and limitations *
- * under the License. *
- ****************************************************************/
+* Licensed to the Apache Software Foundation (ASF) under one *
+* or more contributor license agreements. See the NOTICE file *
+* distributed with this work for additional information *
+* regarding copyright ownership. The ASF licenses this file *
+* to you under the Apache License, Version 2.0 (the *
+* "License"); you may not use this file except in compliance *
+* with the License. You may obtain a copy of the License at *
+* *
+* http://www.apache.org/licenses/LICENSE-2.0 *
+* *
+* Unless required by applicable law or agreed to in writing, *
+* software distributed under the License is distributed on an *
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+* KIND, either express or implied. See the License for the *
+* specific language governing permissions and limitations *
+* under the License. *
+****************************************************************/
package org.apache.james.mime4j.dom;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.Date;
+import java.util.List;
+
import org.apache.commons.io.IOUtils;
-import org.apache.james.mime4j.dom.address.Group;
import org.apache.james.mime4j.dom.address.Mailbox;
import org.apache.james.mime4j.dom.field.FieldName;
import org.apache.james.mime4j.dom.field.MimeVersionField;
import org.apache.james.mime4j.field.DefaultFieldParser;
-import org.apache.james.mime4j.field.address.AddressBuilder;
import org.apache.james.mime4j.message.BodyPart;
import org.apache.james.mime4j.message.DefaultMessageBuilder;
import org.apache.james.mime4j.message.DefaultMessageWriter;
@@ -36,17 +43,6 @@
import org.junit.Before;
import org.junit.Test;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
-import java.util.TimeZone;
-
public class MessageTest {
private Header headerTextPlain = null;
private Header headerMessageRFC822 = null;
@@ -203,17 +199,6 @@
}
@Test
- public void testCreateMessageId() throws Exception {
- MessageImpl m = new MessageImpl();
- m.createMessageId("hostname");
-
- String id = m.getMessageId();
- Assert.assertNotNull(id);
- Assert.assertTrue(id.startsWith("<Mime4j."));
- Assert.assertTrue(id.endsWith("@hostname>"));
- }
-
- @Test
public void testGetSubject() throws Exception {
MessageImpl m = new MessageImpl();
Assert.assertNull(m.getSubject());
@@ -229,19 +214,6 @@
}
@Test
- public void testSetSubject() throws Exception {
- MessageImpl m = new MessageImpl();
-
- m.setSubject("Semmelbr\366sel");
- Assert.assertEquals("Semmelbr\366sel", m.getSubject());
- Assert.assertEquals("=?ISO-8859-1?Q?Semmelbr=F6sel?=", m.getHeader().getField(
- "Subject").getBody());
-
- m.setSubject(null);
- Assert.assertNull(m.getHeader().getField("Subject"));
- }
-
- @Test
public void testGetDate() throws Exception {
MessageImpl m = new MessageImpl();
Assert.assertNull(m.getDate());
@@ -254,19 +226,6 @@
}
@Test
- public void testSetDate() throws Exception {
- MessageImpl m = new MessageImpl();
-
- m.setDate(new Date(86400000), TimeZone.getTimeZone("GMT"));
- Assert.assertEquals(new Date(86400000), m.getDate());
- Assert.assertEquals("Fri, 2 Jan 1970 00:00:00 +0000", m.getHeader().getField(
- "Date").getBody());
-
- m.setDate(null);
- Assert.assertNull(m.getHeader().getField("Date"));
- }
-
- @Test
public void testGetSender() throws Exception {
MessageImpl m = new MessageImpl();
Assert.assertNull(m.getSender());
@@ -279,18 +238,6 @@
}
@Test
- public void testSetSender() throws Exception {
- MessageImpl m = new MessageImpl();
-
- m.setSender(AddressBuilder.DEFAULT.parseMailbox("john.doe@example.net"));
- Assert.assertEquals("john.doe@example.net", m.getHeader().getField("Sender")
- .getBody());
-
- m.setSender(null);
- Assert.assertNull(m.getHeader().getField("Sender"));
- }
-
- @Test
public void testGetFrom() throws Exception {
MessageImpl m = new MessageImpl();
Assert.assertNull(m.getFrom());
@@ -303,29 +250,6 @@
}
@Test
- public void testSetFrom() throws Exception {
- MessageImpl m = new MessageImpl();
-
- Mailbox mailbox1 = AddressBuilder.DEFAULT.parseMailbox("john.doe@example.net");
- Mailbox mailbox2 = AddressBuilder.DEFAULT.parseMailbox("jane.doe@example.net");
-
- m.setFrom(mailbox1);
- Assert.assertEquals("john.doe@example.net", m.getHeader().getField("From")
- .getBody());
-
- m.setFrom(mailbox1, mailbox2);
- Assert.assertEquals("john.doe@example.net, jane.doe@example.net", m
- .getHeader().getField("From").getBody());
-
- m.setFrom(Arrays.asList(mailbox1, mailbox2));
- Assert.assertEquals("john.doe@example.net, jane.doe@example.net", m
- .getHeader().getField("From").getBody());
-
- m.setFrom((Mailbox) null);
- Assert.assertNull(m.getHeader().getField("From"));
- }
-
- @Test
public void testGetTo() throws Exception {
MessageImpl m = new MessageImpl();
Assert.assertNull(m.getTo());
@@ -339,33 +263,6 @@
}
@Test
- public void testSetTo() throws Exception {
- MessageImpl m = new MessageImpl();
-
- Mailbox mailbox1 = AddressBuilder.DEFAULT.parseMailbox("john.doe@example.net");
- Mailbox mailbox2 = AddressBuilder.DEFAULT.parseMailbox("jane.doe@example.net");
- Group group = new Group("Does", mailbox1, mailbox2);
- Mailbox mailbox3 = AddressBuilder.DEFAULT.parseMailbox("Mary Smith <mary@example.net>");
-
- m.setTo(group);
- Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;", m
- .getHeader().getField("To").getBody());
-
- m.setTo(group, mailbox3);
- Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
- + "Mary Smith <mary@example.net>", m.getHeader().getField("To")
- .getBody());
-
- m.setTo(Arrays.asList(group, mailbox3));
- Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
- + "Mary Smith <mary@example.net>", m.getHeader().getField("To")
- .getBody());
-
- m.setTo((Mailbox) null);
- Assert.assertNull(m.getHeader().getField("To"));
- }
-
- @Test
public void testGetCc() throws Exception {
MessageImpl m = new MessageImpl();
Assert.assertNull(m.getCc());
@@ -379,33 +276,6 @@
}
@Test
- public void testSetCc() throws Exception {
- MessageImpl m = new MessageImpl();
-
- Mailbox mailbox1 = AddressBuilder.DEFAULT.parseMailbox("john.doe@example.net");
- Mailbox mailbox2 = AddressBuilder.DEFAULT.parseMailbox("jane.doe@example.net");
- Group group = new Group("Does", mailbox1, mailbox2);
- Mailbox mailbox3 = AddressBuilder.DEFAULT.parseMailbox("Mary Smith <mary@example.net>");
-
- m.setCc(group);
- Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;", m
- .getHeader().getField("Cc").getBody());
-
- m.setCc(group, mailbox3);
- Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
- + "Mary Smith <mary@example.net>", m.getHeader().getField("Cc")
- .getBody());
-
- m.setCc(Arrays.asList(group, mailbox3));
- Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
- + "Mary Smith <mary@example.net>", m.getHeader().getField("Cc")
- .getBody());
-
- m.setCc((Mailbox) null);
- Assert.assertNull(m.getHeader().getField("Cc"));
- }
-
- @Test
public void testGetBcc() throws Exception {
MessageImpl m = new MessageImpl();
Assert.assertNull(m.getBcc());
@@ -419,33 +289,6 @@
}
@Test
- public void testSetBcc() throws Exception {
- MessageImpl m = new MessageImpl();
-
- Mailbox mailbox1 = AddressBuilder.DEFAULT.parseMailbox("john.doe@example.net");
- Mailbox mailbox2 = AddressBuilder.DEFAULT.parseMailbox("jane.doe@example.net");
- Group group = new Group("Does", mailbox1, mailbox2);
- Mailbox mailbox3 = AddressBuilder.DEFAULT.parseMailbox("Mary Smith <mary@example.net>");
-
- m.setBcc(group);
- Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;", m
- .getHeader().getField("Bcc").getBody());
-
- m.setBcc(group, mailbox3);
- Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
- + "Mary Smith <mary@example.net>", m.getHeader()
- .getField("Bcc").getBody());
-
- m.setBcc(Arrays.asList(group, mailbox3));
- Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
- + "Mary Smith <mary@example.net>", m.getHeader()
- .getField("Bcc").getBody());
-
- m.setBcc((Mailbox) null);
- Assert.assertNull(m.getHeader().getField("Bcc"));
- }
-
- @Test
public void testGetReplyTo() throws Exception {
MessageImpl m = new MessageImpl();
Assert.assertNull(m.getReplyTo());
@@ -459,33 +302,6 @@
}
@Test
- public void testSetReplyTo() throws Exception {
- MessageImpl m = new MessageImpl();
-
- Mailbox mailbox1 = AddressBuilder.DEFAULT.parseMailbox("john.doe@example.net");
- Mailbox mailbox2 = AddressBuilder.DEFAULT.parseMailbox("jane.doe@example.net");
- Group group = new Group("Does", mailbox1, mailbox2);
- Mailbox mailbox3 = AddressBuilder.DEFAULT.parseMailbox("Mary Smith <mary@example.net>");
-
- m.setReplyTo(group);
- Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;", m
- .getHeader().getField("Reply-To").getBody());
-
- m.setReplyTo(group, mailbox3);
- Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
- + "Mary Smith <mary@example.net>", m.getHeader().getField(
- "Reply-To").getBody());
-
- m.setReplyTo(Arrays.asList(group, mailbox3));
- Assert.assertEquals("Does: john.doe@example.net, jane.doe@example.net;, "
- + "Mary Smith <mary@example.net>", m.getHeader().getField(
- "Reply-To").getBody());
-
- m.setReplyTo((Mailbox) null);
- Assert.assertNull(m.getHeader().getField("Reply-To"));
- }
-
- @Test
public void testDisposeGetsPropagatedToBody() throws Exception {
DummyBody body1 = new DummyBody();
BodyPart part1 = new BodyPart();