james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r746223 [1/2] - in /james/mime4j/trunk: examples/src/java/org/apache/james/mime4j/samples/tree/ src/main/java/org/apache/james/mime4j/descriptor/ src/main/java/org/apache/james/mime4j/field/ src/main/java/org/apache/james/mime4j/message/ sr...
Date Fri, 20 Feb 2009 12:28:05 GMT
Author: olegk
Date: Fri Feb 20 12:28:04 2009
New Revision: 746223

URL: http://svn.apache.org/viewvc?rev=746223&view=rev
Log:
MIME4J-118: immutable Field interface to represent an abstract MIME field

Added:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AbstractField.java   (contents, props changed)
      - copied, changed from r744866, james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/Field.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/Field.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/RawField.java   (with props)
Removed:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/Field.java
Modified:
    james/mime4j/trunk/examples/src/java/org/apache/james/mime4j/samples/tree/MessageTree.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptor.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/MaximalBodyDescriptor.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/MutableBodyDescriptor.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AddressListField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentDispositionField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTypeField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DateTimeField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DefaultFieldParser.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldParser.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/Fields.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxListField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/UnstructuredField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Entity.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Header.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Message.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/MessageBuilder.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/MessageWriter.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/SimpleContentHandler.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/AbstractContentHandler.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/ContentHandler.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/EntityStateMachine.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/RawEntity.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/StringArrayMap.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/BaseTestForBodyDescriptors.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/ContentDispositionFieldTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/ContentTransferEncodingFieldTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/ContentTypeFieldTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/FieldTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/FieldsTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/field/UnstructuredFieldTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/CopyConstructorTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/EntityTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/HeaderTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageParserTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MessageTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/message/MultipartFormTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeEntityTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/MimeStreamParserTest.java
    james/mime4j/trunk/src/test/java/org/apache/james/mime4j/parser/TestHandler.java

Modified: james/mime4j/trunk/examples/src/java/org/apache/james/mime4j/samples/tree/MessageTree.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/examples/src/java/org/apache/james/mime4j/samples/tree/MessageTree.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/examples/src/java/org/apache/james/mime4j/samples/tree/MessageTree.java (original)
+++ james/mime4j/trunk/examples/src/java/org/apache/james/mime4j/samples/tree/MessageTree.java Fri Feb 20 12:28:04 2009
@@ -43,7 +43,7 @@
 import org.apache.james.mime4j.field.AddressListField;
 import org.apache.james.mime4j.field.ContentTypeField;
 import org.apache.james.mime4j.field.DateTimeField;
-import org.apache.james.mime4j.field.Field;
+import org.apache.james.mime4j.field.AbstractField;
 import org.apache.james.mime4j.field.UnstructuredField;
 import org.apache.james.mime4j.field.address.Mailbox;
 import org.apache.james.mime4j.field.address.MailboxList;
@@ -55,6 +55,7 @@
 import org.apache.james.mime4j.message.Message;
 import org.apache.james.mime4j.message.Multipart;
 import org.apache.james.mime4j.message.TextBody;
+import org.apache.james.mime4j.parser.Field;
 
 /**
  * Displays a parsed Message in a window. The window will be divided into
@@ -321,8 +322,8 @@
                 textView.setText(date.toString());                
             } else if (o instanceof UnstructuredField){
                 textView.setText(((UnstructuredField) o).getValue());                
-            } else if (o instanceof Field){
-                textView.setText(((Field) o).getBody());                
+            } else if (o instanceof AbstractField){
+                textView.setText(((AbstractField) o).getBody());                
             } else {
                 /*
                  * The Object should be a Header or a String containing a 

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptor.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptor.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptor.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/DefaultBodyDescriptor.java Fri Feb 20 12:28:04 2009
@@ -24,6 +24,7 @@
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.MimeUtil;
 
 /**
@@ -92,8 +93,10 @@
      * @param name the field name.
      * @param value the field value.
      */
