james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1126712 [1/2] - in /james/mime4j/trunk: core/src/main/java/org/apache/james/mime4j/util/ dom/src/main/java/org/apache/james/mime4j/dom/field/ dom/src/main/java/org/apache/james/mime4j/field/ dom/src/main/java/org/apache/james/mime4j/messag...
Date Mon, 23 May 2011 20:20:45 GMT
Author: olegk
Date: Mon May 23 20:20:44 2011
New Revision: 1126712

URL: http://svn.apache.org/viewvc?rev=1126712&view=rev
Log:
Follow-up to MIME4J-116: parsing code moved from body descriptors to individual field impls; body descriptors are now collections of lazily parsed fields

Added:
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentDescriptionField.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentIdField.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLanguageField.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLengthField.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLocationField.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentMD5Field.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/MimeVersionField.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentDescriptionFieldImpl.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentIdFieldImpl.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLanguageFieldImpl.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLengthFieldImpl.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLocationFieldImpl.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentMD5FieldImpl.java   (with props)
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/MimeVersionFieldImpl.java   (with props)
Modified:
    james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/util/MimeUtil.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentDispositionField.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentTransferEncodingField.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/FieldName.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingFieldImpl.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/DefaultFieldParser.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MaximalBodyDescriptor.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MinimalBodyDescriptor.java
    james/mime4j/trunk/dom/src/test/java/org/apache/james/mime4j/message/MaximalBodyDescriptorTest.java

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/util/MimeUtil.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/util/MimeUtil.java?rev=1126712&r1=1126711&r2=1126712&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/util/MimeUtil.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/util/MimeUtil.java Mon May 23 20:20:44 2011
@@ -54,58 +54,6 @@ public final class MimeUtil {
      */
     public static final String ENC_7BIT = "7bit";
 
-    /** <code>MIME-Version</code> header name (lowercase) */
-    public static final String MIME_HEADER_MIME_VERSION = "mime-version";
-    /** <code>Content-ID</code> header name (lowercase) */
-    public static final String MIME_HEADER_CONTENT_ID = "content-id";
-    /** <code>Content-Description</code> header name (lowercase) */
-    public static final String MIME_HEADER_CONTENT_DESCRIPTION = "content-description";
-    /** 
-     * <code>Content-Disposition</code> header name (lowercase). 
-     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>. 
-     */
-    public static final String MIME_HEADER_CONTENT_DISPOSITION = "content-disposition";
-    /** 
-     * <code>Content-Disposition</code> filename parameter (lowercase). 
-     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>. 
-     */
-    public static final String PARAM_FILENAME = "filename";
-    /** 
-     * <code>Content-Disposition</code> modification-date parameter (lowercase). 
-     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>. 
-     */
-    public static final String PARAM_MODIFICATION_DATE = "modification-date";
-    /** 
-     * <code>Content-Disposition</code> creation-date parameter (lowercase). 
-     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>. 
-     */
-    public static final String PARAM_CREATION_DATE = "creation-date";
-    /** 
-     * <code>Content-Disposition</code> read-date parameter (lowercase). 
-     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>. 
-     */
-    public static final String PARAM_READ_DATE = "read-date";
-    /** 
-     * <code>Content-Disposition</code> size parameter (lowercase). 
-     * See <a href='http://www.faqs.org/rfcs/rfc2183.html'>RFC2183</a>. 
-     */
-    public static final String PARAM_SIZE = "size";
-    /**
-     * <code>Content-Langauge</code> header (lower case).
-     * See <a href='http://www.faqs.org/rfcs/rfc4646.html'>RFC4646</a>.
-     */
-    public static final String MIME_HEADER_LANGAUGE = "content-language";
-    /**
-     * <code>Content-Location</code> header (lower case).
-     * See <a href='http://www.faqs.org/rfcs/rfc2557.html'>RFC2557</a>.
-     */
-    public static final String MIME_HEADER_LOCATION = "content-location";
-    /**
-     * <code>Content-MD5</code> header (lower case).
-     * See <a href='http://www.faqs.org/rfcs/rfc1864.html'>RFC1864</a>.
-     */
-    public static final String MIME_HEADER_MD5 = "content-md5";
-
     // used to create unique ids
     private static final Random random = new Random();
     

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentDescriptionField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentDescriptionField.java?rev=1126712&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentDescriptionField.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentDescriptionField.java Mon May 23 20:20:44 2011
@@ -0,0 +1,31 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.dom.field;
+
+public interface ContentDescriptionField extends ParsedField {
+
+    /**
+     * Gets the content description defined in this field.
+     * 
+     * @return the content description or <code>null</code> if not set.
+     */
+    String getDescription();
+
+}
\ No newline at end of file

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentDescriptionField.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentDescriptionField.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentDescriptionField.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentDispositionField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentDispositionField.java?rev=1126712&r1=1126711&r2=1126712&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentDispositionField.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentDispositionField.java Mon May 23 20:20:44 2011
@@ -88,7 +88,7 @@ public interface ContentDispositionField
      * @return <code>true</code> if the disposition type of this field is
      *         <i>attachment</i>, <code>false</code> otherwise.
      */
-    public abstract boolean isAttachment();
+    boolean isAttachment();
 
     /**
      * Gets the value of the <code>filename</code> parameter if set.

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentIdField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentIdField.java?rev=1126712&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentIdField.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentIdField.java Mon May 23 20:20:44 2011
@@ -0,0 +1,31 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.dom.field;
+
+public interface ContentIdField extends ParsedField {
+
+    /**
+     * Gets the content ID defined in this field.
+     * 
+     * @return the content ID or <code>null</code> if not set.
+     */
+    String getId();
+
+}
\ No newline at end of file

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentIdField.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentIdField.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentIdField.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLanguageField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLanguageField.java?rev=1126712&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLanguageField.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLanguageField.java Mon May 23 20:20:44 2011
@@ -0,0 +1,33 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.dom.field;
+
+import java.util.List;
+
+public interface ContentLanguageField extends ParsedField {
+
+    /**
+     * Gets the content language(s) defined in this field.
+     * 
+     * @return a list of content language(s).
+     */
+    List<String> getLanguages();
+
+}
\ No newline at end of file

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLanguageField.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLanguageField.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLanguageField.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLengthField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLengthField.java?rev=1126712&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLengthField.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLengthField.java Mon May 23 20:20:44 2011
@@ -0,0 +1,31 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.dom.field;
+
+public interface ContentLengthField extends ParsedField {
+
+    /**
+     * Gets the content length value defined in this field.
+     * 
+     * @return the content length value.
+     */
+    long getContentLength();
+
+}
\ No newline at end of file

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLengthField.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLengthField.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLengthField.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLocationField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLocationField.java?rev=1126712&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLocationField.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLocationField.java Mon May 23 20:20:44 2011
@@ -0,0 +1,31 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.dom.field;
+
+public interface ContentLocationField extends ParsedField {
+
+    /**
+     * Gets the content location defined in this field.
+     * 
+     * @return the content location or <code>null</code> if not set.
+     */
+    String getLocation();
+
+}
\ No newline at end of file

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLocationField.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLocationField.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentLocationField.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentMD5Field.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentMD5Field.java?rev=1126712&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentMD5Field.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentMD5Field.java Mon May 23 20:20:44 2011
@@ -0,0 +1,31 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.dom.field;
+
+public interface ContentMD5Field extends ParsedField {
+
+    /**
+     * Gets the content MD5 raw value defined in this field.
+     * 
+     * @return the content MD5 raw value or <code>null</code> if not set.
+     */
+    String getMD5Raw();
+
+}
\ No newline at end of file

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentMD5Field.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentMD5Field.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentMD5Field.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentTransferEncodingField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentTransferEncodingField.java?rev=1126712&r1=1126711&r2=1126712&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentTransferEncodingField.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/ContentTransferEncodingField.java Mon May 23 20:20:44 2011
@@ -24,7 +24,7 @@ public interface ContentTransferEncoding
     /**
      * Gets the encoding defined in this field.
      * 
-     * @return the encoding or an empty string if not set.
+     * @return the content ID or <code>null</code> if not set.
      */
     String getEncoding();
 

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/FieldName.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/FieldName.java?rev=1126712&r1=1126711&r2=1126712&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/FieldName.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/FieldName.java Mon May 23 20:20:44 2011
@@ -24,10 +24,17 @@ package org.apache.james.mime4j.dom.fiel
  */
 public class FieldName {
 
-    public static final String CONTENT_DISPOSITION = "Content-Disposition";
-    public static final String CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding";
     public static final String CONTENT_TYPE = "Content-Type";
+    public static final String CONTENT_LENGTH = "Content-Length";
+    public static final String CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding";
+    public static final String CONTENT_DISPOSITION = "Content-Disposition";
+    public static final String CONTENT_ID = "Content-ID";
+    public static final String CONTENT_MD5 = "Content-MD5";
+    public static final String CONTENT_DESCRIPTION = "Content-Description";
+    public static final String CONTENT_LANGUAGE = "Content-Language";
+    public static final String CONTENT_LOCATION = "Content-Location";
 
+    public static final String MIME_VERSION = "MIME-Version";
     public static final String DATE = "Date";
     public static final String MESSAGE_ID = "Message-ID";
     public static final String SUBJECT = "Subject";

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/MimeVersionField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/MimeVersionField.java?rev=1126712&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/MimeVersionField.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/MimeVersionField.java Mon May 23 20:20:44 2011
@@ -0,0 +1,28 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you under the Apache License, Version 2.0 (the            *
+ * "License"); you may not use this file except in compliance   *
+ * with the License.  You may obtain a copy of the License at   *
+ *                                                              *
+ *   http://www.apache.org/licenses/LICENSE-2.0                 *
+ *                                                              *
+ * Unless required by applicable law or agreed to in writing,   *
+ * software distributed under the License is distributed on an  *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY       *
+ * KIND, either express or implied.  See the License for the    *
+ * specific language governing permissions and limitations      *
+ * under the License.                                           *
+ ****************************************************************/
+
+package org.apache.james.mime4j.dom.field;
+
+public interface MimeVersionField extends ParsedField {
+
+    int getMinorVersion();
+
+    int getMajorVersion();
+
+}
\ No newline at end of file

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/MimeVersionField.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/MimeVersionField.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/field/MimeVersionField.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentDescriptionFieldImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentDescriptionFieldImpl.java?rev=1126712&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentDescriptionFieldImpl.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentDescriptionFieldImpl.java Mon May 23 20:20:44 2011
@@ -0,0 +1,64 @@
+/****************************************************************
+ * 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.field;
+
+import org.apache.james.mime4j.codec.DecodeMonitor;
+import org.apache.james.mime4j.dom.field.ContentDescriptionField;
+import org.apache.james.mime4j.stream.FieldParser;
+import org.apache.james.mime4j.util.ByteSequence;
+
+/**
+ * Represents a <code>Content-Description</code> field.
+ */
+public class ContentDescriptionFieldImpl extends AbstractField implements ContentDescriptionField {
+
+    private boolean parsed = false;
+    private String description;
+
+    ContentDescriptionFieldImpl(String name, String body, ByteSequence raw, DecodeMonitor monitor) {
+        super(name, body, raw, monitor);
+    }
+
+    private void parse() {
+        parsed = true;
+        String body = getBody();
+        if (body != null) {
+            description = body.trim();
+        } else {
+            description = null;
+        }
+    }
+    
+    public String getDescription() {
+        if (!parsed) {
+            parse();
+        }
+        return description;
+    }
+
+    public static final FieldParser<ContentDescriptionField> PARSER = new FieldParser<ContentDescriptionField>() {
+        public ContentDescriptionField parse(final String name, final String body,
+                final ByteSequence raw, DecodeMonitor monitor) {
+            return new ContentDescriptionFieldImpl(name, body, raw, monitor);
+        }
+    };
+
+}
+

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentDescriptionFieldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentDescriptionFieldImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentDescriptionFieldImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentIdFieldImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentIdFieldImpl.java?rev=1126712&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentIdFieldImpl.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentIdFieldImpl.java Mon May 23 20:20:44 2011
@@ -0,0 +1,64 @@
+/****************************************************************
+ * 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.field;
+
+import org.apache.james.mime4j.codec.DecodeMonitor;
+import org.apache.james.mime4j.dom.field.ContentIdField;
+import org.apache.james.mime4j.stream.FieldParser;
+import org.apache.james.mime4j.util.ByteSequence;
+
+/**
+ * Represents a <code>Content-Transfer-Encoding</code> field.
+ */
+public class ContentIdFieldImpl extends AbstractField implements ContentIdField {
+
+    private boolean parsed = false;
+    private String id;
+
+    ContentIdFieldImpl(String name, String body, ByteSequence raw, DecodeMonitor monitor) {
+        super(name, body, raw, monitor);
+    }
+
+    private void parse() {
+        parsed = true;
+        String body = getBody();
+        if (body != null) {
+            id = body.trim();
+        } else {
+            id = null;
+        }
+    }
+    
+    public String getId() {
+        if (!parsed) {
+            parse();
+        }
+        return id;
+    }
+
+    public static final FieldParser<ContentIdField> PARSER = new FieldParser<ContentIdField>() {
+        public ContentIdField parse(final String name, final String body,
+                final ByteSequence raw, DecodeMonitor monitor) {
+            return new ContentIdFieldImpl(name, body, raw, monitor);
+        }
+    };
+
+}
+

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentIdFieldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentIdFieldImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentIdFieldImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLanguageFieldImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLanguageFieldImpl.java?rev=1126712&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLanguageFieldImpl.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLanguageFieldImpl.java Mon May 23 20:20:44 2011
@@ -0,0 +1,82 @@
+/****************************************************************
+ * 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.field;
+
+import java.io.StringReader;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.james.mime4j.codec.DecodeMonitor;
+import org.apache.james.mime4j.dom.field.ContentLanguageField;
+import org.apache.james.mime4j.field.language.parser.ContentLanguageParser;
+import org.apache.james.mime4j.field.language.parser.ParseException;
+import org.apache.james.mime4j.stream.FieldParser;
+import org.apache.james.mime4j.util.ByteSequence;
+
+/**
+ * Represents a <code>Content-Transfer-Encoding</code> field.
+ */
+public class ContentLanguageFieldImpl extends AbstractField implements ContentLanguageField {
+
+    private boolean parsed = false;
+    private List<String> languages;
+    private ParseException parseException;
+
+    ContentLanguageFieldImpl(String name, String body, ByteSequence raw, DecodeMonitor monitor) {
+        super(name, body, raw, monitor);
+    }
+
+    private void parse() {
+        parsed = true;
+        String body = getBody();
+        if (body != null) {
+            ContentLanguageParser parser = new ContentLanguageParser(new StringReader(body));
+            try {
+                languages = parser.parse();
+            } catch (ParseException ex) {
+                parseException = ex;
+                languages = Collections.<String>emptyList();
+            }
+        } else {
+            languages = Collections.<String>emptyList();
+        }
+    }
+
+    @Override
+    public org.apache.james.mime4j.dom.field.ParseException getParseException() {
+        return parseException;
+    }
+
+    public List<String> getLanguages() {
+        if (!parsed) {
+            parse();
+        }
+        return languages;
+    }
+
+    public static final FieldParser<ContentLanguageField> PARSER = new FieldParser<ContentLanguageField>() {
+        public ContentLanguageField parse(final String name, final String body,
+                final ByteSequence raw, DecodeMonitor monitor) {
+            return new ContentLanguageFieldImpl(name, body, raw, monitor);
+        }
+    };
+
+}
+

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLanguageFieldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLanguageFieldImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLanguageFieldImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLengthFieldImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLengthFieldImpl.java?rev=1126712&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLengthFieldImpl.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLengthFieldImpl.java Mon May 23 20:20:44 2011
@@ -0,0 +1,77 @@
+/****************************************************************
+ * 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.field;
+
+import org.apache.james.mime4j.codec.DecodeMonitor;
+import org.apache.james.mime4j.dom.field.ContentLengthField;
+import org.apache.james.mime4j.stream.FieldParser;
+import org.apache.james.mime4j.util.ByteSequence;
+
+/**
+ * Represents a <code>Content-Length</code> field.
+ */
+public class ContentLengthFieldImpl extends AbstractField implements ContentLengthField {
+
+    private boolean parsed = false;
+    private long contentLength;
+
+    ContentLengthFieldImpl(String name, String body, ByteSequence raw, DecodeMonitor monitor) {
+        super(name, body, raw, monitor);
+    }
+
+    private void parse() {
+        parsed = true;
+        String body = getBody();
+        if (body != null) {
+            try {
+                long v = Long.parseLong(body);
+                if (v < 0) {
+                    if (monitor.warn("Negative content length: " + body, 
+                            "ignoring Content-Length header")) {
+                        contentLength = -1;
+                    }
+                } else {
+                    contentLength = v;
+                }
+            } catch (NumberFormatException e) {
+                if (monitor.warn("Invalid content length: " + body, 
+                        "ignoring Content-Length header")) {
+                    contentLength = -1;
+                }
+            }
+        } else {
+            contentLength = -1;
+        }
+    }
+    
+    public long getContentLength() {
+        if (!parsed) {
+            parse();
+        }
+        return contentLength;
+    }
+
+    public static final FieldParser<ContentLengthField> PARSER = new FieldParser<ContentLengthField>() {
+        public ContentLengthField parse(final String name, final String body,
+                final ByteSequence raw, DecodeMonitor monitor) {
+            return new ContentLengthFieldImpl(name, body, raw, monitor);
+        }
+    };
+}

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLengthFieldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLengthFieldImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLengthFieldImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLocationFieldImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLocationFieldImpl.java?rev=1126712&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLocationFieldImpl.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLocationFieldImpl.java Mon May 23 20:20:44 2011
@@ -0,0 +1,88 @@
+/****************************************************************
+ * 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.field;
+
+import java.io.StringReader;
+
+import org.apache.james.mime4j.codec.DecodeMonitor;
+import org.apache.james.mime4j.dom.field.ContentLocationField;
+import org.apache.james.mime4j.field.structured.parser.ParseException;
+import org.apache.james.mime4j.field.structured.parser.StructuredFieldParser;
+import org.apache.james.mime4j.stream.FieldParser;
+import org.apache.james.mime4j.util.ByteSequence;
+
+/**
+ * Represents a <code>Content-Transfer-Encoding</code> field.
+ */
+public class ContentLocationFieldImpl extends AbstractField implements ContentLocationField {
+
+    private boolean parsed = false;
+    private String location;
+    private ParseException parseException;
+
+    ContentLocationFieldImpl(String name, String body, ByteSequence raw, DecodeMonitor monitor) {
+        super(name, body, raw, monitor);
+    }
+
+    private void parse() {
+        parsed = true;
+        String body = getBody();
+        if (body != null) {
+            StringReader stringReader = new StringReader(body);
+            StructuredFieldParser parser = new StructuredFieldParser(stringReader);
+            try {
+                // From RFC2017 3.1
+                /*
+                 * Extraction of the URL string from the URL-parameter is even simpler:
+                 * The enclosing quotes and any linear whitespace are removed and the
+                 * remaining material is the URL string.
+                 * Read more: http://www.faqs.org/rfcs/rfc2017.html#ixzz0aufO9nRL
+                 */
+                location = parser.parse().replaceAll("\\s", "");
+            } catch (ParseException ex) { 
+                parseException = ex;
+                location = null;
+            }
+        } else {
+            location = null;
+        }
+    }
+    
+    public String getLocation() {
+        if (!parsed) {
+            parse();
+        }
+        return location;
+    }
+
+    @Override
+    public org.apache.james.mime4j.dom.field.ParseException getParseException() {
+        return parseException;
+    }
+
+    public static final FieldParser<ContentLocationField> PARSER = new FieldParser<ContentLocationField>() {
+        public ContentLocationField parse(final String name, final String body,
+                final ByteSequence raw, DecodeMonitor monitor) {
+            return new ContentLocationFieldImpl(name, body, raw, monitor);
+        }
+    };
+
+}
+

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLocationFieldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLocationFieldImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentLocationFieldImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentMD5FieldImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentMD5FieldImpl.java?rev=1126712&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentMD5FieldImpl.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentMD5FieldImpl.java Mon May 23 20:20:44 2011
@@ -0,0 +1,64 @@
+/****************************************************************
+ * 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.field;
+
+import org.apache.james.mime4j.codec.DecodeMonitor;
+import org.apache.james.mime4j.dom.field.ContentMD5Field;
+import org.apache.james.mime4j.stream.FieldParser;
+import org.apache.james.mime4j.util.ByteSequence;
+
+/**
+ * Represents a <code>Content-MD5</code> field.
+ */
+public class ContentMD5FieldImpl extends AbstractField implements ContentMD5Field {
+
+    private boolean parsed = false;
+    private String md5raw;
+
+    ContentMD5FieldImpl(String name, String body, ByteSequence raw, DecodeMonitor monitor) {
+        super(name, body, raw, monitor);
+    }
+
+    private void parse() {
+        parsed = true;
+        String body = getBody();
+        if (body != null) {
+            md5raw = body.trim();
+        } else {
+            md5raw = null;
+        }
+    }
+    
+    public String getMD5Raw() {
+        if (!parsed) {
+            parse();
+        }
+        return md5raw;
+    }
+
+    public static final FieldParser<ContentMD5Field> PARSER = new FieldParser<ContentMD5Field>() {
+        public ContentMD5Field parse(final String name, final String body,
+                final ByteSequence raw, DecodeMonitor monitor) {
+            return new ContentMD5FieldImpl(name, body, raw, monitor);
+        }
+    };
+
+}
+

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentMD5FieldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentMD5FieldImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentMD5FieldImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingFieldImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingFieldImpl.java?rev=1126712&r1=1126711&r2=1126712&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingFieldImpl.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingFieldImpl.java Mon May 23 20:20:44 2011
@@ -19,6 +19,8 @@
 
 package org.apache.james.mime4j.field;
 
+import java.util.Locale;
+
 import org.apache.james.mime4j.codec.DecodeMonitor;
 import org.apache.james.mime4j.dom.field.ContentTransferEncodingField;
 import org.apache.james.mime4j.stream.FieldParser;
@@ -29,17 +31,31 @@ import org.apache.james.mime4j.util.Mime
  * Represents a <code>Content-Transfer-Encoding</code> field.
  */
 public class ContentTransferEncodingFieldImpl extends AbstractField implements ContentTransferEncodingField {
+
+    private boolean parsed = false;
     private String encoding;
 
     ContentTransferEncodingFieldImpl(String name, String body, ByteSequence raw, DecodeMonitor monitor) {
         super(name, body, raw, monitor);
-        encoding = body.trim().toLowerCase();
     }
 
+    private void parse() {
+        parsed = true;
+        String body = getBody();
+        if (body != null) {
+            encoding = body.trim().toLowerCase(Locale.US);
+        } else {
+            encoding = null;
+        }
+    }
+    
     /**
      * @see org.apache.james.mime4j.dom.field.ContentTransferEncodingField#getEncoding()
      */
     public String getEncoding() {
+        if (!parsed) {
+            parse();
+        }
         return encoding;
     }
 

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/DefaultFieldParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/DefaultFieldParser.java?rev=1126712&r1=1126711&r2=1126712&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/DefaultFieldParser.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/DefaultFieldParser.java Mon May 23 20:20:44 2011
@@ -120,11 +120,26 @@ public class DefaultFieldParser extends 
     }
 
     public DefaultFieldParser() {
+        setFieldParser(FieldName.CONTENT_TYPE, 
+                ContentTypeFieldImpl.PARSER);
+        setFieldParser(FieldName.CONTENT_LENGTH,
+                ContentLengthFieldImpl.PARSER);
         setFieldParser(FieldName.CONTENT_TRANSFER_ENCODING,
                 ContentTransferEncodingFieldImpl.PARSER);
-        setFieldParser(FieldName.CONTENT_TYPE, ContentTypeFieldImpl.PARSER);
         setFieldParser(FieldName.CONTENT_DISPOSITION,
                 ContentDispositionFieldImpl.PARSER);
+        setFieldParser(FieldName.CONTENT_ID,
+                ContentDispositionFieldImpl.PARSER);
+        setFieldParser(FieldName.CONTENT_MD5,
+                ContentMD5FieldImpl.PARSER);
+        setFieldParser(FieldName.CONTENT_DESCRIPTION,
+                ContentDescriptionFieldImpl.PARSER);
+        setFieldParser(FieldName.CONTENT_LANGUAGE,
+                ContentLanguageFieldImpl.PARSER);
+        setFieldParser(FieldName.CONTENT_LOCATION,
+                ContentLocationFieldImpl.PARSER);
+        setFieldParser(FieldName.MIME_VERSION,
+                MimeVersionFieldImpl.PARSER);
 
         final FieldParser<DateTimeField> dateTimeParser = DateTimeFieldImpl.PARSER;
         setFieldParser(FieldName.DATE, dateTimeParser);

Added: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/MimeVersionFieldImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/MimeVersionFieldImpl.java?rev=1126712&view=auto
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/MimeVersionFieldImpl.java (added)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/MimeVersionFieldImpl.java Mon May 23 20:20:44 2011
@@ -0,0 +1,99 @@
+/****************************************************************
+ * 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.field;
+
+import java.io.StringReader;
+
+import org.apache.james.mime4j.MimeException;
+import org.apache.james.mime4j.codec.DecodeMonitor;
+import org.apache.james.mime4j.dom.field.MimeVersionField;
+import org.apache.james.mime4j.field.mimeversion.parser.MimeVersionParser;
+import org.apache.james.mime4j.field.mimeversion.parser.ParseException;
+import org.apache.james.mime4j.stream.FieldParser;
+import org.apache.james.mime4j.util.ByteSequence;
+
+/**
+ * Represents a <code>MIME-Version</code> field.
+ */
+public class MimeVersionFieldImpl extends AbstractField implements MimeVersionField {
+
+    public static final int DEFAULT_MINOR_VERSION = 0;
+    public static final int DEFAULT_MAJOR_VERSION = 1;
+    
+    private boolean parsed = false;
+    private int major = DEFAULT_MAJOR_VERSION;
+    private int minor = DEFAULT_MINOR_VERSION;
+    private ParseException parsedException;    
+
+    MimeVersionFieldImpl(String name, String body, ByteSequence raw, DecodeMonitor monitor) {
+        super(name, body, raw, monitor);
+    }
+
+    private void parse() {
+        parsed = true;
+        major = DEFAULT_MAJOR_VERSION;
+        minor = DEFAULT_MINOR_VERSION;
+        String body = getBody();
+        if (body != null) {
+            StringReader reader = new StringReader(body);
+            MimeVersionParser parser = new MimeVersionParser(reader);
+            try {
+                parser.parse();
+                int v = parser.getMajorVersion();
+                if (v != MimeVersionParser.INITIAL_VERSION_VALUE) {
+                    major = v;
+                }
+                v = parser.getMinorVersion();
+                if (v != MimeVersionParser.INITIAL_VERSION_VALUE) {
+                    minor = v;
+                }
+            } catch (MimeException ex) {
+                parsedException = new ParseException(ex);
+            }
+        }
+    }
+
+    public int getMinorVersion() {
+        if (!parsed) {
+            parse();
+        }
+        return minor;
+    }
+
+    public int getMajorVersion() {
+        if (!parsed) {
+            parse();
+        }
+        return major;
+    }
+
+    @Override
+    public org.apache.james.mime4j.dom.field.ParseException getParseException() {
+        return parsedException;
+    }
+
+    public static final FieldParser<MimeVersionField> PARSER = new FieldParser<MimeVersionField>() {
+        public MimeVersionField parse(final String name, final String body,
+                final ByteSequence raw, DecodeMonitor monitor) {
+            return new MimeVersionFieldImpl(name, body, raw, monitor);
+        }
+    };
+    
+}

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/MimeVersionFieldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/MimeVersionFieldImpl.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/field/MimeVersionFieldImpl.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

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=1126712&r1=1126711&r2=1126712&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 May 23 20:20:44 2011
@@ -19,29 +19,31 @@
 
 package org.apache.james.mime4j.message;
 
-import java.io.StringReader;
 import java.util.Collections;
-import java.util.HashMap;
+import java.util.Date;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.codec.DecodeMonitor;
-import org.apache.james.mime4j.dom.datetime.DateTime;
-import org.apache.james.mime4j.field.datetime.parser.DateTimeParser;
-import org.apache.james.mime4j.field.datetime.parser.ParseException;
-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.dom.field.ContentDescriptionField;
+import org.apache.james.mime4j.dom.field.ContentDispositionField;
+import org.apache.james.mime4j.dom.field.ContentIdField;
+import org.apache.james.mime4j.dom.field.ContentLanguageField;
+import org.apache.james.mime4j.dom.field.ContentLocationField;
+import org.apache.james.mime4j.dom.field.ContentMD5Field;
+import org.apache.james.mime4j.dom.field.FieldName;
+import org.apache.james.mime4j.dom.field.MimeVersionField;
+import org.apache.james.mime4j.field.ContentDescriptionFieldImpl;
+import org.apache.james.mime4j.field.ContentDispositionFieldImpl;
+import org.apache.james.mime4j.field.ContentIdFieldImpl;
+import org.apache.james.mime4j.field.ContentLanguageFieldImpl;
+import org.apache.james.mime4j.field.ContentLocationFieldImpl;
+import org.apache.james.mime4j.field.ContentMD5FieldImpl;
+import org.apache.james.mime4j.field.MimeVersionFieldImpl;
 import org.apache.james.mime4j.stream.BodyDescriptor;
-import org.apache.james.mime4j.stream.RawBody;
-import org.apache.james.mime4j.stream.MutableBodyDescriptor;
-import org.apache.james.mime4j.stream.NameValuePair;
 import org.apache.james.mime4j.stream.Field;
-import org.apache.james.mime4j.stream.RawField;
-import org.apache.james.mime4j.stream.RawFieldParser;
-import org.apache.james.mime4j.util.MimeUtil;
+import org.apache.james.mime4j.stream.MutableBodyDescriptor;
 
 /**
  * Parses and stores values for standard MIME header values.
@@ -49,35 +51,13 @@ import org.apache.james.mime4j.util.Mime
  */
 public class MaximalBodyDescriptor extends MinimalBodyDescriptor {
 
-    private static final int DEFAULT_MINOR_VERSION = 0;
-    private static final int DEFAULT_MAJOR_VERSION = 1;
-    private boolean isMimeVersionSet;
-    private int mimeMinorVersion;
-    private int mimeMajorVersion;
-    private MimeException mimeVersionException;
-    private String contentId;
-    private boolean isContentIdSet;
-    private String contentDescription;
-    private boolean isContentDescriptionSet;
-    private String contentDispositionType;
-    private Map<String, String> contentDispositionParameters;
-    private DateTime contentDispositionModificationDate;
-    private MimeException contentDispositionModificationDateParseException;
-    private DateTime contentDispositionCreationDate;
-    private MimeException contentDispositionCreationDateParseException;
-    private DateTime contentDispositionReadDate;
-    private MimeException contentDispositionReadDateParseException;
-    private long contentDispositionSize;
-    private MimeException contentDispositionSizeParseException;
-    private boolean isContentDispositionSet;
-    private List<String> contentLanguage;
-    private MimeException contentLanguageParseException;
-    private boolean isContentLanguageSet;
-    private MimeException contentLocationParseException;
-    private String contentLocation;
-    private boolean isContentLocationSet;
-    private String contentMD5Raw;
-    private boolean isContentMD5Set;
+    private MimeVersionField mimeVersionField;
+    private ContentIdField contentIdField;
+    private ContentDescriptionField contentDescriptionField;
+    private ContentDispositionField contentDispositionField;
+    private ContentLanguageField contentLanguageField;
+    private ContentLocationField contentLocationField;
+    private ContentMD5Field contentMD5Field;
     
     protected MaximalBodyDescriptor() {
         this(null, null);
@@ -85,32 +65,6 @@ public class MaximalBodyDescriptor exten
 
     public MaximalBodyDescriptor(final BodyDescriptor parent, final DecodeMonitor monitor) {
         super(parent, monitor);
-        isMimeVersionSet = false;
-        mimeMajorVersion = DEFAULT_MAJOR_VERSION;
-        mimeMinorVersion = DEFAULT_MINOR_VERSION;
-        this.contentId = null;
-        this.isContentIdSet = false;
-        this.contentDescription = null;
-        this.isContentDescriptionSet = false;
-        this.contentDispositionType = null;
-        this.contentDispositionParameters = Collections.emptyMap();
-        this.contentDispositionModificationDate = null;
-        this.contentDispositionModificationDateParseException = null;
-        this.contentDispositionCreationDate = null;
-        this.contentDispositionCreationDateParseException = null;
-        this.contentDispositionReadDate = null;
-        this.contentDispositionReadDateParseException = null;
-        this.contentDispositionSize = -1;
-        this.contentDispositionSizeParseException = null;
-        this.isContentDispositionSet = false;
-        this.contentLanguage = null;
-        this.contentLanguageParseException = null;
-        this.isContentIdSet = false;
-        this.contentLocation = null;
-        this.contentLocationParseException = null;
-        this.isContentLocationSet = false;
-        this.contentMD5Raw = null;
-        this.isContentMD5Set = false;
     }
 
     @Override
@@ -120,20 +74,20 @@ public class MaximalBodyDescriptor exten
 
     @Override
     public void addField(Field field) throws MimeException {
-        String name = field.getName().toLowerCase(Locale.US);;
-        if (MimeUtil.MIME_HEADER_MIME_VERSION.equals(name) && !isMimeVersionSet) {
+        String name = field.getName();
+        if (name.equalsIgnoreCase(FieldName.MIME_VERSION) && mimeVersionField == null) {
             parseMimeVersion(field);
-        } else if (MimeUtil.MIME_HEADER_CONTENT_ID.equals(name) && !isContentIdSet) {
+        } else if (name.equalsIgnoreCase(FieldName.CONTENT_ID) && contentIdField == null) {
             parseContentId(field);
-        } else if (MimeUtil.MIME_HEADER_CONTENT_DESCRIPTION.equals(name) && !isContentDescriptionSet) {
+        } else if (name.equalsIgnoreCase(FieldName.CONTENT_DESCRIPTION) && contentDescriptionField == null) {
             parseContentDescription(field);
-        } else if (MimeUtil.MIME_HEADER_CONTENT_DISPOSITION.equals(name) && !isContentDispositionSet) {
+        } else if (name.equalsIgnoreCase(FieldName.CONTENT_DISPOSITION) && contentDispositionField == null) {
             parseContentDisposition(field);
-        } else if (MimeUtil.MIME_HEADER_LANGAUGE.equals(name) && !isContentLanguageSet) {
+        } else if (name.equalsIgnoreCase(FieldName.CONTENT_LANGUAGE) && contentLanguageField == null) {
             parseLanguage(field);
-        } else if (MimeUtil.MIME_HEADER_LOCATION.equals(name) && !isContentLocationSet) {
+        } else if (name.equalsIgnoreCase(FieldName.CONTENT_LOCATION) && contentLocationField == null) {
             parseLocation(field);
-        } else if (MimeUtil.MIME_HEADER_MD5.equals(name) && !isContentMD5Set) {
+        } else if (name.equalsIgnoreCase(FieldName.CONTENT_MD5) && contentMD5Field == null) {
             parseMD5(field);
         } else {
             super.addField(field);
@@ -141,150 +95,66 @@ public class MaximalBodyDescriptor exten
     }
     
     private void parseMD5(final Field field) {
-        String value = field.getBody();
-        isContentMD5Set = true;
-        if (value != null) {
-            contentMD5Raw = value.trim();
+        if (field instanceof ContentMD5Field) {
+            contentMD5Field = (ContentMD5Field) field;
+        } else {
+            contentMD5Field = ContentMD5FieldImpl.PARSER.parse(
+                    field.getName(), field.getBody(), field.getRaw(), getDecodeMonitor());
         }
     }
 
     private void parseLocation(final Field field) {
-        isContentLocationSet = true;
-        String value = field.getBody();
-        if (value != null) {
-            final StringReader stringReader = new StringReader(value);
-            final StructuredFieldParser parser = new StructuredFieldParser(stringReader);
-            try {
-                // From RFC2017 3.1
-                /*
-                 * Extraction of the URL string from the URL-parameter is even simpler:
-                 * The enclosing quotes and any linear whitespace are removed and the
-                 * remaining material is the URL string.
-                 * Read more: http://www.faqs.org/rfcs/rfc2017.html#ixzz0aufO9nRL
-                 */
-                contentLocation = parser.parse().replaceAll("\\s", "");
-            } catch (MimeException e) { 
-                contentLocationParseException = e;
-            }
+        if (field instanceof ContentLocationField) {
+            contentLocationField = (ContentLocationField) field;
+        } else {
+            contentLocationField = ContentLocationFieldImpl.PARSER.parse(
+                    field.getName(), field.getBody(), field.getRaw(), getDecodeMonitor());
         }
     }
     
     private void parseLanguage(final Field field) {
-        isContentLanguageSet = true;
-        String value = field.getBody();
-        if (value != null) {
-            try {
-                final ContentLanguageParser parser = new ContentLanguageParser(new StringReader(value));
-                contentLanguage = parser.parse();
-            } catch (MimeException e) {
-                contentLanguageParseException = e;
-            }
+        if (field instanceof ContentLanguageField) {
+            contentLanguageField = (ContentLanguageField) field;
+        } else {
+            contentLanguageField = ContentLanguageFieldImpl.PARSER.parse(
+                    field.getName(), field.getBody(), field.getRaw(), getDecodeMonitor());
         }
     }
 
     private void parseContentDisposition(final Field field) throws MimeException {
-        isContentDispositionSet = true;
-        RawField rawfield;
-        if (field instanceof RawField) {
-            rawfield = ((RawField) field);
+        if (field instanceof ContentDispositionField) {
+            contentDispositionField = (ContentDispositionField) field;
         } else {
-            rawfield = new RawField(field.getName(), field.getBody());
-        }
-        RawBody body = RawFieldParser.DEFAULT.parseRawBody(rawfield);
-        Map<String, String> params = new HashMap<String, String>();
-        for (NameValuePair nmp: body.getParams()) {
-            String name = nmp.getName().toLowerCase(Locale.US);
-            params.put(name, nmp.getValue());
-        }
-        
-        contentDispositionType = body.getValue();
-        contentDispositionParameters = params;
-        
-        final String contentDispositionModificationDate 
-            = contentDispositionParameters.get(MimeUtil.PARAM_MODIFICATION_DATE);
-        if (contentDispositionModificationDate != null) {
-            try {
-                this.contentDispositionModificationDate = parseDate(contentDispositionModificationDate);
-            } catch (ParseException e) {
-                this.contentDispositionModificationDateParseException = e;
-            } 
+            contentDispositionField = ContentDispositionFieldImpl.PARSER.parse(
+                    field.getName(), field.getBody(), field.getRaw(), getDecodeMonitor());
         }
-        
-        final String contentDispositionCreationDate 
-            = contentDispositionParameters.get(MimeUtil.PARAM_CREATION_DATE);
-        if (contentDispositionCreationDate != null) {
-            try {
-                this.contentDispositionCreationDate = parseDate(contentDispositionCreationDate);
-            } catch (ParseException e) {
-                this.contentDispositionCreationDateParseException = e;
-            }         
-        }
-        
-        final String contentDispositionReadDate 
-            = contentDispositionParameters.get(MimeUtil.PARAM_READ_DATE);
-        if (contentDispositionReadDate != null) {
-            try {
-                this.contentDispositionReadDate = parseDate(contentDispositionReadDate);
-            } catch (ParseException e) {
-                this.contentDispositionReadDateParseException = e;
-            }         
-        }
-        
-        final String size = contentDispositionParameters.get(MimeUtil.PARAM_SIZE);
-        if (size != null) {
-            try {
-                contentDispositionSize = Long.parseLong(size);
-            } catch (NumberFormatException e) {
-                this.contentDispositionSizeParseException = (MimeException) new MimeException(e.getMessage(), e).fillInStackTrace();
-            }
-        }
-        contentDispositionParameters.remove("");
     }
 
-    private DateTime parseDate(final String date) throws ParseException {
-        final StringReader stringReader = new StringReader(date);
-        final DateTimeParser parser = new DateTimeParser(stringReader);
-        DateTime result = parser.date_time();
-        return result;
-    }
-    
     private void parseContentDescription(final Field field) {
-        String value = field.getBody();
-        if (value == null) {
-            contentDescription = "";
+        if (field instanceof ContentDescriptionField) {
+            contentDescriptionField = (ContentDescriptionField) field;
         } else {
-            contentDescription = value.trim();
+            contentDescriptionField = ContentDescriptionFieldImpl.PARSER.parse(
+                    field.getName(), field.getBody(), field.getRaw(), getDecodeMonitor());
         }
-        isContentDescriptionSet = true;
     }
 
     private void parseContentId(final Field field) {
-        String value = field.getBody();
-        if (value == null) {
-            contentId = "";
+        if (field instanceof ContentIdField) {
+            contentIdField = (ContentIdField) field;
         } else {
-            contentId = value.trim();
+            contentIdField = ContentIdFieldImpl.PARSER.parse(
+                    field.getName(), field.getBody(), field.getRaw(), getDecodeMonitor());
         }
-        isContentIdSet = true;
     }
 
-    private void parseMimeVersion(Field field) {
-        final StringReader reader = new StringReader(field.getBody());
-        final MimeVersionParser parser = new MimeVersionParser(reader);
-        try {
-            parser.parse();
-            final int major = parser.getMajorVersion();
-            if (major != MimeVersionParser.INITIAL_VERSION_VALUE) {
-                mimeMajorVersion = major;
-            }
-            final int minor = parser.getMinorVersion();
-            if (minor != MimeVersionParser.INITIAL_VERSION_VALUE) {
-                mimeMinorVersion = minor;
-            }
-        } catch (MimeException e) {
-            this.mimeVersionException = e;
+    private void parseMimeVersion(final Field field) {
+        if (field instanceof MimeVersionField) {
+            mimeVersionField = (MimeVersionField) field;
+        } else {
+            mimeVersionField = MimeVersionFieldImpl.PARSER.parse(
+                    field.getName(), field.getBody(), field.getRaw(), getDecodeMonitor());
         }
-        isMimeVersionSet = true;
     }
     
     /**
@@ -295,7 +165,8 @@ public class MaximalBodyDescriptor exten
      * @return positive integer
      */
     public int getMimeMajorVersion() {
-        return mimeMajorVersion;
+        return mimeVersionField != null ? mimeVersionField.getMajorVersion() : 
+            MimeVersionFieldImpl.DEFAULT_MAJOR_VERSION;
     }
     
     /**
@@ -306,28 +177,19 @@ public class MaximalBodyDescriptor exten
      * @return positive integer
      */
     public int getMimeMinorVersion() {
-        return mimeMinorVersion;
+        return mimeVersionField != null ? mimeVersionField.getMinorVersion() : 
+            MimeVersionFieldImpl.DEFAULT_MINOR_VERSION;
     }
     
 
     /**
-     * When the MIME version header exists but cannot be parsed
-     * this field will be contain the exception.
-     * @return <code>MimeException</code> if the mime header cannot
-     * be parsed, null otherwise
-     */
-    public MimeException getMimeVersionParseException() {
-        return mimeVersionException;
-    }
-    
-    /**
      * 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() {
-        return contentDescription;
+        return contentDescriptionField != null ? contentDescriptionField.getDescription() : null;
     }
     
     /**
@@ -337,7 +199,7 @@ public class MaximalBodyDescriptor exten
      * null otherwise
      */
     public String getContentId() {
-        return contentId;
+        return contentIdField != null ? contentIdField.getId() : null;
     }
     
     /**
@@ -348,7 +210,7 @@ public class MaximalBodyDescriptor exten
      * or null when this has not been set
      */
     public String getContentDispositionType() {
-        return contentDispositionType;
+        return contentDispositionField != null ? contentDispositionField.getDispositionType() : null;
     }
     
     /**
@@ -358,7 +220,8 @@ public class MaximalBodyDescriptor exten
      * not null
      */
     public Map<String, String> getContentDispositionParameters() {
-        return contentDispositionParameters;
+        return contentDispositionField != null ? contentDispositionField.getParameters() : 
+            Collections.<String, String>emptyMap();
     }
     
     /**
@@ -368,7 +231,7 @@ public class MaximalBodyDescriptor exten
      * or null when it is not present
      */
     public String getContentDispositionFilename() {
-        return contentDispositionParameters.get(MimeUtil.PARAM_FILENAME);
+        return contentDispositionField != null ? contentDispositionField.getFilename() : null;
     }
     
     /**
@@ -377,17 +240,8 @@ public class MaximalBodyDescriptor exten
      * @return modification-date parameter value,
      * or null when this is not present
      */
-    public DateTime getContentDispositionModificationDate() {
-        return contentDispositionModificationDate;
-    }
-    
-    /**
-     * Gets any exception thrown during the parsing of {@link #getContentDispositionModificationDate()}
-     * @return <code>ParseException</code> when the modification-date parse fails,
-     * null otherwise
-     */
-    public MimeException getContentDispositionModificationDateParseException() {
-        return contentDispositionModificationDateParseException;
+    public Date getContentDispositionModificationDate() {
+        return contentDispositionField != null ? contentDispositionField.getModificationDate() : null;
     }
     
     /**
@@ -396,17 +250,8 @@ public class MaximalBodyDescriptor exten
      * @return creation-date parameter value,
      * or null when this is not present
      */
-    public DateTime getContentDispositionCreationDate() {
-        return contentDispositionCreationDate;
-    }
-    
-    /**
-     * Gets any exception thrown during the parsing of {@link #getContentDispositionCreationDate()}
-     * @return <code>ParseException</code> when the creation-date parse fails,
-     * null otherwise
-     */
-    public MimeException getContentDispositionCreationDateParseException() {
-        return contentDispositionCreationDateParseException;
+    public Date getContentDispositionCreationDate() {
+        return contentDispositionField != null ? contentDispositionField.getCreationDate() : null;
     }
     
     /**
@@ -415,17 +260,8 @@ public class MaximalBodyDescriptor exten
      * @return read-date parameter value,
      * or null when this is not present
      */
-    public DateTime getContentDispositionReadDate() {
-        return contentDispositionReadDate;
-    }
-    
-    /**
-     * Gets any exception thrown during the parsing of {@link #getContentDispositionReadDate()}
-     * @return <code>ParseException</code> when the read-date parse fails,
-     * null otherwise
-     */
-    public MimeException getContentDispositionReadDateParseException() {
-        return contentDispositionReadDateParseException;
+    public Date getContentDispositionReadDate() {
+        return contentDispositionField != null ? contentDispositionField.getReadDate() : null;
     }
     
     /**
@@ -435,16 +271,7 @@ public class MaximalBodyDescriptor exten
      * or -1 if this size has not been set
      */
     public long getContentDispositionSize() {
-        return contentDispositionSize;
-    }
-    
-    /**
-     * Gets any exception thrown during the parsing of {@link #getContentDispositionSize()}
-     * @return <code>ParseException</code> when the read-date parse fails,
-     * null otherwise
-     */
-    public MimeException getContentDispositionSizeParseException() {
-        return contentDispositionSizeParseException;
+        return contentDispositionField != null ? contentDispositionField.getSize() : -1;
     }
     
     /**
@@ -456,36 +283,18 @@ public class MaximalBodyDescriptor exten
      * or null if no header exists
      */
     public List<String> getContentLanguage() {
-        return contentLanguage;
+        return contentLanguageField != null ? contentLanguageField.getLanguages() : 
+            Collections.<String>emptyList();
     }
 
     /**
-     * Gets any exception thrown during the parsing of {@link #getContentLanguage()}
-     * @return <code>ParseException</code> when the content-language parse fails,
-     * null otherwise
-     */
-    public MimeException getContentLanguageParseException() {
-        return contentLanguageParseException;
-    }
-    
-
-    /**
      * Get the <code>content-location</code> header value.
      * 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() {
-        return contentLocation;
-    }
-    
-    /**
-     * Gets any exception thrown during the parsing of {@link #getContentLocation()}
-     * @return <code>ParseException</code> when the content-language parse fails,
-     * null otherwise
-     */
-    public MimeException getContentLocationParseException() {
-        return contentLocationParseException;
+        return contentLocationField != null ? contentLocationField.getLocation() : null;
     }
     
     /**
@@ -496,8 +305,7 @@ public class MaximalBodyDescriptor exten
      * or null if no header exists
      */
     public String getContentMD5Raw() {
-        return contentMD5Raw;
+        return contentMD5Field != null ? contentMD5Field.getMD5Raw() : null;
     }
     
-    
 } 



Mime
View raw message