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/07/11 21:48:57 UTC
svn commit: r1145308 [6/7] - in /james/mime4j/trunk:
core/src/main/java/org/apache/james/mime4j/
core/src/main/java/org/apache/james/mime4j/codec/
core/src/main/java/org/apache/james/mime4j/io/
core/src/main/java/org/apache/james/mime4j/parser/ core/sr...
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/AbstractHeader.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/AbstractHeader.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/AbstractHeader.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/AbstractHeader.java Mon Jul 11 19:48:50 2011
@@ -36,7 +36,7 @@ public abstract class AbstractHeader imp
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>.
*/
@@ -49,7 +49,7 @@ public abstract class AbstractHeader imp
* 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.
*/
@@ -61,7 +61,7 @@ public abstract class AbstractHeader imp
/**
* Adds a field to the end of the list of fields.
- *
+ *
* @param field the field to add.
*/
public void addField(Field field) {
@@ -73,11 +73,11 @@ public abstract class AbstractHeader imp
values.add(field);
fields.add(field);
}
-
+
/**
* Gets the fields of this header. The returned list will not be
* modifiable.
- *
+ *
* @return the list of <code>Field</code> objects.
*/
public List<Field> getFields() {
@@ -87,7 +87,7 @@ public abstract class AbstractHeader imp
/**
* Gets a <code>Field</code> given a field name. If there are multiple
* such fields defined in this header the first one will be returned.
- *
+ *
* @param name the field name (e.g. From, Subject).
* @return the field or <code>null</code> if none found.
*/
@@ -98,10 +98,10 @@ public abstract class AbstractHeader imp
}
return null;
}
-
+
/**
- * Gets all <code>Field</code>s having the specified field name.
- *
+ * Gets all <code>Field</code>s having the specified field name.
+ *
* @param name the field name (e.g. From, Subject).
* @return the list of fields.
*/
@@ -119,7 +119,7 @@ public abstract class AbstractHeader imp
/**
* Returns an iterator over the list of fields of this header.
- *
+ *
* @return an iterator.
*/
public Iterator<Field> iterator() {
@@ -128,7 +128,7 @@ public abstract class AbstractHeader imp
/**
* Removes all <code>Field</code>s having the specified field name.
- *
+ *
* @param name
* the field name (e.g. From, Subject).
* @return number of fields removed.
@@ -151,13 +151,13 @@ public abstract class AbstractHeader imp
/**
* Sets or replaces a field. This method is useful for header fields such as
* Subject or Message-ID that should not occur more than once in a message.
- *
+ *
* If this <code>Header</code> does not already contain a header field of
* the same name as the given field then it is added to the end of the list
* of fields (same behavior as {@link #addField(Field)}). Otherwise the
* first occurrence of a field with the same name is replaced by the given
* field and all further occurrences are removed.
- *
+ *
* @param field the field to set.
*/
public void setField(Field field) {
@@ -189,7 +189,7 @@ public abstract class AbstractHeader imp
/**
* Return Header Object as String representation. Each headerline is
* seperated by "\r\n"
- *
+ *
* @return headers
*/
@Override
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/AbstractMessage.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/AbstractMessage.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/AbstractMessage.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/AbstractMessage.java Mon Jul 11 19:48:50 2011
@@ -45,7 +45,7 @@ public abstract class AbstractMessage ex
/**
* Returns the value of the <i>Message-ID</i> header field of this message
* or <code>null</code> if it is not present.
- *
+ *
* @return the identifier of this message.
*/
public String getMessageId() {
@@ -60,7 +60,7 @@ public abstract class AbstractMessage ex
* 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.
@@ -76,7 +76,7 @@ public abstract class AbstractMessage ex
/**
* Returns the (decoded) value of the <i>Subject</i> header field of this
* message or <code>null</code> if it is not present.
- *
+ *
* @return the subject of this message.
*/
public String getSubject() {
@@ -92,7 +92,7 @@ public abstract class AbstractMessage ex
* 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.
@@ -110,7 +110,7 @@ public abstract class AbstractMessage ex
/**
* Returns the value of the <i>Date</i> header field of this message as
* <code>Date</code> object or <code>null</code> if it is not present.
- *
+ *
* @return the date of this message.
*/
public Date getDate() {
@@ -125,7 +125,7 @@ public abstract class AbstractMessage ex
* 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.
@@ -138,7 +138,7 @@ public abstract class AbstractMessage ex
* 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.
@@ -159,7 +159,7 @@ public abstract class AbstractMessage ex
* Returns the value of the <i>Sender</i> header field of this message as
* <code>Mailbox</code> object or <code>null</code> if it is not
* present.
- *
+ *
* @return the sender of this message.
*/
public Mailbox getSender() {
@@ -169,7 +169,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -182,7 +182,7 @@ public abstract class AbstractMessage ex
* Returns the value of the <i>From</i> header field of this message as
* <code>MailboxList</code> object or <code>null</code> if it is not
* present.
- *
+ *
* @return value of the from field of this message.
*/
public MailboxList getFrom() {
@@ -192,7 +192,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -204,7 +204,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -216,7 +216,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -229,7 +229,7 @@ public abstract class AbstractMessage ex
* Returns the value of the <i>To</i> header field of this message as
* <code>AddressList</code> object or <code>null</code> if it is not
* present.
- *
+ *
* @return value of the to field of this message.
*/
public AddressList getTo() {
@@ -239,7 +239,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -251,7 +251,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -263,7 +263,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -276,7 +276,7 @@ public abstract class AbstractMessage ex
* Returns the value of the <i>Cc</i> header field of this message as
* <code>AddressList</code> object or <code>null</code> if it is not
* present.
- *
+ *
* @return value of the cc field of this message.
*/
public AddressList getCc() {
@@ -286,7 +286,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -298,7 +298,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -310,7 +310,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -323,7 +323,7 @@ public abstract class AbstractMessage ex
* Returns the value of the <i>Bcc</i> header field of this message as
* <code>AddressList</code> object or <code>null</code> if it is not
* present.
- *
+ *
* @return value of the bcc field of this message.
*/
public AddressList getBcc() {
@@ -333,7 +333,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -345,7 +345,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -357,7 +357,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -370,7 +370,7 @@ public abstract class AbstractMessage ex
* Returns the value of the <i>Reply-To</i> header field of this message as
* <code>AddressList</code> object or <code>null</code> if it is not
* present.
- *
+ *
* @return value of the reply to field of this message.
*/
public AddressList getReplyTo() {
@@ -380,7 +380,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -392,7 +392,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -404,7 +404,7 @@ public abstract class AbstractMessage ex
/**
* 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.
@@ -497,5 +497,5 @@ public abstract class AbstractMessage ex
protected abstract MailboxListField newMailboxList(String fieldName, Collection<Mailbox> mailboxes);
-
-}
\ No newline at end of file
+
+}
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/AbstractMultipart.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/AbstractMultipart.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/AbstractMultipart.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/AbstractMultipart.java Mon Jul 11 19:48:50 2011
@@ -51,7 +51,7 @@ public abstract class AbstractMultipart
* Gets the multipart sub-type. E.g. <code>alternative</code> (the
* default) or <code>parallel</code>. See RFC 2045 for common sub-types
* and their meaning.
- *
+ *
* @return the multipart sub-type.
*/
public String getSubType() {
@@ -62,7 +62,7 @@ public abstract class AbstractMultipart
* 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.
*/
@@ -89,7 +89,7 @@ public abstract class AbstractMultipart
/**
* Returns the number of body parts.
- *
+ *
* @return number of <code>Entity</code> objects.
*/
public int getCount() {
@@ -98,7 +98,7 @@ public abstract class AbstractMultipart
/**
* Gets the list of body parts. The list is immutable.
- *
+ *
* @return the list of <code>Entity</code> objects.
*/
public List<Entity> getBodyParts() {
@@ -107,7 +107,7 @@ public abstract class AbstractMultipart
/**
* Sets the list of body parts.
- *
+ *
* @param bodyParts
* the new list of <code>Entity</code> objects.
*/
@@ -120,7 +120,7 @@ public abstract class AbstractMultipart
/**
* Adds a body part to the end of the list of body parts.
- *
+ *
* @param bodyPart
* the body part.
*/
@@ -134,7 +134,7 @@ public abstract class AbstractMultipart
/**
* Inserts a body part at the specified position in the list of body parts.
- *
+ *
* @param bodyPart
* the body part.
* @param index
@@ -154,7 +154,7 @@ public abstract class AbstractMultipart
/**
* Removes the body part at the specified position in the list of body
* parts.
- *
+ *
* @param index
* index of the body part to be removed.
* @return the removed body part.
@@ -171,7 +171,7 @@ public abstract class AbstractMultipart
/**
* Replaces the body part at the specified position in the list of body
* parts with the specified body part.
- *
+ *
* @param bodyPart
* body part to be stored at the specified position.
* @param index
@@ -198,14 +198,14 @@ public abstract class AbstractMultipart
/**
* Gets the preamble or null if the message has no preamble.
- *
+ *
* @return the preamble.
*/
public abstract String getPreamble();
/**
* Sets the preamble with a value or null to remove the preamble.
- *
+ *
* @param preamble
* the preamble.
*/
@@ -213,14 +213,14 @@ public abstract class AbstractMultipart
/**
* Gets the epilogue or null if the message has no epilogue
- *
+ *
* @return the epilogue.
*/
public abstract String getEpilogue();
/**
* Sets the epilogue value, or remove it if the value passed is null.
- *
+ *
* @param epilogue
* the epilogue.
*/
@@ -229,7 +229,7 @@ public abstract class AbstractMultipart
/**
* 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() {
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBinaryBody.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBinaryBody.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBinaryBody.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBinaryBody.java Mon Jul 11 19:48:50 2011
@@ -28,20 +28,20 @@ import org.apache.james.mime4j.dom.Binar
class BasicBinaryBody extends BinaryBody {
private final byte[] content;
-
+
BasicBinaryBody(final byte[] content) {
super();
this.content = content;
}
-
+
@Override
public InputStream getInputStream() throws IOException {
return new ByteArrayInputStream(this.content);
}
-
+
@Override
public BasicBinaryBody copy() {
return new BasicBinaryBody(this.content);
}
-
+
}
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBodyFactory.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBodyFactory.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBodyFactory.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicBodyFactory.java Mon Jul 11 19:48:50 2011
@@ -34,7 +34,7 @@ import org.apache.james.mime4j.util.Char
public class BasicBodyFactory implements BodyFactory {
private static String DEFAULT_CHARSET = CharsetUtil.DEFAULT_CHARSET.name();
-
+
public BinaryBody binaryBody(final InputStream is) throws IOException {
return new BasicBinaryBody(bufferContent(is));
}
@@ -42,7 +42,7 @@ public class BasicBodyFactory implements
public TextBody textBody(final InputStream is, final String mimeCharset) throws IOException {
return new BasicTextBody(bufferContent(is), mimeCharset);
}
-
+
private static byte[] bufferContent(final InputStream is) throws IOException {
if (is == null) {
throw new IllegalArgumentException("Input stream may not be null");
@@ -55,7 +55,7 @@ public class BasicBodyFactory implements
}
return buf.toByteArray();
}
-
+
public TextBody textBody(final String text, final String mimeCharset) throws UnsupportedEncodingException {
if (text == null) {
throw new IllegalArgumentException("Text may not be null");
@@ -66,7 +66,7 @@ public class BasicBodyFactory implements
public TextBody textBody(final String text) throws UnsupportedEncodingException {
return textBody(text, DEFAULT_CHARSET);
}
-
+
public BinaryBody binaryBody(final byte[] buf) {
return new BasicBinaryBody(buf);
}
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicTextBody.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicTextBody.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicTextBody.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BasicTextBody.java Mon Jul 11 19:48:50 2011
@@ -32,13 +32,13 @@ class BasicTextBody extends TextBody {
private final byte[] content;
private final String charset;
-
+
BasicTextBody(final byte[] content, final String charset) {
super();
this.content = content;
this.charset = charset;
}
-
+
@Override
public String getMimeCharset() {
return this.charset;
@@ -58,5 +58,5 @@ class BasicTextBody extends TextBody {
public SingleBody copy() {
return new BasicTextBody(this.content, this.charset);
}
-
+
}
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyFactory.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyFactory.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyFactory.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyFactory.java Mon Jul 11 19:48:50 2011
@@ -33,7 +33,7 @@ public interface BodyFactory {
/**
* Creates a {@link BinaryBody} that holds the content of the given input
* stream.
- *
+ *
* @param is
* input stream to create a message body from.
* @return a binary body.
@@ -51,7 +51,7 @@ public interface BodyFactory {
* calling {@link TextBody#getReader() getReader()} on the returned object.
* If the MIME charset has no corresponding Java charset or the Java charset
* cannot be used for decoding then "us-ascii" is used instead.
- *
+ *
* @param is
* input stream to create a message body from.
* @param mimeCharset
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyPart.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyPart.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyPart.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/BodyPart.java Mon Jul 11 19:48:50 2011
@@ -41,10 +41,10 @@ public class BodyPart extends AbstractEn
public BodyPart() {
}
- @Override
- protected String newUniqueBoundary() {
- return MimeUtil.createUniqueBoundary();
- }
+ @Override
+ protected String newUniqueBoundary() {
+ return MimeUtil.createUniqueBoundary();
+ }
@Override
protected ContentDispositionField newContentDisposition(
@@ -84,7 +84,7 @@ public class BodyPart extends AbstractEn
@Override
protected String calcCharset(ContentTypeField contentType) {
- return ContentTypeFieldImpl.getCharset(contentType);
+ return ContentTypeFieldImpl.getCharset(contentType);
}
}
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/DefaultMessageBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/DefaultMessageBuilder.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/DefaultMessageBuilder.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/DefaultMessageBuilder.java Mon Jul 11 19:48:50 2011
@@ -55,7 +55,7 @@ public class DefaultMessageBuilder imple
private boolean contentDecoding = true;
private boolean flatMode = false;
private DecodeMonitor monitor = null;
-
+
public DefaultMessageBuilder() {
super();
}
@@ -87,14 +87,14 @@ public class DefaultMessageBuilder imple
public void setFlatMode(boolean flatMode) {
this.flatMode = flatMode;
}
-
+
/**
* 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.
*/
@@ -111,7 +111,7 @@ public class DefaultMessageBuilder imple
* <code>Entity</code>. The <code>BodyPart</code> instance is initialized
* with copies of header and body of the specified <code>Entity</code>.
* The parent entity of the new body part is <code>null</code>.
- *
+ *
* @param other
* body part to copy.
* @throws UnsupportedOperationException
@@ -124,7 +124,7 @@ public class DefaultMessageBuilder imple
* {@link SingleBody}.
*/
public BodyPart copy(Entity other) {
- BodyPart copy = new BodyPart();
+ BodyPart copy = new BodyPart();
if (other.getHeader() != null) {
copy.setHeader(copy(other.getHeader()));
}
@@ -140,7 +140,7 @@ public class DefaultMessageBuilder imple
* initialized with copies of preamble, epilogue, sub type and the list of
* body parts of the specified <code>Multipart</code>. The parent entity
* of the new multipart is <code>null</code>.
- *
+ *
* @param other
* multipart to copy.
* @throws UnsupportedOperationException
@@ -162,7 +162,7 @@ public class DefaultMessageBuilder imple
return copy;
}
-
+
/**
* Returns a copy of the given {@link Body} that can be used (and modified)
* independently of the original. The copy should be
@@ -171,7 +171,7 @@ public class DefaultMessageBuilder imple
* The {@link Body#getParent() parent} of the returned copy is
* <code>null</code>, that is, the copy is detached from the parent
* entity of the original.
- *
+ *
* @param body
* body to copy.
* @return a copy of the given body.
@@ -207,7 +207,7 @@ public class DefaultMessageBuilder imple
* initialized with copies of header and body of the specified
* <code>Message</code>. The parent entity of the new message is
* <code>null</code>.
- *
+ *
* @param other
* message to copy.
* @throws UnsupportedOperationException
@@ -249,9 +249,9 @@ public class DefaultMessageBuilder imple
public Header parseHeader(final InputStream is) throws IOException, MimeIOException {
final MimeEntityConfig cfg = config != null ? config : new MimeEntityConfig();
boolean strict = cfg.isStrictParsing();
- final DecodeMonitor mon = monitor != null ? monitor :
+ final DecodeMonitor mon = monitor != null ? monitor :
strict ? DecodeMonitor.STRICT : DecodeMonitor.SILENT;
- final FieldParser<? extends ParsedField> fp = fieldParser != null ? fieldParser :
+ final FieldParser<? extends ParsedField> fp = fieldParser != null ? fieldParser :
strict ? DefaultFieldParser.getParser() : LenientFieldParser.getParser();
final HeaderImpl header = new HeaderImpl();
final MimeStreamParser parser = new MimeStreamParser();
@@ -292,10 +292,10 @@ public class DefaultMessageBuilder imple
MessageImpl message = new MessageImpl();
MimeEntityConfig cfg = config != null ? config : new MimeEntityConfig();
boolean strict = cfg.isStrictParsing();
- DecodeMonitor mon = monitor != null ? monitor :
+ DecodeMonitor mon = monitor != null ? monitor :
strict ? DecodeMonitor.STRICT : DecodeMonitor.SILENT;
BodyDescriptorBuilder bdb = bodyDescBuilder != null ? bodyDescBuilder :
- new DefaultBodyDescriptorBuilder(null, fieldParser != null ? fieldParser :
+ new DefaultBodyDescriptorBuilder(null, fieldParser != null ? fieldParser :
strict ? DefaultFieldParser.getParser() : LenientFieldParser.getParser(), mon);
BodyFactory bf = bodyFactory != null ? bodyFactory : new BasicBodyFactory();
MimeStreamParser parser = new MimeStreamParser(cfg, mon, bdb);
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/DefaultMessageWriter.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/DefaultMessageWriter.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/DefaultMessageWriter.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/DefaultMessageWriter.java Mon Jul 11 19:48:50 2011
@@ -56,7 +56,7 @@ public class DefaultMessageWriter implem
/**
* Write the specified <code>Body</code> to the specified
* <code>OutputStream</code>.
- *
+ *
* @param body
* the <code>Body</code> to write.
* @param out
@@ -78,7 +78,7 @@ public class DefaultMessageWriter implem
/**
* Write the specified <code>Entity</code> to the specified
* <code>OutputStream</code>.
- *
+ *
* @param entity
* the <code>Entity</code> to write.
* @param out
@@ -111,7 +111,7 @@ public class DefaultMessageWriter implem
/**
* Write the specified <code>Message</code> to the specified
* <code>OutputStream</code>.
- *
+ *
* @param entity
* the <code>Message</code> to write.
* @param out
@@ -122,11 +122,11 @@ public class DefaultMessageWriter implem
public void writeMessage(Message message, OutputStream out) throws IOException {
writeEntity(message, out);
}
-
+
/**
* Write the specified <code>Multipart</code> to the specified
* <code>OutputStream</code>.
- *
+ *
* @param multipart
* the <code>Multipart</code> to write.
* @param out
@@ -175,7 +175,7 @@ public class DefaultMessageWriter implem
/**
* Write the specified <code>Field</code> to the specified
* <code>OutputStream</code>.
- *
+ *
* @param field
* the <code>Field</code> to write.
* @param out
@@ -202,7 +202,7 @@ public class DefaultMessageWriter implem
/**
* Write the specified <code>Header</code> to the specified
* <code>OutputStream</code>.
- *
+ *
* @param header
* the <code>Header</code> to write.
* @param out
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/EntityBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/EntityBuilder.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/EntityBuilder.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/EntityBuilder.java Mon Jul 11 19:48:50 2011
@@ -45,7 +45,7 @@ class EntityBuilder implements ContentHa
private final Entity entity;
private final BodyFactory bodyFactory;
private final Stack<Object> stack;
-
+
EntityBuilder(
final Entity entity,
final BodyFactory bodyFactory) {
@@ -53,7 +53,7 @@ class EntityBuilder implements ContentHa
this.bodyFactory = bodyFactory;
this.stack = new Stack<Object>();
}
-
+
private void expect(Class<?> c) {
if (!c.isInstance(stack.peek())) {
throw new IllegalStateException("Internal stack error: "
@@ -61,7 +61,7 @@ class EntityBuilder implements ContentHa
+ stack.peek().getClass().getName() + "'");
}
}
-
+
/**
* @see org.apache.james.mime4j.parser.ContentHandler#startMessage()
*/
@@ -75,7 +75,7 @@ class EntityBuilder implements ContentHa
stack.push(m);
}
}
-
+
/**
* @see org.apache.james.mime4j.parser.ContentHandler#endMessage()
*/
@@ -83,14 +83,14 @@ class EntityBuilder implements ContentHa
expect(Message.class);
stack.pop();
}
-
+
/**
* @see org.apache.james.mime4j.parser.ContentHandler#startHeader()
*/
public void startHeader() throws MimeException {
stack.push(new HeaderImpl());
}
-
+
/**
* @see org.apache.james.mime4j.parser.ContentHandler#field(RawField)
*/
@@ -98,7 +98,7 @@ class EntityBuilder implements ContentHa
expect(Header.class);
((Header) stack.peek()).addField(field);
}
-
+
/**
* @see org.apache.james.mime4j.parser.ContentHandler#endHeader()
*/
@@ -108,34 +108,34 @@ class EntityBuilder implements ContentHa
expect(Entity.class);
((Entity) stack.peek()).setHeader(h);
}
-
+
/**
* @see org.apache.james.mime4j.parser.ContentHandler#startMultipart(org.apache.james.mime4j.stream.BodyDescriptor)
*/
public void startMultipart(final BodyDescriptor bd) throws MimeException {
expect(Entity.class);
-
+
final Entity e = (Entity) stack.peek();
final String subType = bd.getSubType();
final Multipart multiPart = new MultipartImpl(subType);
e.setBody(multiPart);
stack.push(multiPart);
}
-
+
/**
* @see org.apache.james.mime4j.parser.ContentHandler#body(org.apache.james.mime4j.stream.BodyDescriptor, java.io.InputStream)
*/
public void body(BodyDescriptor bd, final InputStream is) throws MimeException, IOException {
expect(Entity.class);
-
- // NO NEED TO MANUALLY RUN DECODING.
+
+ // NO NEED TO MANUALLY RUN DECODING.
// The parser has a "setContentDecoding" method. We should
// simply instantiate the MimeStreamParser with that method.
-
+
// final String enc = bd.getTransferEncoding();
-
+
final Body body;
-
+
/*
final InputStream decodedStream;
if (MimeUtil.ENC_BASE64.equals(enc)) {
@@ -146,35 +146,35 @@ class EntityBuilder implements ContentHa
decodedStream = is;
}
*/
-
+
if (bd.getMimeType().startsWith("text/")) {
body = bodyFactory.textBody(is, bd.getCharset());
} else {
body = bodyFactory.binaryBody(is);
}
-
+
Entity entity = ((Entity) stack.peek());
entity.setBody(body);
}
-
+
/**
* @see org.apache.james.mime4j.parser.ContentHandler#endMultipart()
*/
public void endMultipart() throws MimeException {
stack.pop();
}
-
+
/**
* @see org.apache.james.mime4j.parser.ContentHandler#startBodyPart()
*/
public void startBodyPart() throws MimeException {
expect(Multipart.class);
-
+
BodyPart bodyPart = new BodyPart();
((Multipart) stack.peek()).addBodyPart(bodyPart);
stack.push(bodyPart);
}
-
+
/**
* @see org.apache.james.mime4j.parser.ContentHandler#endBodyPart()
*/
@@ -182,7 +182,7 @@ class EntityBuilder implements ContentHa
expect(BodyPart.class);
stack.pop();
}
-
+
/**
* @see org.apache.james.mime4j.parser.ContentHandler#epilogue(java.io.InputStream)
*/
@@ -191,7 +191,7 @@ class EntityBuilder implements ContentHa
ByteSequence bytes = loadStream(is);
((MultipartImpl) stack.peek()).setEpilogueRaw(bytes);
}
-
+
/**
* @see org.apache.james.mime4j.parser.ContentHandler#preamble(java.io.InputStream)
*/
@@ -200,7 +200,7 @@ class EntityBuilder implements ContentHa
ByteSequence bytes = loadStream(is);
((MultipartImpl) stack.peek()).setPreambleRaw(bytes);
}
-
+
/**
* Unsupported.
* @see org.apache.james.mime4j.parser.ContentHandler#raw(java.io.InputStream)
@@ -220,4 +220,4 @@ class EntityBuilder implements ContentHa
return bab;
}
-}
\ No newline at end of file
+}
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MaximalBodyDescriptor.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MaximalBodyDescriptor.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MaximalBodyDescriptor.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MaximalBodyDescriptor.java Mon Jul 11 19:48:50 2011
@@ -44,7 +44,7 @@ import org.apache.james.mime4j.util.Mime
/**
* Parses and stores values for standard MIME header values.
- *
+ *
*/
public class MaximalBodyDescriptor implements BodyDescriptor {
@@ -58,14 +58,14 @@ public class MaximalBodyDescriptor imple
private static final String CONTENT_LANGUAGE = FieldName.CONTENT_LANGUAGE.toLowerCase(Locale.US);
private static final String CONTENT_LOCATION = FieldName.CONTENT_LOCATION.toLowerCase(Locale.US);
private static final String MIME_VERSION = FieldName.MIME_VERSION.toLowerCase(Locale.US);
-
+
private final String mediaType;
private final String subType;
private final String mimeType;
private final String boundary;
private final String charset;
private final Map<String, ParsedField> fields;
-
+
MaximalBodyDescriptor(
final String mimeType,
final String mediaType,
@@ -79,22 +79,22 @@ public class MaximalBodyDescriptor imple
this.subType = subType;
this.boundary = boundary;
this.charset = charset;
- this.fields = fields != null ? new HashMap<String, ParsedField>(fields) :
+ this.fields = fields != null ? new HashMap<String, ParsedField>(fields) :
Collections.<String, ParsedField>emptyMap();
}
-
+
public String getMimeType() {
return mimeType;
}
-
+
public String getBoundary() {
return boundary;
}
-
+
public String getCharset() {
return charset;
}
-
+
public String getMediaType() {
return mediaType;
}
@@ -105,17 +105,17 @@ public class MaximalBodyDescriptor imple
public Map<String, String> getContentTypeParameters() {
ContentTypeField contentTypeField = (ContentTypeField) fields.get(CONTENT_TYPE);
- return contentTypeField != null ? contentTypeField.getParameters() :
+ return contentTypeField != null ? contentTypeField.getParameters() :
Collections.<String, String>emptyMap();
}
-
+
public String getTransferEncoding() {
- ContentTransferEncodingField contentTransferEncodingField =
+ ContentTransferEncodingField contentTransferEncodingField =
(ContentTransferEncodingField) fields.get(CONTENT_TRANSFER_ENCODING);
- return contentTransferEncodingField != null ? contentTransferEncodingField.getEncoding() :
+ return contentTransferEncodingField != null ? contentTransferEncodingField.getEncoding() :
MimeUtil.ENC_7BIT;
}
-
+
public long getContentLength() {
ContentLengthField contentLengthField = (ContentLengthField) fields.get(CONTENT_LENGTH);
return contentLengthField != null ? contentLengthField.getContentLength() : -1;
@@ -130,38 +130,38 @@ public class MaximalBodyDescriptor imple
*/
public int getMimeMajorVersion() {
MimeVersionField mimeVersionField = (MimeVersionField) fields.get(MIME_VERSION);
- return mimeVersionField != null ? mimeVersionField.getMajorVersion() :
+ return mimeVersionField != null ? mimeVersionField.getMajorVersion() :
MimeVersionFieldImpl.DEFAULT_MAJOR_VERSION;
}
-
+
/**
* Gets the MIME minor version
* as specified by the <code>MIME-Version</code>
- * header.
+ * header.
* Defaults to zero.
* @return positive integer
*/
public int getMimeMinorVersion() {
MimeVersionField mimeVersionField = (MimeVersionField) fields.get(MIME_VERSION);
- return mimeVersionField != null ? mimeVersionField.getMinorVersion() :
+ return mimeVersionField != null ? mimeVersionField.getMinorVersion() :
MimeVersionFieldImpl.DEFAULT_MINOR_VERSION;
}
-
+
/**
- * Gets the value of the <a href='http://www.faqs.org/rfcs/rfc2045'>RFC</a>
+ * Gets the value of the <a href='http://www.faqs.org/rfcs/rfc2045'>RFC</a>
* <code>Content-Description</code> header.
* @return value of the <code>Content-Description</code> when present,
* null otherwise
*/
public String getContentDescription() {
- ContentDescriptionField contentDescriptionField =
+ ContentDescriptionField contentDescriptionField =
(ContentDescriptionField) fields.get(CONTENT_DESCRIPTION);
return contentDescriptionField != null ? contentDescriptionField.getDescription() : null;
}
-
+
/**
- * Gets the value of the <a href='http://www.faqs.org/rfcs/rfc2045'>RFC</a>
+ * Gets the value of the <a href='http://www.faqs.org/rfcs/rfc2045'>RFC</a>
* <code>Content-ID</code> header.
* @return value of the <code>Content-ID</code> when present,
* null otherwise
@@ -170,20 +170,20 @@ public class MaximalBodyDescriptor imple
ContentIdField contentIdField = (ContentIdField) fields.get(CONTENT_ID);
return contentIdField != null ? contentIdField.getId() : null;
}
-
+
/**
* Gets the disposition type of the <code>content-disposition</code> field.
* The value is case insensitive and will be converted to lower case.
* See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
- * @return content disposition type,
+ * @return content disposition type,
* or null when this has not been set
*/
public String getContentDispositionType() {
- ContentDispositionField contentDispositionField =
+ ContentDispositionField contentDispositionField =
(ContentDispositionField) fields.get(CONTENT_DISPOSITION);
return contentDispositionField != null ? contentDispositionField.getDispositionType() : null;
}
-
+
/**
* Gets the parameters of the <code>content-disposition</code> field.
* See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
@@ -191,24 +191,24 @@ public class MaximalBodyDescriptor imple
* not null
*/
public Map<String, String> getContentDispositionParameters() {
- ContentDispositionField contentDispositionField =
+ ContentDispositionField contentDispositionField =
(ContentDispositionField) fields.get(CONTENT_DISPOSITION);
- return contentDispositionField != null ? contentDispositionField.getParameters() :
+ return contentDispositionField != null ? contentDispositionField.getParameters() :
Collections.<String, String>emptyMap();
}
-
+
/**
* Gets the <code>filename</code> parameter value of the <code>content-disposition</code> field.
* See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
- * @return filename parameter value,
+ * @return filename parameter value,
* or null when it is not present
*/
public String getContentDispositionFilename() {
- ContentDispositionField contentDispositionField =
+ ContentDispositionField contentDispositionField =
(ContentDispositionField) fields.get(CONTENT_DISPOSITION);
return contentDispositionField != null ? contentDispositionField.getFilename() : null;
}
-
+
/**
* Gets the <code>modification-date</code> parameter value of the <code>content-disposition</code> field.
* See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
@@ -216,11 +216,11 @@ public class MaximalBodyDescriptor imple
* or null when this is not present
*/
public Date getContentDispositionModificationDate() {
- ContentDispositionField contentDispositionField =
+ ContentDispositionField contentDispositionField =
(ContentDispositionField) fields.get(CONTENT_DISPOSITION);
return contentDispositionField != null ? contentDispositionField.getModificationDate() : null;
}
-
+
/**
* Gets the <code>creation-date</code> parameter value of the <code>content-disposition</code> field.
* See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
@@ -228,11 +228,11 @@ public class MaximalBodyDescriptor imple
* or null when this is not present
*/
public Date getContentDispositionCreationDate() {
- ContentDispositionField contentDispositionField =
+ ContentDispositionField contentDispositionField =
(ContentDispositionField) fields.get(CONTENT_DISPOSITION);
return contentDispositionField != null ? contentDispositionField.getCreationDate() : null;
}
-
+
/**
* Gets the <code>read-date</code> parameter value of the <code>content-disposition</code> field.
* See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
@@ -240,11 +240,11 @@ public class MaximalBodyDescriptor imple
* or null when this is not present
*/
public Date getContentDispositionReadDate() {
- ContentDispositionField contentDispositionField =
+ ContentDispositionField contentDispositionField =
(ContentDispositionField) fields.get(CONTENT_DISPOSITION);
return contentDispositionField != null ? contentDispositionField.getReadDate() : null;
}
-
+
/**
* Gets the <code>size</code> parameter value of the <code>content-disposition</code> field.
* See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>.
@@ -252,38 +252,38 @@ public class MaximalBodyDescriptor imple
* or -1 if this size has not been set
*/
public long getContentDispositionSize() {
- ContentDispositionField contentDispositionField =
+ ContentDispositionField contentDispositionField =
(ContentDispositionField) fields.get(CONTENT_DISPOSITION);
return contentDispositionField != null ? contentDispositionField.getSize() : -1;
}
-
+
/**
* Get the <code>content-language</code> header values.
* Each applicable language tag will be returned in order.
- * See <a href='http://tools.ietf.org/html/rfc4646'>RFC4646</a>
+ * See <a href='http://tools.ietf.org/html/rfc4646'>RFC4646</a>
* <cite>http://tools.ietf.org/html/rfc4646</cite>.
* @return list of language tag Strings,
* or null if no header exists
*/
public List<String> getContentLanguage() {
- ContentLanguageField contentLanguageField =
+ ContentLanguageField contentLanguageField =
(ContentLanguageField) fields.get(CONTENT_LANGUAGE);
- return contentLanguageField != null ? contentLanguageField.getLanguages() :
+ return contentLanguageField != null ? contentLanguageField.getLanguages() :
Collections.<String>emptyList();
}
/**
* Get the <code>content-location</code> header value.
- * See <a href='http://tools.ietf.org/html/rfc2557'>RFC2557</a>
+ * See <a href='http://tools.ietf.org/html/rfc2557'>RFC2557</a>
* @return the URL content-location
* or null if no header exists
*/
public String getContentLocation() {
- ContentLocationField contentLocationField =
+ ContentLocationField contentLocationField =
(ContentLocationField) fields.get(CONTENT_LOCATION);
return contentLocationField != null ? contentLocationField.getLocation() : null;
}
-
+
/**
* Gets the raw, Base64 encoded value of the
* <code>Content-MD5</code> field.
@@ -295,7 +295,7 @@ public class MaximalBodyDescriptor imple
ContentMD5Field contentMD5Field = (ContentMD5Field) fields.get(CONTENT_MD5);
return contentMD5Field != null ? contentMD5Field.getMD5Raw() : null;
}
-
+
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
@@ -313,4 +313,4 @@ public class MaximalBodyDescriptor imple
return sb.toString();
}
-}
+}
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java Mon Jul 11 19:48:50 2011
@@ -41,7 +41,7 @@ import org.apache.james.mime4j.field.Fie
import org.apache.james.mime4j.util.MimeUtil;
/**
- * Represents a MIME message.
+ * Represents a MIME message.
*/
public class MessageImpl extends AbstractMessage {
@@ -126,7 +126,7 @@ public class MessageImpl extends Abstrac
@Override
protected String calcCharset(ContentTypeField contentType) {
- return ContentTypeFieldImpl.getCharset(contentType);
+ return ContentTypeFieldImpl.getCharset(contentType);
}
}
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageServiceFactoryImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageServiceFactoryImpl.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageServiceFactoryImpl.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageServiceFactoryImpl.java Mon Jul 11 19:48:50 2011
@@ -26,7 +26,7 @@ import org.apache.james.mime4j.stream.Mi
/**
* The default MessageBuilderFactory bundled with Mime4j.
- *
+ *
* Supports the "StorageProvider", "MimeEntityConfig" and "MutableBodyDescriptorFactory"
* attributes.
*/
@@ -53,7 +53,7 @@ public class MessageServiceFactoryImpl e
public MessageWriter newMessageWriter() {
return new DefaultMessageWriter();
}
-
+
@Override
public void setAttribute(String name, Object value)
throws IllegalArgumentException {
@@ -83,9 +83,9 @@ public class MessageServiceFactoryImpl e
return;
} else throw new IllegalArgumentException("Unsupported attribute value type for "+name+", expected a Boolean");
}
-
+
throw new IllegalArgumentException("Unsupported attribute: "+name);
-
+
}
}
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MultipartImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MultipartImpl.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MultipartImpl.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MultipartImpl.java Mon Jul 11 19:48:50 2011
@@ -64,7 +64,7 @@ public class MultipartImpl extends Abstr
/**
* Gets the preamble.
- *
+ *
* @return the preamble.
*/
@Override
@@ -78,7 +78,7 @@ public class MultipartImpl extends Abstr
/**
* Sets the preamble.
- *
+ *
* @param preamble
* the preamble.
*/
@@ -102,7 +102,7 @@ public class MultipartImpl extends Abstr
/**
* Gets the epilogue.
- *
+ *
* @return the epilogue.
*/
@Override
@@ -116,7 +116,7 @@ public class MultipartImpl extends Abstr
/**
* Sets the epilogue.
- *
+ *
* @param epilogue
* the epilogue.
*/
Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/SimpleContentHandler.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/SimpleContentHandler.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/SimpleContentHandler.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/SimpleContentHandler.java Mon Jul 11 19:48:50 2011
@@ -38,21 +38,21 @@ import org.apache.james.mime4j.stream.Ra
*/
public abstract class SimpleContentHandler extends AbstractContentHandler {
- private final FieldParser<? extends ParsedField> fieldParser;
+ private final FieldParser<? extends ParsedField> fieldParser;
private final DecodeMonitor monitor;
-
+
public SimpleContentHandler(
- final FieldParser<? extends ParsedField> fieldParser,
+ final FieldParser<? extends ParsedField> fieldParser,
final DecodeMonitor monitor) {
super();
this.fieldParser = fieldParser != null ? fieldParser : LenientFieldParser.getParser();
this.monitor = monitor != null ? monitor : DecodeMonitor.SILENT;
}
-
+
public SimpleContentHandler() {
this(null, null);
}
-
+
/**
* Called after headers are parsed.
*/
Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/ExampleMessagesRoundtripTest.java Mon Jul 11 19:48:50 2011
@@ -68,18 +68,18 @@ public class ExampleMessagesRoundtripTes
Message inputMessage = builder.parseMessage(url.openStream());
ByteArrayOutputStream out = new ByteArrayOutputStream();
writer.writeMessage(inputMessage, out);
-
+
String s = url.toString();
URL msgout = new URL(s.substring(0, s.lastIndexOf('.')) + ".out");
try {
- ByteArrayOutputStream expectedstream = new ByteArrayOutputStream();
- CodecUtil.copy(msgout.openStream(), expectedstream);
- assertEquals("Wrong Expected result", new String(expectedstream.toByteArray()), new String(out.toByteArray()));
+ ByteArrayOutputStream expectedstream = new ByteArrayOutputStream();
+ CodecUtil.copy(msgout.openStream(), expectedstream);
+ assertEquals("Wrong Expected result", new String(expectedstream.toByteArray()), new String(out.toByteArray()));
} catch (FileNotFoundException e) {
- FileOutputStream fos = new FileOutputStream(msgout.getPath()+".expected");
- writer.writeMessage(inputMessage, fos);
- fos.close();
- fail("Expected file created");
+ FileOutputStream fos = new FileOutputStream(msgout.getPath()+".expected");
+ writer.writeMessage(inputMessage, fos);
+ fos.close();
+ fail("Expected file created");
}
}
@@ -87,7 +87,7 @@ public class ExampleMessagesRoundtripTes
return new ExampleMessagesRountripTestSuite();
}
-
+
static class ExampleMessagesRountripTestSuite extends TestSuite {
public ExampleMessagesRountripTestSuite() throws IOException, URISyntaxException {
@@ -96,17 +96,17 @@ public class ExampleMessagesRoundtripTes
addTests("/mimetools-testmsgs");
}
- private void addTests(String testsFolder) throws URISyntaxException,
- MalformedURLException, IOException {
- URL resource = ExampleMessagesRountripTestSuite.class.getResource(testsFolder);
+ private void addTests(String testsFolder) throws URISyntaxException,
+ MalformedURLException, IOException {
+ URL resource = ExampleMessagesRountripTestSuite.class.getResource(testsFolder);
if (resource != null) {
if (resource.getProtocol().equalsIgnoreCase("file")) {
File dir = new File(resource.toURI());
File[] files = dir.listFiles();
-
+
for (File f : files) {
if (f.getName().endsWith(".msg")) {
- addTest(new ExampleMessagesRoundtripTest(f.getName(),
+ addTest(new ExampleMessagesRoundtripTest(f.getName(),
f.toURI().toURL()));
}
}
@@ -118,13 +118,13 @@ public class ExampleMessagesRoundtripTes
String s = "/" + entry.toString();
File f = new File(s);
if (s.startsWith(testsFolder) && s.endsWith(".msg")) {
- addTest(new ExampleMessagesRoundtripTest(f.getName(),
+ addTest(new ExampleMessagesRoundtripTest(f.getName(),
new URL("jar:file:" + jar.getName() + "!" + s)));
}
}
}
}
- }
-
+ }
+
}
}
Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/HeaderTest.java Mon Jul 11 19:48:50 2011
@@ -47,29 +47,29 @@ public class HeaderTest extends TestCase
assertEquals("Headers equals", SUBJECT + "\r\n" + TO + "\r\n", header
.toString());
}
-
+
private static final String SWISS_GERMAN_HELLO = "Gr\374ezi_z\344m\344";
public void testWriteSpecialCharacters() throws Exception {
String hello = SWISS_GERMAN_HELLO;
Header header = new HeaderImpl();
header.addField(DefaultFieldParser.parse("Hello: " + hello));
-
+
Field field = header.getField("Hello");
assertNotNull(field);
// field.getBody is already a 7 bit ASCII string, after MIME4J-151
// assertEquals(hello, field.getBody());
assertEquals(SWISS_GERMAN_HELLO, field.getBody());
-
+
ByteArrayOutputStream outstream = new ByteArrayOutputStream();
-
+
DefaultMessageWriter writer = new DefaultMessageWriter();
writer.writeHeader(header, outstream);
byte[] b = outstream.toByteArray();
ByteArrayBuffer buf = new ByteArrayBuffer(b.length);
buf.append(b, 0, b.length);
String s = ContentUtil.decode(buf);
-
+
assertEquals("Hello: " + SWISS_GERMAN_HELLO + "\r\n\r\n", s);
}
@@ -135,5 +135,5 @@ public class HeaderTest extends TestCase
assertEquals("Message-ID", header.getFields().get(3).getName());
}
-
+
}
Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageCompleteMailTest.java Mon Jul 11 19:48:50 2011
@@ -38,14 +38,14 @@ public class MessageCompleteMailTest ext
protected void tearDown() throws Exception {
super.tearDown();
}
-
+
public void testMultipartAlternative() throws Exception {
Message message = createMessage(ExampleMail.MIME_MULTIPART_ALTERNATIVE_BYTES);
assertTrue("Should be a multipart/alternative mail", message.isMultipart());
Multipart part = (Multipart)message.getBody();
assertEquals("alternative", part.getSubType());
- }
-
+ }
+
public void testMultipartMixed() throws Exception {
Message message = createMessage(ExampleMail.MIME_MIXED_MULTIPART_VARIOUS_ENCODINGS_BYTES);
assertTrue("Should be a multipart/mixed mail", message.isMultipart());
Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageHeadlessParserTest.java Mon Jul 11 19:48:50 2011
@@ -34,33 +34,33 @@ import org.apache.james.mime4j.stream.Mi
public class MessageHeadlessParserTest extends TestCase {
- public void testMalformedHeaderShouldEndHeader() throws Exception {
- String headlessContent = "Subject: my subject\r\n"
- + "Hi, how are you?\r\n"
- + "This is a simple message with no CRLFCELF between headers and body.\r\n"
- + "ThisIsNotAnHeader: because this should be already in the body\r\n"
- + "\r\n"
- + "Instead this should be better parsed as a text/plain body\r\n";
+ public void testMalformedHeaderShouldEndHeader() throws Exception {
+ String headlessContent = "Subject: my subject\r\n"
+ + "Hi, how are you?\r\n"
+ + "This is a simple message with no CRLFCELF between headers and body.\r\n"
+ + "ThisIsNotAnHeader: because this should be already in the body\r\n"
+ + "\r\n"
+ + "Instead this should be better parsed as a text/plain body\r\n";
- MimeEntityConfig config = new MimeEntityConfig();
- config.setMalformedHeaderStartsBody(true);
+ MimeEntityConfig config = new MimeEntityConfig();
+ config.setMalformedHeaderStartsBody(true);
DefaultMessageBuilder builder = new DefaultMessageBuilder();
builder.setMimeEntityConfig(config);
- Message message = builder.parseMessage(
- new ByteArrayInputStream(headlessContent.getBytes("UTF-8")));
- assertEquals("text/plain", message.getMimeType());
- assertEquals(1, message.getHeader().getFields().size());
- BufferedReader reader = new BufferedReader(((TextBody) message.getBody()).getReader());
- String firstLine = reader.readLine();
- assertEquals("Hi, how are you?", firstLine);
- }
-
- public void testSimpleNonMimeTextHeadless() throws Exception {
- String headlessContent = "Hi, how are you?\r\n"
- + "This is a simple message with no headers. While mime messages should start with\r\n"
- + "header: headervalue\r\n"
- + "\r\n"
- + "Instead this should be better parsed as a text/plain body\r\n";
+ Message message = builder.parseMessage(
+ new ByteArrayInputStream(headlessContent.getBytes("UTF-8")));
+ assertEquals("text/plain", message.getMimeType());
+ assertEquals(1, message.getHeader().getFields().size());
+ BufferedReader reader = new BufferedReader(((TextBody) message.getBody()).getReader());
+ String firstLine = reader.readLine();
+ assertEquals("Hi, how are you?", firstLine);
+ }
+
+ public void testSimpleNonMimeTextHeadless() throws Exception {
+ String headlessContent = "Hi, how are you?\r\n"
+ + "This is a simple message with no headers. While mime messages should start with\r\n"
+ + "header: headervalue\r\n"
+ + "\r\n"
+ + "Instead this should be better parsed as a text/plain body\r\n";
MimeEntityConfig config = new MimeEntityConfig();
config.setMalformedHeaderStartsBody(true);
@@ -68,42 +68,42 @@ public class MessageHeadlessParserTest e
builder.setMimeEntityConfig(config);
Message message = builder.parseMessage(
new ByteArrayInputStream(headlessContent.getBytes("UTF-8")));
- assertEquals("text/plain", message.getMimeType());
- assertEquals(0, message.getHeader().getFields().size());
- BufferedReader reader = new BufferedReader(((TextBody) message.getBody()).getReader());
- String firstLine = reader.readLine();
- assertEquals("Hi, how are you?", firstLine);
- }
-
- public void testMultipartFormContent() throws Exception {
- String contentType = "multipart/form-data; boundary=foo";
- String headlessContent = "\r\n"
- + "--foo\r\nContent-Disposition: form-data; name=\"field01\""
- + "\r\n"
- + "\r\n"
- + "this stuff\r\n"
- + "--foo\r\n"
- + "Content-Disposition: form-data; name=\"field02\"\r\n"
- + "\r\n"
- + "that stuff\r\n"
- + "--foo\r\n"
- + "Content-Disposition: form-data; name=\"field03\"; filename=\"mypic.jpg\"\r\n"
- + "Content-Type: image/jpeg\r\n" + "\r\n"
- + "all kind of stuff\r\n" + "--foo--\r\n";
+ assertEquals("text/plain", message.getMimeType());
+ assertEquals(0, message.getHeader().getFields().size());
+ BufferedReader reader = new BufferedReader(((TextBody) message.getBody()).getReader());
+ String firstLine = reader.readLine();
+ assertEquals("Hi, how are you?", firstLine);
+ }
+
+ public void testMultipartFormContent() throws Exception {
+ String contentType = "multipart/form-data; boundary=foo";
+ String headlessContent = "\r\n"
+ + "--foo\r\nContent-Disposition: form-data; name=\"field01\""
+ + "\r\n"
+ + "\r\n"
+ + "this stuff\r\n"
+ + "--foo\r\n"
+ + "Content-Disposition: form-data; name=\"field02\"\r\n"
+ + "\r\n"
+ + "that stuff\r\n"
+ + "--foo\r\n"
+ + "Content-Disposition: form-data; name=\"field03\"; filename=\"mypic.jpg\"\r\n"
+ + "Content-Type: image/jpeg\r\n" + "\r\n"
+ + "all kind of stuff\r\n" + "--foo--\r\n";
- MimeEntityConfig config = new MimeEntityConfig();
- config.setHeadlessParsing(contentType);
+ MimeEntityConfig config = new MimeEntityConfig();
+ config.setHeadlessParsing(contentType);
DefaultMessageBuilder builder = new DefaultMessageBuilder();
builder.setMimeEntityConfig(config);
- Message message = builder.parseMessage(
- new ByteArrayInputStream(headlessContent.getBytes("UTF-8")));
- assertEquals("multipart/form-data", message.getMimeType());
- assertEquals(1, message.getHeader().getFields().size());
- ContentTypeField contentTypeField = ((ContentTypeField) message
- .getHeader().getField(FieldName.CONTENT_TYPE));
- assertEquals("foo", contentTypeField.getBoundary());
- Multipart multipart = (Multipart) message.getBody();
- assertEquals(3, multipart.getCount());
- }
+ Message message = builder.parseMessage(
+ new ByteArrayInputStream(headlessContent.getBytes("UTF-8")));
+ assertEquals("multipart/form-data", message.getMimeType());
+ assertEquals(1, message.getHeader().getFields().size());
+ ContentTypeField contentTypeField = ((ContentTypeField) message
+ .getHeader().getField(FieldName.CONTENT_TYPE));
+ assertEquals("foo", contentTypeField.getBoundary());
+ Multipart multipart = (Multipart) message.getBody();
+ assertEquals(3, multipart.getCount());
+ }
}
Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageParserTest.java Mon Jul 11 19:48:50 2011
@@ -50,7 +50,7 @@ import org.apache.james.mime4j.stream.Fi
import org.apache.james.mime4j.stream.MimeEntityConfig;
public class MessageParserTest extends TestCase {
-
+
private URL url;
public MessageParserTest(String name, URL url) {
@@ -61,25 +61,25 @@ public class MessageParserTest extends T
public static Test suite() throws IOException, URISyntaxException {
return new MessageParserTestSuite();
}
-
+
static class MessageParserTestSuite extends TestSuite {
-
+
public MessageParserTestSuite() throws IOException, URISyntaxException {
addTests("/testmsgs");
addTests("/mimetools-testmsgs");
}
- private void addTests(String testsFolder) throws URISyntaxException,
- MalformedURLException, IOException {
- URL resource = MessageParserTestSuite.class.getResource(testsFolder);
+ private void addTests(String testsFolder) throws URISyntaxException,
+ MalformedURLException, IOException {
+ URL resource = MessageParserTestSuite.class.getResource(testsFolder);
if (resource != null) {
if (resource.getProtocol().equalsIgnoreCase("file")) {
File dir = new File(resource.toURI());
File[] files = dir.listFiles();
-
+
for (File f : files) {
if (f.getName().endsWith(".msg")) {
- addTest(new MessageParserTest(f.getName(),
+ addTest(new MessageParserTest(f.getName(),
f.toURI().toURL()));
}
}
@@ -91,16 +91,16 @@ public class MessageParserTest extends T
String s = "/" + entry.toString();
File f = new File(s);
if (s.startsWith(testsFolder) && s.endsWith(".msg")) {
- addTest(new MessageParserTest(f.getName(),
+ addTest(new MessageParserTest(f.getName(),
new URL("jar:file:" + jar.getName() + "!" + s)));
}
}
}
}
- }
-
+ }
+
}
-
+
@Override
protected void runTest() throws IOException {
MimeEntityConfig config = new MimeEntityConfig();
@@ -111,18 +111,18 @@ public class MessageParserTest extends T
DefaultMessageBuilder builder = new DefaultMessageBuilder();
builder.setMimeEntityConfig(config);
Message m = builder.parseMessage(url.openStream());
-
+
String s = url.toString();
String prefix = s.substring(0, s.lastIndexOf('.'));
URL xmlFileUrl = new URL(prefix + "_decoded.xml");
-
+
String result = getStructure(m, prefix, "1");
try {
- String expected = IOUtils.toString(xmlFileUrl.openStream(), "ISO8859-1");
- assertEquals(expected, result);
+ String expected = IOUtils.toString(xmlFileUrl.openStream(), "ISO8859-1");
+ assertEquals(expected, result);
} catch (FileNotFoundException ex) {
- IOUtils.write(result, new FileOutputStream(xmlFileUrl.getPath()+".expected"), "ISO8859-1");
- fail("Expected file created.");
+ IOUtils.write(result, new FileOutputStream(xmlFileUrl.getPath()+".expected"), "ISO8859-1");
+ fail("Expected file created.");
}
}
@@ -132,17 +132,17 @@ public class MessageParserTest extends T
return s.replaceAll(">", ">");
}
- private String getStructure(Entity e, String prefix, String id)
+ private String getStructure(Entity e, String prefix, String id)
throws IOException {
-
+
StringBuilder sb = new StringBuilder();
-
+
if (e instanceof MessageImpl) {
sb.append("<message>\r\n");
} else {
sb.append("<body-part>\r\n");
- }
-
+ }
+
sb.append("<header>\r\n");
for (Field field : e.getHeader().getFields()) {
sb.append("<field>\r\n"
@@ -150,11 +150,11 @@ public class MessageParserTest extends T
+ "</field>\r\n");
}
sb.append("</header>\r\n");
-
+
if (e.getBody() instanceof Multipart) {
sb.append("<multipart>\r\n");
-
- Multipart multipart =(Multipart) e.getBody();
+
+ Multipart multipart =(Multipart) e.getBody();
List<Entity> parts = multipart.getBodyParts();
if (multipart.getPreamble() != null) {
@@ -162,7 +162,7 @@ public class MessageParserTest extends T
sb.append(escape(multipart.getPreamble()));
sb.append("</preamble>\r\n");
}
-
+
int i = 1;
for (Entity bodyPart : parts) {
sb.append(getStructure(bodyPart, prefix, id + "_" + (i++)));
@@ -173,20 +173,20 @@ public class MessageParserTest extends T
sb.append(escape(multipart.getEpilogue()));
sb.append("</epilogue>\r\n");
}
-
+
sb.append("</multipart>\r\n");
-
+
} else if (e.getBody() instanceof MessageImpl) {
sb.append(getStructure((MessageImpl) e.getBody(), prefix, id + "_1"));
} else {
Body b = e.getBody();
- String s = prefix + "_decoded_" + id
+ String s = prefix + "_decoded_" + id
+ (b instanceof TextBody ? ".txt" : ".bin");
String tag = b instanceof TextBody ? "text-body" : "binary-body";
File f = new File(s);
sb.append("<" + tag + " name=\"" + f.getName() + "\"/>\r\n");
URL expectedUrl = new URL(s);
-
+
if (b instanceof TextBody) {
String charset = e.getCharset();
if (charset == null) {
@@ -195,41 +195,41 @@ public class MessageParserTest extends T
String s2 = IOUtils.toString(((TextBody) b).getReader());
try {
- String s1 = IOUtils.toString(expectedUrl.openStream(), charset);
- assertEquals(f.getName(), s1, s2);
+ String s1 = IOUtils.toString(expectedUrl.openStream(), charset);
+ assertEquals(f.getName(), s1, s2);
} catch (FileNotFoundException ex) {
- IOUtils.write(s2, new FileOutputStream(expectedUrl.getPath()+".expected"));
- fail("Expected file created.");
+ IOUtils.write(s2, new FileOutputStream(expectedUrl.getPath()+".expected"));
+ fail("Expected file created.");
}
} else {
- try {
- assertEqualsBinary(f.getName(), expectedUrl.openStream(),
+ try {
+ assertEqualsBinary(f.getName(), expectedUrl.openStream(),
((BinaryBody) b).getInputStream());
- } catch (FileNotFoundException ex) {
- IOUtils.copy(((BinaryBody) b).getInputStream(), new FileOutputStream(expectedUrl.getPath()+".expected"));
- fail("Expected file created.");
- }
+ } catch (FileNotFoundException ex) {
+ IOUtils.copy(((BinaryBody) b).getInputStream(), new FileOutputStream(expectedUrl.getPath()+".expected"));
+ fail("Expected file created.");
+ }
}
}
-
+
if (e instanceof MessageImpl) {
sb.append("</message>\r\n");
} else {
sb.append("</body-part>\r\n");
- }
-
+ }
+
return sb.toString();
}
- private void assertEqualsBinary(String msg, InputStream a, InputStream b)
+ private void assertEqualsBinary(String msg, InputStream a, InputStream b)
throws IOException {
-
+
int pos = 0;
while (true) {
int b1 = a.read();
int b2 = b.read();
assertEquals(msg + " (Position " + (++pos) + ")", b1, b2);
-
+
if (b1 == -1 || b2 == -1) {
break;
}
Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageTest.java Mon Jul 11 19:48:50 2011
@@ -62,7 +62,7 @@ public class MessageTest extends TestCas
headerEmpty = new HeaderImpl();
headerMultipartMixed = new HeaderImpl();
headerMultipartDigest = new HeaderImpl();
-
+
headerTextPlain.addField(
DefaultFieldParser.parse("Content-Type: text/plain"));
headerMessageRFC822.addField(
@@ -76,67 +76,67 @@ public class MessageTest extends TestCas
public void testGetMimeType() {
MessageImpl parent = null;
MessageImpl child = null;
-
+
parent = new MessageImpl();
child = new MessageImpl();
child.setParent(parent);
parent.setHeader(headerMultipartDigest);
child.setHeader(headerEmpty);
- assertEquals("multipart/digest, empty", "message/rfc822",
+ assertEquals("multipart/digest, empty", "message/rfc822",
child.getMimeType());
child.setHeader(headerTextPlain);
- assertEquals("multipart/digest, text/plain", "text/plain",
+ assertEquals("multipart/digest, text/plain", "text/plain",
child.getMimeType());
child.setHeader(headerMessageRFC822);
- assertEquals("multipart/digest, message/rfc822", "message/rfc822",
+ assertEquals("multipart/digest, message/rfc822", "message/rfc822",
child.getMimeType());
-
+
parent = new MessageImpl();
child = new MessageImpl();
child.setParent(parent);
parent.setHeader(headerMultipartMixed);
child.setHeader(headerEmpty);
- assertEquals("multipart/mixed, empty", "text/plain",
+ assertEquals("multipart/mixed, empty", "text/plain",
child.getMimeType());
child.setHeader(headerTextPlain);
- assertEquals("multipart/mixed, text/plain", "text/plain",
+ assertEquals("multipart/mixed, text/plain", "text/plain",
child.getMimeType());
child.setHeader(headerMessageRFC822);
- assertEquals("multipart/mixed, message/rfc822", "message/rfc822",
+ assertEquals("multipart/mixed, message/rfc822", "message/rfc822",
child.getMimeType());
-
+
child = new MessageImpl();
child.setHeader(headerEmpty);
assertEquals("null, empty", "text/plain", child.getMimeType());
child.setHeader(headerTextPlain);
assertEquals("null, text/plain", "text/plain", child.getMimeType());
child.setHeader(headerMessageRFC822);
- assertEquals("null, message/rfc822", "message/rfc822",
+ assertEquals("null, message/rfc822", "message/rfc822",
child.getMimeType());
}
public void testIsMultipart() {
MessageImpl m = new MessageImpl();
-
+
m.setHeader(headerEmpty);
assertTrue("empty", !m.isMultipart());
-
+
m.setHeader(headerTextPlain);
assertTrue("text/plain", !m.isMultipart());
-
+
m.setHeader(headerMultipartDigest);
assertTrue("multipart/digest", m.isMultipart());
-
+
m.setHeader(headerMultipartMixed);
assertTrue("multipart/mixed", m.isMultipart());
}
-
+
public void testWriteTo() throws Exception {
byte[] inputByte = getRawMessageAsByteArray();
DefaultMessageBuilder builder = new DefaultMessageBuilder();
DefaultMessageWriter writer = new DefaultMessageWriter();
-
+
Message m = builder.parseMessage(new ByteArrayInputStream(inputByte));
ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -161,7 +161,7 @@ public class MessageTest extends TestCas
DefaultMessageBuilder builder = new DefaultMessageBuilder();
DefaultMessageWriter writer = new DefaultMessageWriter();
-
+
Message m = builder.parseMessage(new ByteArrayInputStream(inputByte));
m.getHeader().addField(DefaultFieldParser.parse(testheader));
Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MessageWriteToTest.java Mon Jul 11 19:48:50 2011
@@ -39,7 +39,7 @@ public class MessageWriteToTest extends
protected void tearDown() throws Exception {
super.tearDown();
}
-
+
public void testSimpleMail() throws Exception {
Message message = createMessage(ExampleMail.RFC822_SIMPLE_BYTES);
assertFalse("Not multipart", message.isMultipart());
@@ -48,7 +48,7 @@ public class MessageWriteToTest extends
writer.writeMessage(message, out);
assertEquals(out.toByteArray(), ExampleMail.RFC822_SIMPLE_BYTES);
}
-
+
private void assertEquals(byte[] expected, byte[] actual) {
StringBuilder buffer = new StringBuilder(expected.length);
assertEquals(new String(expected), new String(actual));
@@ -58,7 +58,7 @@ public class MessageWriteToTest extends
assertEquals("Mismatch@" + i, expected[i], actual[i]);
}
}
-
+
public void testBinaryAttachment() throws Exception {
Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES);
assertTrue("Is multipart", message.isMultipart());
@@ -67,7 +67,7 @@ public class MessageWriteToTest extends
writer.writeMessage(message, out);
assertEquals(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_BYTES, out.toByteArray());
}
-
+
public void testBinaryAttachmentNoPreamble() throws Exception {
Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_NOPREAMBLE_BYTES);
assertTrue("Is multipart", message.isMultipart());
@@ -76,7 +76,7 @@ public class MessageWriteToTest extends
writer.writeMessage(message, out);
assertEquals(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_NOPREAMBLE_BYTES, out.toByteArray());
}
-
+
public void testBinaryAttachmentPreambleEpilogue() throws Exception {
Message message = createMessage(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_PREAMBLE_EPILOGUE_BYTES);
assertTrue("Is multipart", message.isMultipart());
@@ -85,7 +85,7 @@ public class MessageWriteToTest extends
writer.writeMessage(message, out);
assertEquals(ExampleMail.MULTIPART_WITH_BINARY_ATTACHMENTS_PREAMBLE_EPILOGUE_BYTES, out.toByteArray());
}
-
+
private Message createMessage(byte[] octets) throws Exception {
ByteArrayInputStream in = new ByteArrayInputStream(octets);
DefaultMessageBuilder builder = new DefaultMessageBuilder();
Modified: james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java?rev=1145308&r1=1145307&r2=1145308&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java (original)
+++ james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/dom/MultipartFormTest.java Mon Jul 11 19:48:50 2011
@@ -37,13 +37,13 @@ public class MultipartFormTest extends T
public void testMultipartFormContent() throws Exception {
BasicBodyFactory bodyFactory = new BasicBodyFactory();
-
+
MessageImpl message = new MessageImpl();
Header header = new HeaderImpl();
header.addField(
DefaultFieldParser.parse("Content-Type: multipart/form-data; boundary=foo"));
message.setHeader(header);
-
+
Multipart multipart = new MultipartImpl("alternative");
multipart.setParent(message);
BodyPart p1 = new BodyPart();
@@ -65,12 +65,12 @@ public class MultipartFormTest extends T
multipart.addBodyPart(p1);
multipart.addBodyPart(p2);
multipart.addBodyPart(p3);
-
+
ByteArrayOutputStream out = new ByteArrayOutputStream();
DefaultMessageWriter writer = new DefaultMessageWriter();
writer.writeMultipart(multipart, out);
out.close();
-
+
String expected = "--foo\r\n" +
"Content-Type: text/plain\r\n" +
"\r\n" +
@@ -87,5 +87,5 @@ public class MultipartFormTest extends T
String s = out.toString("US-ASCII");
assertEquals(expected, s);
}
-
+
}