-    public void addField(String name, String value) {
-        
+    public void addField(Field field) {
+        String name = field.getName();
+        String value = field.getBody();
+
         name = name.trim().toLowerCase();
         
         if (name.equals("content-transfer-encoding") && !contentTransferEncSet) {

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/MaximalBodyDescriptor.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/MaximalBodyDescriptor.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/MaximalBodyDescriptor.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/MaximalBodyDescriptor.java Fri Feb 20 12:28:04 2009
@@ -31,9 +31,9 @@
 import org.apache.james.mime4j.field.language.parser.ContentLanguageParser;
 import org.apache.james.mime4j.field.mimeversion.parser.MimeVersionParser;
 import org.apache.james.mime4j.field.structured.parser.StructuredFieldParser;
+import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.MimeUtil;
 
-
 /**
  * Parses and stores values for standard MIME header values.
  * 
@@ -105,7 +105,9 @@
     }
     
     @Override
-    public void addField(String name, String value) {
+    public void addField(Field field) {
+        String name = field.getName();
+        String value = field.getBody();
         name = name.trim().toLowerCase();
         if (MimeUtil.MIME_HEADER_MIME_VERSION.equals(name) && !isMimeVersionSet) {
             parseMimeVersion(value);
@@ -122,7 +124,7 @@
         } else if (MimeUtil.MIME_HEADER_MD5.equals(name) && !isContentMD5Set) {
             parseMD5(value);
         } else {
-            super.addField(name, value);
+            super.addField(field);
         }
     }
     

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/MutableBodyDescriptor.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/MutableBodyDescriptor.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/MutableBodyDescriptor.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/descriptor/MutableBodyDescriptor.java Fri Feb 20 12:28:04 2009
@@ -20,6 +20,8 @@
 
 package org.apache.james.mime4j.descriptor;
 
+import org.apache.james.mime4j.parser.Field;
+
 /**
  * Adds mutator.
  */
@@ -27,9 +29,8 @@
 
     /**
      * Adds a field to the body descriptor.
-     * @param pFieldName The fields name.
-     * @param pFieldValue The unparsed fields value.
+     * @param Field the MIME field.
      */
-    void addField(String pFieldName, String pFieldValue);
+    void addField(Field field);
 
 }

Copied: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AbstractField.java (from r744866, james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/Field.java)
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AbstractField.java?p2=james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AbstractField.java&p1=james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/Field.java&r1=744866&r2=746223&rev=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/Field.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AbstractField.java Fri Feb 20 12:28:04 2009
@@ -23,12 +23,13 @@
 import java.util.regex.Pattern;
 
 import org.apache.james.mime4j.MimeException;
+import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.MimeUtil;
 
 /**
  * The base class of all field classes.
  */
-public abstract class Field {
+public abstract class AbstractField implements Field {
     public static final String SENDER = "Sender";
     public static final String FROM = "From";
     public static final String TO = "To";
@@ -63,7 +64,7 @@
     private final String body;
     private final String raw;
     
-    protected Field(final String name, final String body, final String raw) {
+    protected AbstractField(final String name, final String body, final String raw) {
         this.name = name;
         this.body = body;
         this.raw = raw;

Propchange: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AbstractField.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AddressListField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AddressListField.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AddressListField.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AddressListField.java Fri Feb 20 12:28:04 2009
@@ -27,7 +27,7 @@
 /**
  * Address list field such as <code>To</code> or <code>Reply-To</code>.
  */
-public class AddressListField extends Field {
+public class AddressListField extends AbstractField {
     private static Log log = LogFactory.getLog(AddressListField.class);
 
     private boolean parsed = false;
@@ -70,7 +70,7 @@
     }
 
     static class Parser implements FieldParser {
-        public Field parse(final String name, final String body,
+        public AbstractField parse(final String name, final String body,
                 final String raw) {
             return new AddressListField(name, body, raw);
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentDispositionField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentDispositionField.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentDispositionField.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentDispositionField.java Fri Feb 20 12:28:04 2009
@@ -37,7 +37,7 @@
 /**
  * Represents a <code>Content-Disposition</code> field.
  */
-public class ContentDispositionField extends Field {
+public class ContentDispositionField extends AbstractField {
     private static Log log = LogFactory.getLog(ContentDispositionField.class);
 
     /** The <code>inline</code> disposition type. */
@@ -318,7 +318,7 @@
     }
 
     static class Parser implements FieldParser {
-        public Field parse(final String name, final String body,
+        public AbstractField parse(final String name, final String body,
                 final String raw) {
             return new ContentDispositionField(name, body, raw);
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingField.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingField.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingField.java Fri Feb 20 12:28:04 2009
@@ -24,7 +24,7 @@
 /**
  * Represents a <code>Content-Transfer-Encoding</code> field.
  */
-public class ContentTransferEncodingField extends Field {
+public class ContentTransferEncodingField extends AbstractField {
     private String encoding;
 
     ContentTransferEncodingField(String name, String body, String raw) {
@@ -56,7 +56,7 @@
     }
 
     static class Parser implements FieldParser {
-        public Field parse(final String name, final String body,
+        public AbstractField parse(final String name, final String body,
                 final String raw) {
             return new ContentTransferEncodingField(name, body, raw);
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTypeField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTypeField.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTypeField.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTypeField.java Fri Feb 20 12:28:04 2009
@@ -34,7 +34,7 @@
 /**
  * Represents a <code>Content-Type</code> field.
  */
-public class ContentTypeField extends Field {
+public class ContentTypeField extends AbstractField {
     private static Log log = LogFactory.getLog(ContentTypeField.class);
 
     /** The prefix of all <code>multipart</code> MIME types. */
@@ -249,7 +249,7 @@
     }
 
     static class Parser implements FieldParser {
-        public Field parse(final String name, final String body,
+        public AbstractField parse(final String name, final String body,
                 final String raw) {
             return new ContentTypeField(name, body, raw);
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DateTimeField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DateTimeField.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DateTimeField.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DateTimeField.java Fri Feb 20 12:28:04 2009
@@ -31,7 +31,7 @@
 /**
  * Date-time field such as <code>Date</code> or <code>Resent-Date</code>.
  */
-public class DateTimeField extends Field {
+public class DateTimeField extends AbstractField {
     private static Log log = LogFactory.getLog(DateTimeField.class);
 
     private boolean parsed = false;
@@ -80,7 +80,7 @@
     }
 
     static class Parser implements FieldParser {
-        public Field parse(final String name, final String body,
+        public AbstractField parse(final String name, final String body,
                 final String raw) {
             return new DateTimeField(name, body, raw);
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DefaultFieldParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DefaultFieldParser.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DefaultFieldParser.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DefaultFieldParser.java Fri Feb 20 12:28:04 2009
@@ -22,29 +22,29 @@
 public class DefaultFieldParser extends DelegatingFieldParser {
     
     public DefaultFieldParser() {
-        setFieldParser(Field.CONTENT_TRANSFER_ENCODING, new ContentTransferEncodingField.Parser());
-        setFieldParser(Field.CONTENT_TYPE, new ContentTypeField.Parser());
-        setFieldParser(Field.CONTENT_DISPOSITION, new ContentDispositionField.Parser());
+        setFieldParser(AbstractField.CONTENT_TRANSFER_ENCODING, new ContentTransferEncodingField.Parser());
+        setFieldParser(AbstractField.CONTENT_TYPE, new ContentTypeField.Parser());
+        setFieldParser(AbstractField.CONTENT_DISPOSITION, new ContentDispositionField.Parser());
         
         final DateTimeField.Parser dateTimeParser = new DateTimeField.Parser();
-        setFieldParser(Field.DATE, dateTimeParser);
-        setFieldParser(Field.RESENT_DATE, dateTimeParser);
+        setFieldParser(AbstractField.DATE, dateTimeParser);
+        setFieldParser(AbstractField.RESENT_DATE, dateTimeParser);
         
         final MailboxListField.Parser mailboxListParser = new MailboxListField.Parser();
-        setFieldParser(Field.FROM, mailboxListParser);
-        setFieldParser(Field.RESENT_FROM, mailboxListParser);
+        setFieldParser(AbstractField.FROM, mailboxListParser);
+        setFieldParser(AbstractField.RESENT_FROM, mailboxListParser);
         
         final MailboxField.Parser mailboxParser = new MailboxField.Parser();
-        setFieldParser(Field.SENDER, mailboxParser);
-        setFieldParser(Field.RESENT_SENDER, mailboxParser);
+        setFieldParser(AbstractField.SENDER, mailboxParser);
+        setFieldParser(AbstractField.RESENT_SENDER, mailboxParser);
         
         final AddressListField.Parser addressListParser = new AddressListField.Parser();
-        setFieldParser(Field.TO, addressListParser);
-        setFieldParser(Field.RESENT_TO, addressListParser);
-        setFieldParser(Field.CC, addressListParser);
-        setFieldParser(Field.RESENT_CC, addressListParser);
-        setFieldParser(Field.BCC, addressListParser);
-        setFieldParser(Field.RESENT_BCC, addressListParser);
-        setFieldParser(Field.REPLY_TO, addressListParser);
+        setFieldParser(AbstractField.TO, addressListParser);
+        setFieldParser(AbstractField.RESENT_TO, addressListParser);
+        setFieldParser(AbstractField.CC, addressListParser);
+        setFieldParser(AbstractField.RESENT_CC, addressListParser);
+        setFieldParser(AbstractField.BCC, addressListParser);
+        setFieldParser(AbstractField.RESENT_BCC, addressListParser);
+        setFieldParser(AbstractField.REPLY_TO, addressListParser);
     }
 }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java Fri Feb 20 12:28:04 2009
@@ -22,6 +22,8 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.james.mime4j.parser.Field;
+
 public class DelegatingFieldParser implements FieldParser {
     
     private Map<String, FieldParser> parsers = new HashMap<String, FieldParser>();

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldParser.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldParser.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldParser.java Fri Feb 20 12:28:04 2009
@@ -19,7 +19,10 @@
 
 package org.apache.james.mime4j.field;
 
+import org.apache.james.mime4j.parser.Field;
+
 public interface FieldParser {
     
     Field parse(final String name, final String body, final String raw);
+    
 }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/Fields.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/Fields.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/Fields.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/Fields.java Fri Feb 20 12:28:04 2009
@@ -30,10 +30,11 @@
 import org.apache.james.mime4j.codec.EncoderUtil;
 import org.apache.james.mime4j.field.address.Address;
 import org.apache.james.mime4j.field.address.Mailbox;
+import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.MimeUtil;
 
 /**
- * Factory for concrete {@link Field} instances.
+ * Factory for concrete {@link AbstractField} instances.
  */
 public class Fields {
 
@@ -51,7 +52,7 @@
      * @return the newly created <i>Content-Type</i> field.
      */
     public static ContentTypeField contentType(String contentType) {
-        return parse(ContentTypeField.class, Field.CONTENT_TYPE, contentType);
+        return parse(ContentTypeField.class, AbstractField.CONTENT_TYPE, contentType);
     }
 
     /**
@@ -72,7 +73,7 @@
             throw new IllegalArgumentException();
 
         if (parameters == null || parameters.isEmpty()) {
-            return parse(ContentTypeField.class, Field.CONTENT_TYPE, mimeType);
+            return parse(ContentTypeField.class, AbstractField.CONTENT_TYPE, mimeType);
         } else {
             StringBuilder sb = new StringBuilder(mimeType);
             for (Map.Entry<String, String> entry : parameters.entrySet()) {
@@ -97,7 +98,7 @@
     public static ContentTransferEncodingField contentTransferEncoding(
             String contentTransferEncoding) {
         return parse(ContentTransferEncodingField.class,
-                Field.CONTENT_TRANSFER_ENCODING, contentTransferEncoding);
+                AbstractField.CONTENT_TRANSFER_ENCODING, contentTransferEncoding);
     }
 
     /**
@@ -112,7 +113,7 @@
      */
     public static ContentDispositionField contentDisposition(
             String contentDisposition) {
-        return parse(ContentDispositionField.class, Field.CONTENT_DISPOSITION,
+        return parse(ContentDispositionField.class, AbstractField.CONTENT_DISPOSITION,
                 contentDisposition);
     }
 
@@ -135,7 +136,7 @@
 
         if (parameters == null || parameters.isEmpty()) {
             return parse(ContentDispositionField.class,
-                    Field.CONTENT_DISPOSITION, dispositionType);
+                    AbstractField.CONTENT_DISPOSITION, dispositionType);
         } else {
             StringBuilder sb = new StringBuilder(dispositionType);
             for (Map.Entry<String, String> entry : parameters.entrySet()) {
@@ -244,7 +245,7 @@
      * @return the newly created <i>Date</i> field.
      */
     public static DateTimeField date(Date date) {
-        return date(Field.DATE, date, null);
+        return date(AbstractField.DATE, date, null);
     }
 
     /**
@@ -288,9 +289,9 @@
      *            <code>null</code> if no host name should be included.
      * @return the newly created <i>Message-ID</i> field.
      */
-    public static Field messageId(String hostname) {
+    public static AbstractField messageId(String hostname) {
         String fieldValue = MimeUtil.createUniqueMessageId(hostname);
-        return parse(UnstructuredField.class, Field.MESSAGE_ID, fieldValue);
+        return parse(UnstructuredField.class, AbstractField.MESSAGE_ID, fieldValue);
     }
 
     /**
@@ -302,11 +303,11 @@
      * @return the newly created <i>Subject</i> field.
      */
     public static UnstructuredField subject(String subject) {
-        int usedCharacters = Field.SUBJECT.length() + 2;
+        int usedCharacters = AbstractField.SUBJECT.length() + 2;
         String fieldValue = EncoderUtil.encodeIfNecessary(subject,
                 EncoderUtil.Usage.TEXT_TOKEN, usedCharacters);
 
-        return parse(UnstructuredField.class, Field.SUBJECT, fieldValue);
+        return parse(UnstructuredField.class, AbstractField.SUBJECT, fieldValue);
     }
 
     /**
@@ -317,7 +318,7 @@
      * @return the newly created <i>Sender</i> field.
      */
     public static MailboxField sender(Mailbox mailbox) {
-        return mailbox(Field.SENDER, mailbox);
+        return mailbox(AbstractField.SENDER, mailbox);
     }
 
     /**
@@ -328,7 +329,7 @@
      * @return the newly created <i>From</i> field.
      */
     public static MailboxListField from(Mailbox mailbox) {
-        return mailboxList(Field.FROM, Collections.singleton(mailbox));
+        return mailboxList(AbstractField.FROM, Collections.singleton(mailbox));
     }
 
     /**
@@ -339,7 +340,7 @@
      * @return the newly created <i>From</i> field.
      */
     public static MailboxListField from(Mailbox... mailboxes) {
-        return mailboxList(Field.FROM, Arrays.asList(mailboxes));
+        return mailboxList(AbstractField.FROM, Arrays.asList(mailboxes));
     }
 
     /**
@@ -350,7 +351,7 @@
      * @return the newly created <i>From</i> field.
      */
     public static MailboxListField from(Iterable<Mailbox> mailboxes) {
-        return mailboxList(Field.FROM, mailboxes);
+        return mailboxList(AbstractField.FROM, mailboxes);
     }
 
     /**
@@ -361,7 +362,7 @@
      * @return the newly created <i>To</i> field.
      */
     public static AddressListField to(Address address) {
-        return addressList(Field.TO, Collections.singleton(address));
+        return addressList(AbstractField.TO, Collections.singleton(address));
     }
 
     /**
@@ -372,7 +373,7 @@
      * @return the newly created <i>To</i> field.
      */
     public static AddressListField to(Address... addresses) {
-        return addressList(Field.TO, Arrays.asList(addresses));
+        return addressList(AbstractField.TO, Arrays.asList(addresses));
     }
 
     /**
@@ -383,7 +384,7 @@
      * @return the newly created <i>To</i> field.
      */
     public static AddressListField to(Iterable<Address> addresses) {
-        return addressList(Field.TO, addresses);
+        return addressList(AbstractField.TO, addresses);
     }
 
     /**
@@ -394,7 +395,7 @@
      * @return the newly created <i>Cc</i> field.
      */
     public static AddressListField cc(Address address) {
-        return addressList(Field.CC, Collections.singleton(address));
+        return addressList(AbstractField.CC, Collections.singleton(address));
     }
 
     /**
@@ -405,7 +406,7 @@
      * @return the newly created <i>Cc</i> field.
      */
     public static AddressListField cc(Address... addresses) {
-        return addressList(Field.CC, Arrays.asList(addresses));
+        return addressList(AbstractField.CC, Arrays.asList(addresses));
     }
 
     /**
@@ -416,7 +417,7 @@
      * @return the newly created <i>Cc</i> field.
      */
     public static AddressListField cc(Iterable<Address> addresses) {
-        return addressList(Field.CC, addresses);
+        return addressList(AbstractField.CC, addresses);
     }
 
     /**
@@ -427,7 +428,7 @@
      * @return the newly created <i>Bcc</i> field.
      */
     public static AddressListField bcc(Address address) {
-        return addressList(Field.BCC, Collections.singleton(address));
+        return addressList(AbstractField.BCC, Collections.singleton(address));
     }
 
     /**
@@ -438,7 +439,7 @@
      * @return the newly created <i>Bcc</i> field.
      */
     public static AddressListField bcc(Address... addresses) {
-        return addressList(Field.BCC, Arrays.asList(addresses));
+        return addressList(AbstractField.BCC, Arrays.asList(addresses));
     }
 
     /**
@@ -449,7 +450,7 @@
      * @return the newly created <i>Bcc</i> field.
      */
     public static AddressListField bcc(Iterable<Address> addresses) {
-        return addressList(Field.BCC, addresses);
+        return addressList(AbstractField.BCC, addresses);
     }
 
     /**
@@ -461,7 +462,7 @@
      * @return the newly created <i>Reply-To</i> field.
      */
     public static AddressListField replyTo(Address address) {
-        return addressList(Field.REPLY_TO, Collections.singleton(address));
+        return addressList(AbstractField.REPLY_TO, Collections.singleton(address));
     }
 
     /**
@@ -473,7 +474,7 @@
      * @return the newly created <i>Reply-To</i> field.
      */
     public static AddressListField replyTo(Address... addresses) {
-        return addressList(Field.REPLY_TO, Arrays.asList(addresses));
+        return addressList(AbstractField.REPLY_TO, Arrays.asList(addresses));
     }
 
     /**
@@ -485,7 +486,7 @@
      * @return the newly created <i>Reply-To</i> field.
      */
     public static AddressListField replyTo(Iterable<Address> addresses) {
-        return addressList(Field.REPLY_TO, addresses);
+        return addressList(AbstractField.REPLY_TO, addresses);
     }
 
     /**
@@ -565,12 +566,12 @@
         return EncoderUtil.isToken(dispositionType);
     }
 
-    private static <F extends Field> F parse(Class<F> fieldClass,
+    private static <F extends AbstractField> F parse(Class<F> fieldClass,
             String fieldName, String fieldBody) {
         try {
             String raw = MimeUtil.fold(fieldName + ": " + fieldBody, 0);
 
-            Field field = Field.parse(raw);
+            Field field = AbstractField.parse(raw);
             if (!fieldClass.isInstance(field)) {
                 throw new IllegalArgumentException("Incompatible field name: "
                         + fieldName);

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxField.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxField.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxField.java Fri Feb 20 12:28:04 2009
@@ -29,7 +29,7 @@
 /**
  * Mailbox field such as <code>Sender</code> or <code>Resent-Sender</code>.
  */
-public class MailboxField extends Field {
+public class MailboxField extends AbstractField {
     private static Log log = LogFactory.getLog(MailboxField.class);
 
     private boolean parsed = false;
@@ -75,7 +75,7 @@
     }
 
     static class Parser implements FieldParser {
-        public Field parse(final String name, final String body,
+        public AbstractField parse(final String name, final String body,
                 final String raw) {
             return new MailboxField(name, body, raw);
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxListField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxListField.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxListField.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxListField.java Fri Feb 20 12:28:04 2009
@@ -28,7 +28,7 @@
 /**
  * Mailbox-list field such as <code>From</code> or <code>Resent-From</code>.
  */
-public class MailboxListField extends Field {
+public class MailboxListField extends AbstractField {
     private static Log log = LogFactory.getLog(MailboxListField.class);
 
     private boolean parsed = false;
@@ -71,7 +71,7 @@
     }
 
     static class Parser implements FieldParser {
-        public Field parse(final String name, final String body,
+        public AbstractField parse(final String name, final String body,
                 final String raw) {
             return new MailboxListField(name, body, raw);
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/UnstructuredField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/UnstructuredField.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/UnstructuredField.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/UnstructuredField.java Fri Feb 20 12:28:04 2009
@@ -24,7 +24,7 @@
 /**
  * Simple unstructured field such as <code>Subject</code>.
  */
-public class UnstructuredField extends Field {
+public class UnstructuredField extends AbstractField {
     private boolean parsed = false;
 
     private String value;
@@ -49,7 +49,7 @@
     }
 
     static class Parser implements FieldParser {
-        public Field parse(final String name, final String body,
+        public AbstractField parse(final String name, final String body,
                 final String raw) {
             return new UnstructuredField(name, body, raw);
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Entity.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Entity.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Entity.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Entity.java Fri Feb 20 12:28:04 2009
@@ -27,7 +27,7 @@
 import org.apache.james.mime4j.field.ContentDispositionField;
 import org.apache.james.mime4j.field.ContentTransferEncodingField;
 import org.apache.james.mime4j.field.ContentTypeField;
-import org.apache.james.mime4j.field.Field;
+import org.apache.james.mime4j.field.AbstractField;
 import org.apache.james.mime4j.field.Fields;
 import org.apache.james.mime4j.util.MimeUtil;
 
@@ -264,10 +264,10 @@
      */
     public String getMimeType() {
         ContentTypeField child = 
-            (ContentTypeField) getHeader().getField(Field.CONTENT_TYPE);
+            (ContentTypeField) getHeader().getField(AbstractField.CONTENT_TYPE);
         ContentTypeField parent = getParent() != null 
             ? (ContentTypeField) getParent().getHeader().
-                                                getField(Field.CONTENT_TYPE)
+                                                getField(AbstractField.CONTENT_TYPE)
             : null;
         
         return ContentTypeField.getMimeType(child, parent);
@@ -280,7 +280,7 @@
      */
     public String getCharset() {
         return ContentTypeField.getCharset( 
-            (ContentTypeField) getHeader().getField(Field.CONTENT_TYPE));
+            (ContentTypeField) getHeader().getField(AbstractField.CONTENT_TYPE));
     }
     
     /**
@@ -290,7 +290,7 @@
      */
     public String getContentTransferEncoding() {
         ContentTransferEncodingField f = (ContentTransferEncodingField) 
-                        getHeader().getField(Field.CONTENT_TRANSFER_ENCODING);
+                        getHeader().getField(AbstractField.CONTENT_TRANSFER_ENCODING);
         
         return ContentTransferEncodingField.getEncoding(f);
     }
@@ -315,7 +315,7 @@
      *         type has been set.
      */
     public String getDispositionType() {
-        ContentDispositionField field = obtainField(Field.CONTENT_DISPOSITION);
+        ContentDispositionField field = obtainField(AbstractField.CONTENT_DISPOSITION);
         if (field == null)
             return null;
 
@@ -415,7 +415,7 @@
      *         <code>null</code> if the filename has not been set.
      */
     public String getFilename() {
-        ContentDispositionField field = obtainField(Field.CONTENT_DISPOSITION);
+        ContentDispositionField field = obtainField(AbstractField.CONTENT_DISPOSITION);
         if (field == null)
             return null;
 
@@ -435,7 +435,7 @@
     public void setFilename(String filename) {
         Header header = obtainHeader();
         ContentDispositionField field = (ContentDispositionField) header
-                .getField(Field.CONTENT_DISPOSITION);
+                .getField(AbstractField.CONTENT_DISPOSITION);
         if (field == null) {
             if (filename != null) {
                 header.setField(Fields.contentDisposition(
@@ -478,7 +478,7 @@
      */
     public boolean isMultipart() {
         ContentTypeField f = 
-            (ContentTypeField) getHeader().getField(Field.CONTENT_TYPE);
+            (ContentTypeField) getHeader().getField(AbstractField.CONTENT_TYPE);
         return f != null && f.getBoundary() != null 
             && getMimeType().startsWith(ContentTypeField.TYPE_MULTIPART_PREFIX);
     }
@@ -521,7 +521,7 @@
      * @return the header field or <code>null</code> if this entity has no
      *         header or the header contains no such field.
      */
-    <F extends Field> F obtainField(String fieldName) {
+    <F extends AbstractField> F obtainField(String fieldName) {
         Header header = getHeader();
         if (header == null)
             return null;

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Header.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Header.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Header.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Header.java Fri Feb 20 12:28:04 2009
@@ -30,8 +30,8 @@
 
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.MimeIOException;
-import org.apache.james.mime4j.field.Field;
 import org.apache.james.mime4j.parser.AbstractContentHandler;
+import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.parser.MimeStreamParser;
 
 /**
@@ -81,8 +81,8 @@
                 parser.stop();
             }
             @Override
-            public void field(String fieldData) throws MimeException {
-                addField(Field.parse(fieldData));
+            public void field(Field field) throws MimeException {
+                addField(field);
             }
         });
         try {

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Message.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Message.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Message.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/Message.java Fri Feb 20 12:28:04 2009
@@ -32,7 +32,7 @@
 import org.apache.james.mime4j.MimeIOException;
 import org.apache.james.mime4j.field.AddressListField;
 import org.apache.james.mime4j.field.DateTimeField;
-import org.apache.james.mime4j.field.Field;
+import org.apache.james.mime4j.field.AbstractField;
 import org.apache.james.mime4j.field.Fields;
 import org.apache.james.mime4j.field.MailboxField;
 import org.apache.james.mime4j.field.MailboxListField;
@@ -110,8 +110,9 @@
      * @throws MimeIOException
      *             on MIME protocol violations.
      */
-    public Message(InputStream is, MimeEntityConfig config) throws IOException,
-            MimeIOException {
+    public Message(
+            InputStream is, 
+            MimeEntityConfig config) throws IOException, MimeIOException {
         this(is, config, DefaultStorageProvider.getInstance());
     }
 
@@ -131,7 +132,9 @@
      * @throws MimeIOException
      *             on MIME protocol violations.
      */
-    public Message(InputStream is, MimeEntityConfig config,
+    public Message(
+            InputStream is, 
+            MimeEntityConfig config,
             StorageProvider storageProvider) throws IOException,
             MimeIOException {
         try {
@@ -166,7 +169,7 @@
      * @return the identifier of this message.
      */
     public String getMessageId() {
-        Field field = obtainField(Field.MESSAGE_ID);
+        AbstractField field = obtainField(AbstractField.MESSAGE_ID);
         if (field == null)
             return null;
 
@@ -195,7 +198,7 @@
      * @return the subject of this message.
      */
     public String getSubject() {
-        UnstructuredField field = obtainField(Field.SUBJECT);
+        UnstructuredField field = obtainField(AbstractField.SUBJECT);
         if (field == null)
             return null;
 
@@ -216,7 +219,7 @@
         Header header = obtainHeader();
 
         if (subject == null) {
-            header.removeFields(Field.SUBJECT);
+            header.removeFields(AbstractField.SUBJECT);
         } else {
             header.setField(Fields.subject(subject));
         }
@@ -229,7 +232,7 @@
      * @return the date of this message.
      */
     public Date getDate() {
-        DateTimeField dateField = obtainField(Field.DATE);
+        DateTimeField dateField = obtainField(AbstractField.DATE);
         if (dateField == null)
             return null;
 
@@ -264,9 +267,9 @@
         Header header = obtainHeader();
 
         if (date == null) {
-            header.removeFields(Field.DATE);
+            header.removeFields(AbstractField.DATE);
         } else {
-            header.setField(Fields.date(Field.DATE, date, zone));
+            header.setField(Fields.date(AbstractField.DATE, date, zone));
         }
     }
 
@@ -278,7 +281,7 @@
      * @return the sender of this message.
      */
     public Mailbox getSender() {
-        return getMailbox(Field.SENDER);
+        return getMailbox(AbstractField.SENDER);
     }
 
     /**
@@ -290,7 +293,7 @@
      *            field.
      */
     public void setSender(Mailbox sender) {
-        setMailbox(Field.SENDER, sender);
+        setMailbox(AbstractField.SENDER, sender);
     }
 
     /**
@@ -301,7 +304,7 @@
      * @return value of the from field of this message.
      */
     public MailboxList getFrom() {
-        return getMailboxList(Field.FROM);
+        return getMailboxList(AbstractField.FROM);
     }
 
     /**
@@ -313,7 +316,7 @@
      *            field.
      */
     public void setFrom(Mailbox from) {
-        setMailboxList(Field.FROM, from);
+        setMailboxList(AbstractField.FROM, from);
     }
 
     /**
@@ -325,7 +328,7 @@
      *            remove the header field.
      */
     public void setFrom(Mailbox... from) {
-        setMailboxList(Field.FROM, from);
+        setMailboxList(AbstractField.FROM, from);
     }
 
     /**
@@ -337,7 +340,7 @@
      *            to remove the header field.
      */
     public void setFrom(Collection<Mailbox> from) {
-        setMailboxList(Field.FROM, from);
+        setMailboxList(AbstractField.FROM, from);
     }
 
     /**
@@ -348,7 +351,7 @@
      * @return value of the to field of this message.
      */
     public AddressList getTo() {
-        return getAddressList(Field.TO);
+        return getAddressList(AbstractField.TO);
     }
 
     /**
@@ -360,7 +363,7 @@
      *            field.
      */
     public void setTo(Address to) {
-        setAddressList(Field.TO, to);
+        setAddressList(AbstractField.TO, to);
     }
 
     /**
@@ -372,7 +375,7 @@
      *            remove the header field.
      */
     public void setTo(Address... to) {
-        setAddressList(Field.TO, to);
+        setAddressList(AbstractField.TO, to);
     }
 
     /**
@@ -384,7 +387,7 @@
      *            to remove the header field.
      */
     public void setTo(Collection<Address> to) {
-        setAddressList(Field.TO, to);
+        setAddressList(AbstractField.TO, to);
     }
 
     /**
@@ -395,7 +398,7 @@
      * @return value of the cc field of this message.
      */
     public AddressList getCc() {
-        return getAddressList(Field.CC);
+        return getAddressList(AbstractField.CC);
     }
 
     /**
@@ -407,7 +410,7 @@
      *            field.
      */
     public void setCc(Address cc) {
-        setAddressList(Field.CC, cc);
+        setAddressList(AbstractField.CC, cc);
     }
 
     /**
@@ -419,7 +422,7 @@
      *            remove the header field.
      */
     public void setCc(Address... cc) {
-        setAddressList(Field.CC, cc);
+        setAddressList(AbstractField.CC, cc);
     }
 
     /**
@@ -431,7 +434,7 @@
      *            to remove the header field.
      */
     public void setCc(Collection<Address> cc) {
-        setAddressList(Field.CC, cc);
+        setAddressList(AbstractField.CC, cc);
     }
 
     /**
@@ -442,7 +445,7 @@
      * @return value of the bcc field of this message.
      */
     public AddressList getBcc() {
-        return getAddressList(Field.BCC);
+        return getAddressList(AbstractField.BCC);
     }
 
     /**
@@ -454,7 +457,7 @@
      *            field.
      */
     public void setBcc(Address bcc) {
-        setAddressList(Field.BCC, bcc);
+        setAddressList(AbstractField.BCC, bcc);
     }
 
     /**
@@ -466,7 +469,7 @@
      *            remove the header field.
      */
     public void setBcc(Address... bcc) {
-        setAddressList(Field.BCC, bcc);
+        setAddressList(AbstractField.BCC, bcc);
     }
 
     /**
@@ -478,7 +481,7 @@
      *            to remove the header field.
      */
     public void setBcc(Collection<Address> bcc) {
-        setAddressList(Field.BCC, bcc);
+        setAddressList(AbstractField.BCC, bcc);
     }
 
     /**
@@ -489,7 +492,7 @@
      * @return value of the reply to field of this message.
      */
     public AddressList getReplyTo() {
-        return getAddressList(Field.REPLY_TO);
+        return getAddressList(AbstractField.REPLY_TO);
     }
 
     /**
@@ -501,7 +504,7 @@
      *            field.
      */
     public void setReplyTo(Address replyTo) {
-        setAddressList(Field.REPLY_TO, replyTo);
+        setAddressList(AbstractField.REPLY_TO, replyTo);
     }
 
     /**
@@ -513,7 +516,7 @@
      *            remove the header field.
      */
     public void setReplyTo(Address... replyTo) {
-        setAddressList(Field.REPLY_TO, replyTo);
+        setAddressList(AbstractField.REPLY_TO, replyTo);
     }
 
     /**
@@ -525,7 +528,7 @@
      *            to remove the header field.
      */
     public void setReplyTo(Collection<Address> replyTo) {
-        setAddressList(Field.REPLY_TO, replyTo);
+        setAddressList(AbstractField.REPLY_TO, replyTo);
     }
 
     private Mailbox getMailbox(String fieldName) {

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/MessageBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/MessageBuilder.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/MessageBuilder.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/MessageBuilder.java Fri Feb 20 12:28:04 2009
@@ -27,8 +27,9 @@
 import org.apache.james.mime4j.codec.Base64InputStream;
 import org.apache.james.mime4j.codec.QuotedPrintableInputStream;
 import org.apache.james.mime4j.descriptor.BodyDescriptor;
-import org.apache.james.mime4j.field.Field;
+import org.apache.james.mime4j.field.AbstractField;
 import org.apache.james.mime4j.parser.ContentHandler;
+import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.parser.MimeStreamParser;
 import org.apache.james.mime4j.storage.StorageProvider;
 import org.apache.james.mime4j.util.MimeUtil;
@@ -93,9 +94,10 @@
     /**
      * @see org.apache.james.mime4j.parser.ContentHandler#field(java.lang.String)
      */
-    public void field(String fieldData) throws MimeException {
+    public void field(Field field) throws MimeException {
         expect(Header.class);
-        ((Header) stack.peek()).addField(Field.parse(fieldData));
+        Field parsedfield = AbstractField.parse(field.getRaw()); 
+        ((Header) stack.peek()).addField(parsedfield);
     }
     
     /**

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/MessageWriter.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/MessageWriter.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/MessageWriter.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/MessageWriter.java Fri Feb 20 12:28:04 2009
@@ -32,7 +32,8 @@
 import org.apache.james.mime4j.MimeIOException;
 import org.apache.james.mime4j.codec.CodecUtil;
 import org.apache.james.mime4j.field.ContentTypeField;
-import org.apache.james.mime4j.field.Field;
+import org.apache.james.mime4j.field.AbstractField;
+import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.CharsetUtil;
 import org.apache.james.mime4j.util.MimeUtil;
 
@@ -224,7 +225,7 @@
     public void writeHeader(Header header, OutputStream out)
             throws IOException, MimeIOException {
         Writer writer = getWriter((ContentTypeField) header
-                .getField(Field.CONTENT_TYPE), out);
+                .getField(AbstractField.CONTENT_TYPE), out);
 
         try {
             for (Field field : header) {
@@ -271,7 +272,7 @@
                     "Missing header in parent entity");
 
         ContentTypeField contentType = (ContentTypeField) header
-                .getField(Field.CONTENT_TYPE);
+                .getField(AbstractField.CONTENT_TYPE);
         if (contentType == null)
             throw new IllegalArgumentException(
                     "Content-Type field not specified");

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/SimpleContentHandler.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/SimpleContentHandler.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/SimpleContentHandler.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/SimpleContentHandler.java Fri Feb 20 12:28:04 2009
@@ -23,8 +23,8 @@
 import org.apache.james.mime4j.codec.Base64InputStream;
 import org.apache.james.mime4j.codec.QuotedPrintableInputStream;
 import org.apache.james.mime4j.descriptor.BodyDescriptor;
-import org.apache.james.mime4j.field.Field;
 import org.apache.james.mime4j.parser.AbstractContentHandler;
+import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.MimeUtil;
 
 import java.io.InputStream;
@@ -72,11 +72,11 @@
     }
 
     /**
-     * @see org.apache.james.mime4j.parser.AbstractContentHandler#field(java.lang.String)
+     * @see org.apache.james.mime4j.parser.AbstractContentHandler#field(Field)
      */
     @Override
-    public final void field(String fieldData) throws MimeException {
-        currHeader.addField(Field.parse(fieldData));
+    public final void field(Field field) throws MimeException {
+        currHeader.addField(field);
     }
 
     /**

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/AbstractContentHandler.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/AbstractContentHandler.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/AbstractContentHandler.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/AbstractContentHandler.java Fri Feb 20 12:28:04 2009
@@ -77,9 +77,9 @@
     }
     
     /**
-     * @see org.apache.james.mime4j.parser.ContentHandler#field(java.lang.String)
+     * @see org.apache.james.mime4j.parser.ContentHandler#field(Field)
      */
-    public void field(String fieldData) throws MimeException {
+    public void field(Field field) throws MimeException {
     }
     
     /**

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/AbstractEntity.java Fri Feb 20 12:28:04 2009
@@ -55,7 +55,7 @@
     private final CharArrayBuffer fieldbuf;
 
     private int lineCount;
-    private String field, fieldName, fieldValue;
+    private Field field;
     private boolean endOfHeader;
     private int headerCount;
 
@@ -195,7 +195,10 @@
             fieldbuf.setLength(len);
             
             boolean valid = true;
-            field = fieldbuf.toString();
+            
+            String fieldName = null;
+            String fieldValue = null;
+            
             int pos = fieldbuf.indexOf(':');
             if (pos <= 0) {
                 monitor(Event.INALID_HEADER);
@@ -212,7 +215,8 @@
                 fieldValue = fieldbuf.substring(pos + 1, fieldbuf.length());
             }
             if (valid) {
-                body.addField(fieldName, fieldValue);            
+                field = new RawField(fieldName, fieldValue, fieldbuf.toString());
+                body.addField(field);            
                 return true;
             }
         }
@@ -248,7 +252,7 @@
      * @throws IllegalStateException {@link #getState()} returns another
      *   value than {@link EntityStates#T_FIELD}.
      */
-    public String getField() {
+    public Field getField() {
         switch (getState()) {
         case EntityStates.T_FIELD:
             return field;
@@ -258,36 +262,6 @@
     }
 
     /**
-     * This method is valid, if {@link #getState()} returns {@link EntityStates#T_FIELD}.
-     * @return String with the fields name.
-     * @throws IllegalStateException {@link #getState()} returns another
-     *   value than {@link EntityStates#T_FIELD}.
-     */
-    public String getFieldName() {
-        switch (getState()) {
-        case EntityStates.T_FIELD:
-            return fieldName;
-        default:
-            throw new IllegalStateException("Invalid state :" + stateToString(state));
-        }
-    }
-
-    /**
-     * This method is valid, if {@link #getState()} returns {@link EntityStates#T_FIELD}.
-     * @return String with the fields value.
-     * @throws IllegalStateException {@link #getState()} returns another
-     *   value than {@link EntityStates#T_FIELD}.
-     */
-    public String getFieldValue() {
-        switch (getState()) {
-        case EntityStates.T_FIELD:
-            return fieldValue;
-        default:
-            throw new IllegalStateException("Invalid state :" + stateToString(state));
-        }
-    }
-
-    /**
      * Monitors the given event.
      * Subclasses may override to perform actions upon events.
      * Base implementation logs at warn.

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/ContentHandler.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/ContentHandler.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/ContentHandler.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/ContentHandler.java Fri Feb 20 12:28:04 2009
@@ -121,12 +121,10 @@
     /**
      * Called for each field of a header.
      * 
-     * @param fieldData the raw contents of the field 
-     *        (<code>Field-Name: field value</code>). The value will not be 
-     *        unfolded.
+     * @param field the MIME field.
      * @throws MimeException on processing errors
      */
-    void field(String fieldData) throws MimeException;
+    void field(Field field) throws MimeException;
 
     /**
      * Called when there are no more header fields in a message or body part.

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/EntityStateMachine.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/EntityStateMachine.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/EntityStateMachine.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/EntityStateMachine.java Fri Feb 20 12:28:04 2009
@@ -98,26 +98,6 @@
      * @throws IllegalStateException if a header field cannot be
      *  obtained at the current stage of the parsing process. 
      */
-    String getField() throws IllegalStateException;
-    
-    /**
-     * Returns name of the current header field.
-     * 
-     * @return field name
-     * 
-     * @throws IllegalStateException if a header field cannot be
-     *  obtained at the current stage of the parsing process. 
-     */
-    String getFieldName() throws IllegalStateException;
-
-    /**
-     * Returns value of the current header field.
-     * 
-     * @return field value
-     * 
-     * @throws IllegalStateException if a header field cannot be
-     *  obtained at the current stage of the parsing process. 
-     */
-    String getFieldValue() throws IllegalStateException;
+    Field getField() throws IllegalStateException;
     
 }

Added: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/Field.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/Field.java?rev=746223&view=auto
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/Field.java (added)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/Field.java Fri Feb 20 12:28:04 2009
@@ -0,0 +1,48 @@
+/****************************************************************
+ * 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.parser;
+
+/**
+ * Abstract MIME field.
+ */
+public interface Field {
+    
+    /**
+     * Gets the name of the field (<code>Subject</code>, <code>From</code>, etc).
+     * 
+     * @return the field name.
+     */
+    String getName();
+
+    /**
+     * Gets the unparsed and possibly encoded (see RFC 2047) field body string.
+     * 
+     * @return the unfolded unparsed field body string.
+     */
+    String getBody();
+
+    /**
+     * Gets the original raw field string.
+     * 
+     * @return the original raw field string.
+     */
+    String getRaw();
+    
+}

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeEntity.java Fri Feb 20 12:28:04 2009
@@ -94,7 +94,10 @@
             throw new IllegalStateException("Invalid state: " + stateToString(state));
         }
         skipHeader = true;
-        body.addField("Content-Type", contentType);
+        body.addField(new RawField(
+                "Content-Type", 
+                contentType,
+                "Content-Type: " +contentType));
     }
     
     @Override

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/MimeTokenStream.java Fri Feb 20 12:28:04 2009
@@ -339,31 +339,11 @@
      * @throws IllegalStateException {@link #getState()} returns another
      *   value than {@link #T_FIELD}.
      */
-    public String getField() {
+    public Field getField() {
         return currentStateMachine.getField();
     }
     
     /**
-     * This method is valid, if {@link #getState()} returns {@link #T_FIELD}.
-     * @return String with the fields name.
-     * @throws IllegalStateException {@link #getState()} returns another
-     *   value than {@link #T_FIELD}.
-     */
-    public String getFieldName() {
-        return currentStateMachine.getFieldName();
-    }
-
-    /**
-     * This method is valid, if {@link #getState()} returns {@link #T_FIELD}.
-     * @return String with the fields value.
-     * @throws IllegalStateException {@link #getState()} returns another
-     *   value than {@link #T_FIELD}.
-     */
-    public String getFieldValue() {
-        return currentStateMachine.getFieldValue();
-    }
-
-    /**
      * This method advances the token stream to the next token.
      * @throws IllegalStateException The method has been called, although
      *   {@link #getState()} was already {@link #T_END_OF_STREAM}.

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/RawEntity.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/RawEntity.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/RawEntity.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/RawEntity.java Fri Feb 20 12:28:04 2009
@@ -71,7 +71,7 @@
     /**
      * This method has no effect and always returns <code>null</code>.
      */
-    public String getField() {
+    public Field getField() {
         return null;
     }
 

Added: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/RawField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/RawField.java?rev=746223&view=auto
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/RawField.java (added)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/RawField.java Fri Feb 20 12:28:04 2009
@@ -0,0 +1,54 @@
+/****************************************************************
+ * 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.parser;
+
+/**
+ * The basic immutable MIME field.
+ */
+public class RawField implements Field {
+    
+    private final String name;
+    private final String body;
+    private final String raw;
+    
+    public RawField(String name, String body, String raw) {
+        super();
+        this.name = name;
+        this.body = body;
+        this.raw = raw;
+    }
+    
+    public String getName() {
+        return this.name;
+    }
+
+    public String getBody() {
+        return this.body;
+    }
+
+    public String getRaw() {
+        return this.raw;
+    }
+    
+    public String toString() {
+        return this.raw;
+    }
+    
+}

Propchange: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/parser/RawField.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/StringArrayMap.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/StringArrayMap.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/StringArrayMap.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/util/StringArrayMap.java Fri Feb 20 12:28:04 2009
@@ -29,7 +29,7 @@
 import java.util.Map;
 import java.util.NoSuchElementException;
 
-import org.apache.james.mime4j.field.Field;
+import org.apache.james.mime4j.field.AbstractField;
 import org.apache.james.mime4j.message.Header;
 import org.apache.james.mime4j.parser.ContentHandler;
 
@@ -40,7 +40,7 @@
  * <p>
  * Note that this class is not directly used anywhere in Mime4j.
  * Instead a user might choose to use it instead of {@link Header}
- * and {@link Field} in a custom {@link ContentHandler} implementation.
+ * and {@link AbstractField} in a custom {@link ContentHandler} implementation.
  * See also MIME4j-24.
  */
 public class StringArrayMap implements Serializable {

Modified: james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/BaseTestForBodyDescriptors.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/BaseTestForBodyDescriptors.java?rev=746223&r1=746222&r2=746223&view=diff
==============================================================================
--- james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/BaseTestForBodyDescriptors.java (original)
+++ james/mime4j/trunk/src/test/java/org/apache/james/mime4j/descriptor/BaseTestForBodyDescriptors.java Fri Feb 20 12:28:04 2009
@@ -21,6 +21,7 @@
 
 import org.apache.james.mime4j.descriptor.BodyDescriptor;
 import org.apache.james.mime4j.descriptor.MutableBodyDescriptor;
+import org.apache.james.mime4j.field.AbstractField;
 
 import junit.framework.TestCase;
 
@@ -34,25 +35,25 @@
         MutableBodyDescriptor bd = null;
         
         bd = newBodyDescriptor();
-        bd.addField("Content-Type ", "text/plain; charset=ISO-8859-1; "
-                + "boundary=foo; param1=value1; param2=value2; param3=value3");
+        bd.addField(AbstractField.parse("Content-Type ", "text/plain; charset=ISO-8859-1; "
+                + "boundary=foo; param1=value1; param2=value2; param3=value3"));
         assertEquals(3, bd.getContentTypeParameters().size());
         assertEquals("value1", bd.getContentTypeParameters().get("param1"));
         assertEquals("value2", bd.getContentTypeParameters().get("param2"));
         assertEquals("value3", bd.getContentTypeParameters().get("param3"));
         
         bd = newBodyDescriptor();
-        bd.addField("Content-Type ", "text/plain; param1=value1; param2=value2;"
-                     + " param3=value3");
+        bd.addField(AbstractField.parse("Content-Type ", "text/plain; param1=value1; param2=value2;"
+                     + " param3=value3"));
         assertEquals(3, bd.getContentTypeParameters().size());
         assertEquals("value1", bd.getContentTypeParameters().get("param1"));
         assertEquals("value2", bd.getContentTypeParameters().get("param2"));
         assertEquals("value3", bd.getContentTypeParameters().get("param3"));
         
         bd = newBodyDescriptor();
-        bd.addField("Content-Type ", "text/plain; "
+        bd.addField(AbstractField.parse("Content-Type ", "text/plain; "
                 + "param1= \" value with\tspaces \" ; "
-                + "param2=\"\\\"value4 with escaped \\\" \\\"\";");
+                + "param2=\"\\\"value4 with escaped \\\" \\\"\";"));
         assertEquals(2, bd.getContentTypeParameters().size());
         assertEquals(" value with\tspaces ", bd.getContentTypeParameters().get("param1"));
         assertEquals("\"value4 with escaped \" \"", bd.getContentTypeParameters().get("param2"));
@@ -62,7 +63,7 @@
          * The parameter value should be \n\"
          */
         bd = newBodyDescriptor();
-        bd.addField("Content-Type ", "text/plain; param=\"\\n\\\\\\\"\"");
+        bd.addField(AbstractField.parse("Content-Type ", "text/plain; param=\"\\n\\\\\\\"\""));
         assertEquals(1, bd.getContentTypeParameters().size());
         assertEquals("\\n\\\"", bd.getContentTypeParameters().get("param"));
     }
@@ -74,10 +75,10 @@
          * Make sure that only the first Content-Type header added is used.
          */
         bd = newBodyDescriptor();
-        bd.addField("Content-Type ", "text/plain; charset=ISO-8859-1");
+        bd.addField(AbstractField.parse("Content-Type ", "text/plain; charset=ISO-8859-1"));
         assertEquals("text/plain", bd.getMimeType());
         assertEquals("iso-8859-1", bd.getCharset());
-        bd.addField("Content-Type ", "text/html; charset=us-ascii");
+        bd.addField(AbstractField.parse("Content-Type ", "text/html; charset=us-ascii"));
         assertEquals("text/plain", bd.getMimeType());
         assertEquals("iso-8859-1", bd.getCharset());
     }
@@ -86,32 +87,32 @@
         MutableBodyDescriptor bd = null;
         
         bd = newBodyDescriptor();
-        bd.addField("Content-Type ", "text/PLAIN");
+        bd.addField(AbstractField.parse("Content-Type ", "text/PLAIN"));
         assertEquals("text/plain", bd.getMimeType());
         
         bd = newBodyDescriptor();
-        bd.addField("Content-Type ", "text/PLAIN;");
+        bd.addField(AbstractField.parse("Content-Type ", "text/PLAIN;"));
         assertEquals("text/plain", bd.getMimeType());
         
         bd = newBodyDescriptor();
-        bd.addField("content-type", "   TeXt / html   ");
+        bd.addField(AbstractField.parse("content-type", "   TeXt / html   "));
         assertEquals("text/html", bd.getMimeType());
         
         bd = newBodyDescriptor();
-        bd.addField("CONTENT-TYPE", "   x-app/yada ;  param = yada");
+        bd.addField(AbstractField.parse("CONTENT-TYPE", "   x-app/yada ;  param = yada"));
         assertEquals("x-app/yada", bd.getMimeType());
         
         bd = newBodyDescriptor();
-        bd.addField("CONTENT-TYPE", "   yada");
+        bd.addField(AbstractField.parse("CONTENT-TYPE", "   yada"));
         assertEquals("text/plain", bd.getMimeType());
         
         /*
          * Make sure that only the first Content-Type header added is used.
          */
         bd = newBodyDescriptor();
-        bd.addField("Content-Type ", "text/plain");
+        bd.addField(AbstractField.parse("Content-Type ", "text/plain"));
         assertEquals("text/plain", bd.getMimeType());
-        bd.addField("Content-Type ", "text/html");
+        bd.addField(AbstractField.parse("Content-Type ", "text/html"));
         assertEquals("text/plain", bd.getMimeType());
         
         /*
@@ -121,19 +122,19 @@
         MutableBodyDescriptor parent = null;
         
         parent = newBodyDescriptor();
-        parent.addField("Content-Type", "mutlipart/alternative; boundary=foo");
+        parent.addField(AbstractField.parse("Content-Type", "mutlipart/alternative; boundary=foo"));
         
         child = newBodyDescriptor(parent);
         assertEquals("text/plain", child.getMimeType());
-        child.addField("Content-Type", " child/type");
+        child.addField(AbstractField.parse("Content-Type", " child/type"));
         assertEquals("child/type", child.getMimeType());
         
         parent = newBodyDescriptor();
-        parent.addField("Content-Type", "multipart/digest; boundary=foo");
+        parent.addField(AbstractField.parse("Content-Type", "multipart/digest; boundary=foo"));
         
         child = newBodyDescriptor(parent);
         assertEquals("message/rfc822", child.getMimeType());
-        child.addField("Content-Type", " child/type");
+        child.addField(AbstractField.parse("Content-Type", " child/type"));
         assertEquals("child/type", child.getMimeType());
         
     }
@@ -146,40 +147,40 @@
          */
         bd = newBodyDescriptor();
         assertEquals("us-ascii", bd.getCharset());
-        bd.addField("Content-Type ", "text/type; charset=ISO-8859-1");
+        bd.addField(AbstractField.parse("Content-Type ", "text/type; charset=ISO-8859-1"));
         assertEquals("iso-8859-1", bd.getCharset());
         
         bd = newBodyDescriptor();
         assertEquals("us-ascii", bd.getCharset());
-        bd.addField("Content-Type ", "text/type");
+        bd.addField(AbstractField.parse("Content-Type ", "text/type"));
         assertEquals("us-ascii", bd.getCharset());
         
         /*
          * Test boundary.
          */
         bd = newBodyDescriptor();
-        bd.addField("Content-Type", "text/html; boundary=yada yada");
+        bd.addField(AbstractField.parse("Content-Type", "text/html; boundary=yada yada"));
         assertNull(bd.getBoundary());
 
         bd = newBodyDescriptor();
-        bd.addField("Content-Type", "multipart/yada; boundary=yada");
+        bd.addField(AbstractField.parse("Content-Type", "multipart/yada; boundary=yada"));
         assertEquals("yada", bd.getBoundary());
 
         /*
          * Test some weird parameters.
          */
         bd = newBodyDescriptor();
-        bd.addField("Content-Type", "multipart/yada; boundary=yada yada");
+        bd.addField(AbstractField.parse("Content-Type", "multipart/yada; boundary=yada yada"));
         assertEquals("yada", bd.getBoundary());
         
         bd = newBodyDescriptor();
-        bd.addField("Content-Type", "multipart/yada; boUNdarY= ya:*da; \tcharset\t =  big5");
+        bd.addField(AbstractField.parse("Content-Type", "multipart/yada; boUNdarY= ya:*da; \tcharset\t =  big5"));
         assertEquals("ya:*da", bd.getBoundary());
         assertEquals("big5", bd.getCharset());
         
         bd = newBodyDescriptor();
-        bd.addField("Content-Type", "multipart/yada; boUNdarY= \"ya \\\"\\\"\tda \\\"\"; "
-                            + "\tcharset\t =  \"\\\"hepp\\\"  =us\t-ascii\"");
+        bd.addField(AbstractField.parse("Content-Type", "multipart/yada; boUNdarY= \"ya \\\"\\\"\tda \\\"\"; "
+                            + "\tcharset\t =  \"\\\"hepp\\\"  =us\t-ascii\""));
         assertEquals("ya \"\"\tda \"", bd.getBoundary());
         assertEquals("\"hepp\"  =us\t-ascii", bd.getCharset());
         
@@ -191,23 +192,23 @@
         bd = newBodyDescriptor();
         assertEquals(-1, bd.getContentLength());
 
-        bd.addField("Content-Length", "9901");
+        bd.addField(AbstractField.parse("Content-Length", "9901"));
         assertEquals(9901, bd.getContentLength());
 
         // only the first content-length counts
-        bd.addField("Content-Length", "1239901");
+        bd.addField(AbstractField.parse("Content-Length", "1239901"));
         assertEquals(9901, bd.getContentLength());
     }
     
     public void testDoDefaultToUsAsciiWhenUntyped() throws Exception {
         MutableBodyDescriptor descriptor = newBodyDescriptor();
-        descriptor.addField("To", "me@example.org");
+        descriptor.addField(AbstractField.parse("To", "me@example.org"));
         assertEquals("us-ascii", descriptor.getCharset());
     }
 
     public void testDoNotDefaultToUsAsciiForNonTextTypes() throws Exception {
         MutableBodyDescriptor descriptor = newBodyDescriptor();
-        descriptor.addField("Content-Type", "image/png; name=blob.png");
+        descriptor.addField(AbstractField.parse("Content-Type", "image/png; name=blob.png"));
         assertNull(descriptor.getCharset());
     }
 }



Mime
View raw message