james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwiederk...@apache.org
Subject svn commit: r746261 - in /james/mime4j/trunk/src/main/java/org/apache/james/mime4j: field/AbstractField.java field/DefaultFieldParser.java field/FieldName.java field/Fields.java message/Entity.java message/Message.java message/MessageWriter.java
Date Fri, 20 Feb 2009 14:51:20 GMT
Author: mwiederkehr
Date: Fri Feb 20 14:51:20 2009
New Revision: 746261

URL: http://svn.apache.org/viewvc?rev=746261&view=rev
Log:
extracted header field name constants

Added:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldName.java
Modified:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AbstractField.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/Fields.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/Message.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/message/MessageWriter.java

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AbstractField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AbstractField.java?rev=746261&r1=746260&r2=746261&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AbstractField.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AbstractField.java Fri
Feb 20 14:51:20 2009
@@ -30,28 +30,6 @@
  * The base class of all field classes.
  */
 public abstract class AbstractField implements Field {
-    public static final String SENDER = "Sender";
-    public static final String FROM = "From";
-    public static final String TO = "To";
-    public static final String CC = "Cc";
-    public static final String BCC = "Bcc";
-    public static final String REPLY_TO = "Reply-To";
-    public static final String RESENT_SENDER = "Resent-Sender";
-    public static final String RESENT_FROM = "Resent-From";
-    public static final String RESENT_TO = "Resent-To";
-    public static final String RESENT_CC = "Resent-Cc";
-    public static final String RESENT_BCC = "Resent-Bcc";
-
-    public static final String DATE = "Date";
-    public static final String RESENT_DATE = "Resent-Date";
-
-    public static final String SUBJECT = "Subject";
-
-    public static final String CONTENT_TYPE = "Content-Type";
-    public static final String CONTENT_TRANSFER_ENCODING = "Content-Transfer-Encoding";
-    public static final String CONTENT_DISPOSITION = "Content-Disposition";
-
-    public static final String MESSAGE_ID = "Message-ID";
 
     private static final String FIELD_NAME_PATTERN = 
         "^([\\x21-\\x39\\x3b-\\x7e]+):";
@@ -216,7 +194,7 @@
      *         <code>false</code> otherwise.
      */
     public boolean isContentType() {
-        return CONTENT_TYPE.equalsIgnoreCase(name);
+        return FieldName.CONTENT_TYPE.equalsIgnoreCase(name);
     }
     
     /**
@@ -226,7 +204,7 @@
      *         <code>false</code> otherwise.
      */
     public boolean isSubject() {
-        return SUBJECT.equalsIgnoreCase(name);
+        return FieldName.SUBJECT.equalsIgnoreCase(name);
     }
     
     /**
@@ -236,7 +214,7 @@
      *         <code>false</code> otherwise.
      */
     public boolean isFrom() {
-        return FROM.equalsIgnoreCase(name);
+        return FieldName.FROM.equalsIgnoreCase(name);
     }
     
     /**
@@ -246,7 +224,7 @@
      *         <code>false</code> otherwise.
      */
     public boolean isTo() {
-        return TO.equalsIgnoreCase(name);
+        return FieldName.TO.equalsIgnoreCase(name);
     }
     
     /**

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=746261&r1=746260&r2=746261&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 14:51:20 2009
@@ -22,29 +22,29 @@
 public class DefaultFieldParser extends DelegatingFieldParser {
     
     public DefaultFieldParser() {
-        setFieldParser(AbstractField.CONTENT_TRANSFER_ENCODING, new ContentTransferEncodingField.Parser());
-        setFieldParser(AbstractField.CONTENT_TYPE, new ContentTypeField.Parser());
-        setFieldParser(AbstractField.CONTENT_DISPOSITION, new ContentDispositionField.Parser());
+        setFieldParser(FieldName.CONTENT_TRANSFER_ENCODING, new ContentTransferEncodingField.Parser());
+        setFieldParser(FieldName.CONTENT_TYPE, new ContentTypeField.Parser());
+        setFieldParser(FieldName.CONTENT_DISPOSITION, new ContentDispositionField.Parser());
         
         final DateTimeField.Parser dateTimeParser = new DateTimeField.Parser();
-        setFieldParser(AbstractField.DATE, dateTimeParser);
-        setFieldParser(AbstractField.RESENT_DATE, dateTimeParser);
+        setFieldParser(FieldName.DATE, dateTimeParser);
+        setFieldParser(FieldName.RESENT_DATE, dateTimeParser);
         
         final MailboxListField.Parser mailboxListParser = new MailboxListField.Parser();
-        setFieldParser(AbstractField.FROM, mailboxListParser);
-        setFieldParser(AbstractField.RESENT_FROM, mailboxListParser);
+        setFieldParser(FieldName.FROM, mailboxListParser);
+        setFieldParser(FieldName.RESENT_FROM, mailboxListParser);
         
         final MailboxField.Parser mailboxParser = new MailboxField.Parser();
-        setFieldParser(AbstractField.SENDER, mailboxParser);
-        setFieldParser(AbstractField.RESENT_SENDER, mailboxParser);
+        setFieldParser(FieldName.SENDER, mailboxParser);
+        setFieldParser(FieldName.RESENT_SENDER, mailboxParser);
         
         final AddressListField.Parser addressListParser = new AddressListField.Parser();
-        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);
+        setFieldParser(FieldName.TO, addressListParser);
+        setFieldParser(FieldName.RESENT_TO, addressListParser);
+        setFieldParser(FieldName.CC, addressListParser);
+        setFieldParser(FieldName.RESENT_CC, addressListParser);
+        setFieldParser(FieldName.BCC, addressListParser);
+        setFieldParser(FieldName.RESENT_BCC, addressListParser);
+        setFieldParser(FieldName.REPLY_TO, addressListParser);
     }
 }

Added: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldName.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldName.java?rev=746261&view=auto
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldName.java (added)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldName.java Fri Feb
20 14:51:20 2009
@@ -0,0 +1,53 @@
+/****************************************************************
+ * 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;
+
+/**
+ * Constants for common header field names.
+ */
+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 DATE = "Date";
+    public static final String MESSAGE_ID = "Message-ID";
+    public static final String SUBJECT = "Subject";
+
+    public static final String FROM = "From";
+    public static final String SENDER = "Sender";
+    public static final String TO = "To";
+    public static final String CC = "Cc";
+    public static final String BCC = "Bcc";
+    public static final String REPLY_TO = "Reply-To";
+
+    public static final String RESENT_DATE = "Resent-Date";
+
+    public static final String RESENT_FROM = "Resent-From";
+    public static final String RESENT_SENDER = "Resent-Sender";
+    public static final String RESENT_TO = "Resent-To";
+    public static final String RESENT_CC = "Resent-Cc";
+    public static final String RESENT_BCC = "Resent-Bcc";
+
+    private FieldName() {
+    }
+
+}

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=746261&r1=746260&r2=746261&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
14:51:20 2009
@@ -52,7 +52,7 @@
      * @return the newly created <i>Content-Type</i> field.
      */
     public static ContentTypeField contentType(String contentType) {
-        return parse(ContentTypeField.class, AbstractField.CONTENT_TYPE, contentType);
+        return parse(ContentTypeField.class, FieldName.CONTENT_TYPE, contentType);
     }
 
     /**
@@ -73,7 +73,7 @@
             throw new IllegalArgumentException();
 
         if (parameters == null || parameters.isEmpty()) {
-            return parse(ContentTypeField.class, AbstractField.CONTENT_TYPE, mimeType);
+            return parse(ContentTypeField.class, FieldName.CONTENT_TYPE, mimeType);
         } else {
             StringBuilder sb = new StringBuilder(mimeType);
             for (Map.Entry<String, String> entry : parameters.entrySet()) {
@@ -98,7 +98,7 @@
     public static ContentTransferEncodingField contentTransferEncoding(
             String contentTransferEncoding) {
         return parse(ContentTransferEncodingField.class,
-                AbstractField.CONTENT_TRANSFER_ENCODING, contentTransferEncoding);
+                FieldName.CONTENT_TRANSFER_ENCODING, contentTransferEncoding);
     }
 
     /**
@@ -113,7 +113,7 @@
      */
     public static ContentDispositionField contentDisposition(
             String contentDisposition) {
-        return parse(ContentDispositionField.class, AbstractField.CONTENT_DISPOSITION,
+        return parse(ContentDispositionField.class, FieldName.CONTENT_DISPOSITION,
                 contentDisposition);
     }
 
@@ -136,7 +136,7 @@
 
         if (parameters == null || parameters.isEmpty()) {
             return parse(ContentDispositionField.class,
-                    AbstractField.CONTENT_DISPOSITION, dispositionType);
+                    FieldName.CONTENT_DISPOSITION, dispositionType);
         } else {
             StringBuilder sb = new StringBuilder(dispositionType);
             for (Map.Entry<String, String> entry : parameters.entrySet()) {
@@ -245,7 +245,7 @@
      * @return the newly created <i>Date</i> field.
      */
     public static DateTimeField date(Date date) {
-        return date(AbstractField.DATE, date, null);
+        return date(FieldName.DATE, date, null);
     }
 
     /**
@@ -291,7 +291,7 @@
      */
     public static Field messageId(String hostname) {
         String fieldValue = MimeUtil.createUniqueMessageId(hostname);
-        return parse(UnstructuredField.class, AbstractField.MESSAGE_ID, fieldValue);
+        return parse(UnstructuredField.class, FieldName.MESSAGE_ID, fieldValue);
     }
 
     /**
@@ -303,11 +303,11 @@
      * @return the newly created <i>Subject</i> field.
      */
     public static UnstructuredField subject(String subject) {
-        int usedCharacters = AbstractField.SUBJECT.length() + 2;
+        int usedCharacters = FieldName.SUBJECT.length() + 2;
         String fieldValue = EncoderUtil.encodeIfNecessary(subject,
                 EncoderUtil.Usage.TEXT_TOKEN, usedCharacters);
 
-        return parse(UnstructuredField.class, AbstractField.SUBJECT, fieldValue);
+        return parse(UnstructuredField.class, FieldName.SUBJECT, fieldValue);
     }
 
     /**
@@ -318,7 +318,7 @@
      * @return the newly created <i>Sender</i> field.
      */
     public static MailboxField sender(Mailbox mailbox) {
-        return mailbox(AbstractField.SENDER, mailbox);
+        return mailbox(FieldName.SENDER, mailbox);
     }
 
     /**
@@ -329,7 +329,7 @@
      * @return the newly created <i>From</i> field.
      */
     public static MailboxListField from(Mailbox mailbox) {
-        return mailboxList(AbstractField.FROM, Collections.singleton(mailbox));
+        return mailboxList(FieldName.FROM, Collections.singleton(mailbox));
     }
 
     /**
@@ -340,7 +340,7 @@
      * @return the newly created <i>From</i> field.
      */
     public static MailboxListField from(Mailbox... mailboxes) {
-        return mailboxList(AbstractField.FROM, Arrays.asList(mailboxes));
+        return mailboxList(FieldName.FROM, Arrays.asList(mailboxes));
     }
 
     /**
@@ -351,7 +351,7 @@
      * @return the newly created <i>From</i> field.
      */
     public static MailboxListField from(Iterable<Mailbox> mailboxes) {
-        return mailboxList(AbstractField.FROM, mailboxes);
+        return mailboxList(FieldName.FROM, mailboxes);
     }
 
     /**
@@ -362,7 +362,7 @@
      * @return the newly created <i>To</i> field.
      */
     public static AddressListField to(Address address) {
-        return addressList(AbstractField.TO, Collections.singleton(address));
+        return addressList(FieldName.TO, Collections.singleton(address));
     }
 
     /**
@@ -373,7 +373,7 @@
      * @return the newly created <i>To</i> field.
      */
     public static AddressListField to(Address... addresses) {
-        return addressList(AbstractField.TO, Arrays.asList(addresses));
+        return addressList(FieldName.TO, Arrays.asList(addresses));
     }
 
     /**
@@ -384,7 +384,7 @@
      * @return the newly created <i>To</i> field.
      */
     public static AddressListField to(Iterable<Address> addresses) {
-        return addressList(AbstractField.TO, addresses);
+        return addressList(FieldName.TO, addresses);
     }
 
     /**
@@ -395,7 +395,7 @@
      * @return the newly created <i>Cc</i> field.
      */
     public static AddressListField cc(Address address) {
-        return addressList(AbstractField.CC, Collections.singleton(address));
+        return addressList(FieldName.CC, Collections.singleton(address));
     }
 
     /**
@@ -406,7 +406,7 @@
      * @return the newly created <i>Cc</i> field.
      */
     public static AddressListField cc(Address... addresses) {
-        return addressList(AbstractField.CC, Arrays.asList(addresses));
+        return addressList(FieldName.CC, Arrays.asList(addresses));
     }
 
     /**
@@ -417,7 +417,7 @@
      * @return the newly created <i>Cc</i> field.
      */
     public static AddressListField cc(Iterable<Address> addresses) {
-        return addressList(AbstractField.CC, addresses);
+        return addressList(FieldName.CC, addresses);
     }
 
     /**
@@ -428,7 +428,7 @@
      * @return the newly created <i>Bcc</i> field.
      */
     public static AddressListField bcc(Address address) {
-        return addressList(AbstractField.BCC, Collections.singleton(address));
+        return addressList(FieldName.BCC, Collections.singleton(address));
     }
 
     /**
@@ -439,7 +439,7 @@
      * @return the newly created <i>Bcc</i> field.
      */
     public static AddressListField bcc(Address... addresses) {
-        return addressList(AbstractField.BCC, Arrays.asList(addresses));
+        return addressList(FieldName.BCC, Arrays.asList(addresses));
     }
 
     /**
@@ -450,7 +450,7 @@
      * @return the newly created <i>Bcc</i> field.
      */
     public static AddressListField bcc(Iterable<Address> addresses) {
-        return addressList(AbstractField.BCC, addresses);
+        return addressList(FieldName.BCC, addresses);
     }
 
     /**
@@ -462,7 +462,7 @@
      * @return the newly created <i>Reply-To</i> field.
      */
     public static AddressListField replyTo(Address address) {
-        return addressList(AbstractField.REPLY_TO, Collections.singleton(address));
+        return addressList(FieldName.REPLY_TO, Collections.singleton(address));
     }
 
     /**
@@ -474,7 +474,7 @@
      * @return the newly created <i>Reply-To</i> field.
      */
     public static AddressListField replyTo(Address... addresses) {
-        return addressList(AbstractField.REPLY_TO, Arrays.asList(addresses));
+        return addressList(FieldName.REPLY_TO, Arrays.asList(addresses));
     }
 
     /**
@@ -486,7 +486,7 @@
      * @return the newly created <i>Reply-To</i> field.
      */
     public static AddressListField replyTo(Iterable<Address> addresses) {
-        return addressList(AbstractField.REPLY_TO, addresses);
+        return addressList(FieldName.REPLY_TO, addresses);
     }
 
     /**

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=746261&r1=746260&r2=746261&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
14:51:20 2009
@@ -24,10 +24,10 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.james.mime4j.field.AbstractField;
 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.FieldName;
 import org.apache.james.mime4j.field.Fields;
 import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.MimeUtil;
@@ -287,10 +287,10 @@
      */
     public String getMimeType() {
         ContentTypeField child = 
-            (ContentTypeField) getHeader().getField(AbstractField.CONTENT_TYPE);
+            (ContentTypeField) getHeader().getField(FieldName.CONTENT_TYPE);
         ContentTypeField parent = getParent() != null 
             ? (ContentTypeField) getParent().getHeader().
-                                                getField(AbstractField.CONTENT_TYPE)
+                                                getField(FieldName.CONTENT_TYPE)
             : null;
         
         return ContentTypeField.getMimeType(child, parent);
@@ -303,7 +303,7 @@
      */
     public String getCharset() {
         return ContentTypeField.getCharset( 
-            (ContentTypeField) getHeader().getField(AbstractField.CONTENT_TYPE));
+            (ContentTypeField) getHeader().getField(FieldName.CONTENT_TYPE));
     }
     
     /**
@@ -313,7 +313,7 @@
      */
     public String getContentTransferEncoding() {
         ContentTransferEncodingField f = (ContentTransferEncodingField) 
-                        getHeader().getField(AbstractField.CONTENT_TRANSFER_ENCODING);
+                        getHeader().getField(FieldName.CONTENT_TRANSFER_ENCODING);
         
         return ContentTransferEncodingField.getEncoding(f);
     }
@@ -338,7 +338,7 @@
      *         type has been set.
      */
     public String getDispositionType() {
-        ContentDispositionField field = obtainField(AbstractField.CONTENT_DISPOSITION);
+        ContentDispositionField field = obtainField(FieldName.CONTENT_DISPOSITION);
         if (field == null)
             return null;
 
@@ -438,7 +438,7 @@
      *         <code>null</code> if the filename has not been set.
      */
     public String getFilename() {
-        ContentDispositionField field = obtainField(AbstractField.CONTENT_DISPOSITION);
+        ContentDispositionField field = obtainField(FieldName.CONTENT_DISPOSITION);
         if (field == null)
             return null;
 
@@ -458,7 +458,7 @@
     public void setFilename(String filename) {
         Header header = obtainHeader();
         ContentDispositionField field = (ContentDispositionField) header
-                .getField(AbstractField.CONTENT_DISPOSITION);
+                .getField(FieldName.CONTENT_DISPOSITION);
         if (field == null) {
             if (filename != null) {
                 header.setField(Fields.contentDisposition(
@@ -501,7 +501,7 @@
      */
     public boolean isMultipart() {
         ContentTypeField f = 
-            (ContentTypeField) getHeader().getField(AbstractField.CONTENT_TYPE);
+            (ContentTypeField) getHeader().getField(FieldName.CONTENT_TYPE);
         return f != null && f.getBoundary() != null 
             && getMimeType().startsWith(ContentTypeField.TYPE_MULTIPART_PREFIX);
     }

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=746261&r1=746260&r2=746261&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 14:51:20 2009
@@ -30,9 +30,9 @@
 
 import org.apache.james.mime4j.MimeException;
 import org.apache.james.mime4j.MimeIOException;
-import org.apache.james.mime4j.field.AbstractField;
 import org.apache.james.mime4j.field.AddressListField;
 import org.apache.james.mime4j.field.DateTimeField;
+import org.apache.james.mime4j.field.FieldName;
 import org.apache.james.mime4j.field.Fields;
 import org.apache.james.mime4j.field.MailboxField;
 import org.apache.james.mime4j.field.MailboxListField;
@@ -167,7 +167,7 @@
      * @return the identifier of this message.
      */
     public String getMessageId() {
-        Field field = obtainField(AbstractField.MESSAGE_ID);
+        Field field = obtainField(FieldName.MESSAGE_ID);
         if (field == null)
             return null;
 
@@ -196,7 +196,7 @@
      * @return the subject of this message.
      */
     public String getSubject() {
-        UnstructuredField field = obtainField(AbstractField.SUBJECT);
+        UnstructuredField field = obtainField(FieldName.SUBJECT);
         if (field == null)
             return null;
 
@@ -217,7 +217,7 @@
         Header header = obtainHeader();
 
         if (subject == null) {
-            header.removeFields(AbstractField.SUBJECT);
+            header.removeFields(FieldName.SUBJECT);
         } else {
             header.setField(Fields.subject(subject));
         }
@@ -230,7 +230,7 @@
      * @return the date of this message.
      */
     public Date getDate() {
-        DateTimeField dateField = obtainField(AbstractField.DATE);
+        DateTimeField dateField = obtainField(FieldName.DATE);
         if (dateField == null)
             return null;
 
@@ -265,9 +265,9 @@
         Header header = obtainHeader();
 
         if (date == null) {
-            header.removeFields(AbstractField.DATE);
+            header.removeFields(FieldName.DATE);
         } else {
-            header.setField(Fields.date(AbstractField.DATE, date, zone));
+            header.setField(Fields.date(FieldName.DATE, date, zone));
         }
     }
 
@@ -279,7 +279,7 @@
      * @return the sender of this message.
      */
     public Mailbox getSender() {
-        return getMailbox(AbstractField.SENDER);
+        return getMailbox(FieldName.SENDER);
     }
 
     /**
@@ -291,7 +291,7 @@
      *            field.
      */
     public void setSender(Mailbox sender) {
-        setMailbox(AbstractField.SENDER, sender);
+        setMailbox(FieldName.SENDER, sender);
     }
 
     /**
@@ -302,7 +302,7 @@
      * @return value of the from field of this message.
      */
     public MailboxList getFrom() {
-        return getMailboxList(AbstractField.FROM);
+        return getMailboxList(FieldName.FROM);
     }
 
     /**
@@ -314,7 +314,7 @@
      *            field.
      */
     public void setFrom(Mailbox from) {
-        setMailboxList(AbstractField.FROM, from);
+        setMailboxList(FieldName.FROM, from);
     }
 
     /**
@@ -326,7 +326,7 @@
      *            remove the header field.
      */
     public void setFrom(Mailbox... from) {
-        setMailboxList(AbstractField.FROM, from);
+        setMailboxList(FieldName.FROM, from);
     }
 
     /**
@@ -338,7 +338,7 @@
      *            to remove the header field.
      */
     public void setFrom(Collection<Mailbox> from) {
-        setMailboxList(AbstractField.FROM, from);
+        setMailboxList(FieldName.FROM, from);
     }
 
     /**
@@ -349,7 +349,7 @@
      * @return value of the to field of this message.
      */
     public AddressList getTo() {
-        return getAddressList(AbstractField.TO);
+        return getAddressList(FieldName.TO);
     }
 
     /**
@@ -361,7 +361,7 @@
      *            field.
      */
     public void setTo(Address to) {
-        setAddressList(AbstractField.TO, to);
+        setAddressList(FieldName.TO, to);
     }
 
     /**
@@ -373,7 +373,7 @@
      *            remove the header field.
      */
     public void setTo(Address... to) {
-        setAddressList(AbstractField.TO, to);
+        setAddressList(FieldName.TO, to);
     }
 
     /**
@@ -385,7 +385,7 @@
      *            to remove the header field.
      */
     public void setTo(Collection<Address> to) {
-        setAddressList(AbstractField.TO, to);
+        setAddressList(FieldName.TO, to);
     }
 
     /**
@@ -396,7 +396,7 @@
      * @return value of the cc field of this message.
      */
     public AddressList getCc() {
-        return getAddressList(AbstractField.CC);
+        return getAddressList(FieldName.CC);
     }
 
     /**
@@ -408,7 +408,7 @@
      *            field.
      */
     public void setCc(Address cc) {
-        setAddressList(AbstractField.CC, cc);
+        setAddressList(FieldName.CC, cc);
     }
 
     /**
@@ -420,7 +420,7 @@
      *            remove the header field.
      */
     public void setCc(Address... cc) {
-        setAddressList(AbstractField.CC, cc);
+        setAddressList(FieldName.CC, cc);
     }
 
     /**
@@ -432,7 +432,7 @@
      *            to remove the header field.
      */
     public void setCc(Collection<Address> cc) {
-        setAddressList(AbstractField.CC, cc);
+        setAddressList(FieldName.CC, cc);
     }
 
     /**
@@ -443,7 +443,7 @@
      * @return value of the bcc field of this message.
      */
     public AddressList getBcc() {
-        return getAddressList(AbstractField.BCC);
+        return getAddressList(FieldName.BCC);
     }
 
     /**
@@ -455,7 +455,7 @@
      *            field.
      */
     public void setBcc(Address bcc) {
-        setAddressList(AbstractField.BCC, bcc);
+        setAddressList(FieldName.BCC, bcc);
     }
 
     /**
@@ -467,7 +467,7 @@
      *            remove the header field.
      */
     public void setBcc(Address... bcc) {
-        setAddressList(AbstractField.BCC, bcc);
+        setAddressList(FieldName.BCC, bcc);
     }
 
     /**
@@ -479,7 +479,7 @@
      *            to remove the header field.
      */
     public void setBcc(Collection<Address> bcc) {
-        setAddressList(AbstractField.BCC, bcc);
+        setAddressList(FieldName.BCC, bcc);
     }
 
     /**
@@ -490,7 +490,7 @@
      * @return value of the reply to field of this message.
      */
     public AddressList getReplyTo() {
-        return getAddressList(AbstractField.REPLY_TO);
+        return getAddressList(FieldName.REPLY_TO);
     }
 
     /**
@@ -502,7 +502,7 @@
      *            field.
      */
     public void setReplyTo(Address replyTo) {
-        setAddressList(AbstractField.REPLY_TO, replyTo);
+        setAddressList(FieldName.REPLY_TO, replyTo);
     }
 
     /**
@@ -514,7 +514,7 @@
      *            remove the header field.
      */
     public void setReplyTo(Address... replyTo) {
-        setAddressList(AbstractField.REPLY_TO, replyTo);
+        setAddressList(FieldName.REPLY_TO, replyTo);
     }
 
     /**
@@ -526,7 +526,7 @@
      *            to remove the header field.
      */
     public void setReplyTo(Collection<Address> replyTo) {
-        setAddressList(AbstractField.REPLY_TO, replyTo);
+        setAddressList(FieldName.REPLY_TO, replyTo);
     }
 
     private Mailbox getMailbox(String fieldName) {

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=746261&r1=746260&r2=746261&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 14:51:20 2009
@@ -32,7 +32,7 @@
 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.AbstractField;
+import org.apache.james.mime4j.field.FieldName;
 import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.CharsetUtil;
 import org.apache.james.mime4j.util.MimeUtil;
@@ -225,7 +225,7 @@
     public void writeHeader(Header header, OutputStream out)
             throws IOException, MimeIOException {
         Writer writer = getWriter((ContentTypeField) header
-                .getField(AbstractField.CONTENT_TYPE), out);
+                .getField(FieldName.CONTENT_TYPE), out);
 
         try {
             for (Field field : header) {
@@ -272,7 +272,7 @@
                     "Missing header in parent entity");
 
         ContentTypeField contentType = (ContentTypeField) header
-                .getField(AbstractField.CONTENT_TYPE);
+                .getField(FieldName.CONTENT_TYPE);
         if (contentType == null)
             throw new IllegalArgumentException(
                     "Content-Type field not specified");



Mime
View raw message