james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwiederk...@apache.org
Subject svn commit: r778457 [3/13] - in /james/mime4j/trunk: benchmark/src/main/java/org/apache/james/mime4j/ core/src/main/java/org/apache/james/mime4j/ core/src/main/java/org/apache/james/mime4j/codec/ core/src/main/java/org/apache/james/mime4j/descriptor/ c...
Date Mon, 25 May 2009 17:20:52 GMT
Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/ContentDispositionField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/ContentDispositionField.java?rev=778457&r1=778456&r2=778457&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/ContentDispositionField.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/ContentDispositionField.java Mon May 25 17:20:48 2009
@@ -1,326 +1,326 @@
-/****************************************************************
- * 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.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.james.mime4j.field.contentdisposition.parser.ContentDispositionParser;
-import org.apache.james.mime4j.field.contentdisposition.parser.TokenMgrError;
-import org.apache.james.mime4j.field.datetime.parser.DateTimeParser;
-import org.apache.james.mime4j.util.ByteSequence;
-
-/**
- * Represents a <code>Content-Disposition</code> field.
- */
-public class ContentDispositionField extends AbstractField {
-    private static Log log = LogFactory.getLog(ContentDispositionField.class);
-
-    /** The <code>inline</code> disposition type. */
-    public static final String DISPOSITION_TYPE_INLINE = "inline";
-
-    /** The <code>attachment</code> disposition type. */
-    public static final String DISPOSITION_TYPE_ATTACHMENT = "attachment";
-
-    /** The name of the <code>filename</code> parameter. */
-    public static final String PARAM_FILENAME = "filename";
-
-    /** The name of the <code>creation-date</code> parameter. */
-    public static final String PARAM_CREATION_DATE = "creation-date";
-
-    /** The name of the <code>modification-date</code> parameter. */
-    public static final String PARAM_MODIFICATION_DATE = "modification-date";
-
-    /** The name of the <code>read-date</code> parameter. */
-    public static final String PARAM_READ_DATE = "read-date";
-
-    /** The name of the <code>size</code> parameter. */
-    public static final String PARAM_SIZE = "size";
-
-    private boolean parsed = false;
-
-    private String dispositionType = "";
-    private Map<String, String> parameters = new HashMap<String, String>();
-    private ParseException parseException;
-
-    private boolean creationDateParsed;
-    private Date creationDate;
-
-    private boolean modificationDateParsed;
-    private Date modificationDate;
-
-    private boolean readDateParsed;
-    private Date readDate;
-
-    ContentDispositionField(String name, String body, ByteSequence raw) {
-        super(name, body, raw);
-    }
-
-    /**
-     * Gets the exception that was raised during parsing of the field value, if
-     * any; otherwise, null.
-     */
-    @Override
-    public ParseException getParseException() {
-        if (!parsed)
-            parse();
-
-        return parseException;
-    }
-
-    /**
-     * Gets the disposition type defined in this Content-Disposition field.
-     * 
-     * @return the disposition type or an empty string if not set.
-     */
-    public String getDispositionType() {
-        if (!parsed)
-            parse();
-
-        return dispositionType;
-    }
-
-    /**
-     * Gets the value of a parameter. Parameter names are case-insensitive.
-     * 
-     * @param name
-     *            the name of the parameter to get.
-     * @return the parameter value or <code>null</code> if not set.
-     */
-    public String getParameter(String name) {
-        if (!parsed)
-            parse();
-
-        return parameters.get(name.toLowerCase());
-    }
-
-    /**
-     * Gets all parameters.
-     * 
-     * @return the parameters.
-     */
-    public Map<String, String> getParameters() {
-        if (!parsed)
-            parse();
-
-        return Collections.unmodifiableMap(parameters);
-    }
-
-    /**
-     * Determines if the disposition type of this field matches the given one.
-     * 
-     * @param dispositionType
-     *            the disposition type to match against.
-     * @return <code>true</code> if the disposition type of this field
-     *         matches, <code>false</code> otherwise.
-     */
-    public boolean isDispositionType(String dispositionType) {
-        if (!parsed)
-            parse();
-
-        return this.dispositionType.equalsIgnoreCase(dispositionType);
-    }
-
-    /**
-     * Return <code>true</code> if the disposition type of this field is
-     * <i>inline</i>, <code>false</code> otherwise.
-     * 
-     * @return <code>true</code> if the disposition type of this field is
-     *         <i>inline</i>, <code>false</code> otherwise.
-     */
-    public boolean isInline() {
-        if (!parsed)
-            parse();
-
-        return dispositionType.equals(DISPOSITION_TYPE_INLINE);
-    }
-
-    /**
-     * Return <code>true</code> if the disposition type of this field is
-     * <i>attachment</i>, <code>false</code> otherwise.
-     * 
-     * @return <code>true</code> if the disposition type of this field is
-     *         <i>attachment</i>, <code>false</code> otherwise.
-     */
-    public boolean isAttachment() {
-        if (!parsed)
-            parse();
-
-        return dispositionType.equals(DISPOSITION_TYPE_ATTACHMENT);
-    }
-
-    /**
-     * Gets the value of the <code>filename</code> parameter if set.
-     * 
-     * @return the <code>filename</code> parameter value or <code>null</code>
-     *         if not set.
-     */
-    public String getFilename() {
-        return getParameter(PARAM_FILENAME);
-    }
-
-    /**
-     * Gets the value of the <code>creation-date</code> parameter if set and
-     * valid.
-     * 
-     * @return the <code>creation-date</code> parameter value or
-     *         <code>null</code> if not set or invalid.
-     */
-    public Date getCreationDate() {
-        if (!creationDateParsed) {
-            creationDate = parseDate(PARAM_CREATION_DATE);
-            creationDateParsed = true;
-        }
-
-        return creationDate;
-    }
-
-    /**
-     * Gets the value of the <code>modification-date</code> parameter if set
-     * and valid.
-     * 
-     * @return the <code>modification-date</code> parameter value or
-     *         <code>null</code> if not set or invalid.
-     */
-    public Date getModificationDate() {
-        if (!modificationDateParsed) {
-            modificationDate = parseDate(PARAM_MODIFICATION_DATE);
-            modificationDateParsed = true;
-        }
-
-        return modificationDate;
-    }
-
-    /**
-     * Gets the value of the <code>read-date</code> parameter if set and
-     * valid.
-     * 
-     * @return the <code>read-date</code> parameter value or <code>null</code>
-     *         if not set or invalid.
-     */
-    public Date getReadDate() {
-        if (!readDateParsed) {
-            readDate = parseDate(PARAM_READ_DATE);
-            readDateParsed = true;
-        }
-
-        return readDate;
-    }
-
-    /**
-     * Gets the value of the <code>size</code> parameter if set and valid.
-     * 
-     * @return the <code>size</code> parameter value or <code>-1</code> if
-     *         not set or invalid.
-     */
-    public long getSize() {
-        String value = getParameter(PARAM_SIZE);
-        if (value == null)
-            return -1;
-
-        try {
-            long size = Long.parseLong(value);
-            return size < 0 ? -1 : size;
-        } catch (NumberFormatException e) {
-            return -1;
-        }
-    }
-
-    private Date parseDate(String paramName) {
-        String value = getParameter(paramName);
-        if (value == null) {
-            if (log.isDebugEnabled()) {
-                log.debug("Parsing " + paramName + " null");
-            }
-            return null;
-        }
-
-        try {
-            return new DateTimeParser(new StringReader(value)).parseAll()
-                    .getDate();
-        } catch (ParseException e) {
-            if (log.isDebugEnabled()) {
-                log.debug("Parsing " + paramName + " '" + value + "': "
-                        + e.getMessage());
-            }
-            return null;
-        } catch (org.apache.james.mime4j.field.datetime.parser.TokenMgrError e) {
-            if (log.isDebugEnabled()) {
-                log.debug("Parsing " + paramName + " '" + value + "': "
-                        + e.getMessage());
-            }
-            return null;
-        }
-    }
-
-    private void parse() {
-        String body = getBody();
-
-        ContentDispositionParser parser = new ContentDispositionParser(
-                new StringReader(body));
-        try {
-            parser.parseAll();
-        } catch (ParseException e) {
-            if (log.isDebugEnabled()) {
-                log.debug("Parsing value '" + body + "': " + e.getMessage());
-            }
-            parseException = e;
-        } catch (TokenMgrError e) {
-            if (log.isDebugEnabled()) {
-                log.debug("Parsing value '" + body + "': " + e.getMessage());
-            }
-            parseException = new ParseException(e.getMessage());
-        }
-
-        final String dispositionType = parser.getDispositionType();
-
-        if (dispositionType != null) {
-            this.dispositionType = dispositionType.toLowerCase(Locale.US);
-
-            List<String> paramNames = parser.getParamNames();
-            List<String> paramValues = parser.getParamValues();
-
-            if (paramNames != null && paramValues != null) {
-                final int len = Math.min(paramNames.size(), paramValues.size());
-                for (int i = 0; i < len; i++) {
-                    String paramName = paramNames.get(i).toLowerCase(Locale.US);
-                    String paramValue = paramValues.get(i);
-                    parameters.put(paramName, paramValue);
-                }
-            }
-        }
-
-        parsed = true;
-    }
-
-    static final FieldParser PARSER = new FieldParser() {
-        public ParsedField parse(final String name, final String body,
-                final ByteSequence raw) {
-            return new ContentDispositionField(name, body, raw);
-        }
-    };
-}
+/****************************************************************
+ * 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.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.james.mime4j.field.contentdisposition.parser.ContentDispositionParser;
+import org.apache.james.mime4j.field.contentdisposition.parser.TokenMgrError;
+import org.apache.james.mime4j.field.datetime.parser.DateTimeParser;
+import org.apache.james.mime4j.util.ByteSequence;
+
+/**
+ * Represents a <code>Content-Disposition</code> field.
+ */
+public class ContentDispositionField extends AbstractField {
+    private static Log log = LogFactory.getLog(ContentDispositionField.class);
+
+    /** The <code>inline</code> disposition type. */
+    public static final String DISPOSITION_TYPE_INLINE = "inline";
+
+    /** The <code>attachment</code> disposition type. */
+    public static final String DISPOSITION_TYPE_ATTACHMENT = "attachment";
+
+    /** The name of the <code>filename</code> parameter. */
+    public static final String PARAM_FILENAME = "filename";
+
+    /** The name of the <code>creation-date</code> parameter. */
+    public static final String PARAM_CREATION_DATE = "creation-date";
+
+    /** The name of the <code>modification-date</code> parameter. */
+    public static final String PARAM_MODIFICATION_DATE = "modification-date";
+
+    /** The name of the <code>read-date</code> parameter. */
+    public static final String PARAM_READ_DATE = "read-date";
+
+    /** The name of the <code>size</code> parameter. */
+    public static final String PARAM_SIZE = "size";
+
+    private boolean parsed = false;
+
+    private String dispositionType = "";
+    private Map<String, String> parameters = new HashMap<String, String>();
+    private ParseException parseException;
+
+    private boolean creationDateParsed;
+    private Date creationDate;
+
+    private boolean modificationDateParsed;
+    private Date modificationDate;
+
+    private boolean readDateParsed;
+    private Date readDate;
+
+    ContentDispositionField(String name, String body, ByteSequence raw) {
+        super(name, body, raw);
+    }
+
+    /**
+     * Gets the exception that was raised during parsing of the field value, if
+     * any; otherwise, null.
+     */
+    @Override
+    public ParseException getParseException() {
+        if (!parsed)
+            parse();
+
+        return parseException;
+    }
+
+    /**
+     * Gets the disposition type defined in this Content-Disposition field.
+     * 
+     * @return the disposition type or an empty string if not set.
+     */
+    public String getDispositionType() {
+        if (!parsed)
+            parse();
+
+        return dispositionType;
+    }
+
+    /**
+     * Gets the value of a parameter. Parameter names are case-insensitive.
+     * 
+     * @param name
+     *            the name of the parameter to get.
+     * @return the parameter value or <code>null</code> if not set.
+     */
+    public String getParameter(String name) {
+        if (!parsed)
+            parse();
+
+        return parameters.get(name.toLowerCase());
+    }
+
+    /**
+     * Gets all parameters.
+     * 
+     * @return the parameters.
+     */
+    public Map<String, String> getParameters() {
+        if (!parsed)
+            parse();
+
+        return Collections.unmodifiableMap(parameters);
+    }
+
+    /**
+     * Determines if the disposition type of this field matches the given one.
+     * 
+     * @param dispositionType
+     *            the disposition type to match against.
+     * @return <code>true</code> if the disposition type of this field
+     *         matches, <code>false</code> otherwise.
+     */
+    public boolean isDispositionType(String dispositionType) {
+        if (!parsed)
+            parse();
+
+        return this.dispositionType.equalsIgnoreCase(dispositionType);
+    }
+
+    /**
+     * Return <code>true</code> if the disposition type of this field is
+     * <i>inline</i>, <code>false</code> otherwise.
+     * 
+     * @return <code>true</code> if the disposition type of this field is
+     *         <i>inline</i>, <code>false</code> otherwise.
+     */
+    public boolean isInline() {
+        if (!parsed)
+            parse();
+
+        return dispositionType.equals(DISPOSITION_TYPE_INLINE);
+    }
+
+    /**
+     * Return <code>true</code> if the disposition type of this field is
+     * <i>attachment</i>, <code>false</code> otherwise.
+     * 
+     * @return <code>true</code> if the disposition type of this field is
+     *         <i>attachment</i>, <code>false</code> otherwise.
+     */
+    public boolean isAttachment() {
+        if (!parsed)
+            parse();
+
+        return dispositionType.equals(DISPOSITION_TYPE_ATTACHMENT);
+    }
+
+    /**
+     * Gets the value of the <code>filename</code> parameter if set.
+     * 
+     * @return the <code>filename</code> parameter value or <code>null</code>
+     *         if not set.
+     */
+    public String getFilename() {
+        return getParameter(PARAM_FILENAME);
+    }
+
+    /**
+     * Gets the value of the <code>creation-date</code> parameter if set and
+     * valid.
+     * 
+     * @return the <code>creation-date</code> parameter value or
+     *         <code>null</code> if not set or invalid.
+     */
+    public Date getCreationDate() {
+        if (!creationDateParsed) {
+            creationDate = parseDate(PARAM_CREATION_DATE);
+            creationDateParsed = true;
+        }
+
+        return creationDate;
+    }
+
+    /**
+     * Gets the value of the <code>modification-date</code> parameter if set
+     * and valid.
+     * 
+     * @return the <code>modification-date</code> parameter value or
+     *         <code>null</code> if not set or invalid.
+     */
+    public Date getModificationDate() {
+        if (!modificationDateParsed) {
+            modificationDate = parseDate(PARAM_MODIFICATION_DATE);
+            modificationDateParsed = true;
+        }
+
+        return modificationDate;
+    }
+
+    /**
+     * Gets the value of the <code>read-date</code> parameter if set and
+     * valid.
+     * 
+     * @return the <code>read-date</code> parameter value or <code>null</code>
+     *         if not set or invalid.
+     */
+    public Date getReadDate() {
+        if (!readDateParsed) {
+            readDate = parseDate(PARAM_READ_DATE);
+            readDateParsed = true;
+        }
+
+        return readDate;
+    }
+
+    /**
+     * Gets the value of the <code>size</code> parameter if set and valid.
+     * 
+     * @return the <code>size</code> parameter value or <code>-1</code> if
+     *         not set or invalid.
+     */
+    public long getSize() {
+        String value = getParameter(PARAM_SIZE);
+        if (value == null)
+            return -1;
+
+        try {
+            long size = Long.parseLong(value);
+            return size < 0 ? -1 : size;
+        } catch (NumberFormatException e) {
+            return -1;
+        }
+    }
+
+    private Date parseDate(String paramName) {
+        String value = getParameter(paramName);
+        if (value == null) {
+            if (log.isDebugEnabled()) {
+                log.debug("Parsing " + paramName + " null");
+            }
+            return null;
+        }
+
+        try {
+            return new DateTimeParser(new StringReader(value)).parseAll()
+                    .getDate();
+        } catch (ParseException e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Parsing " + paramName + " '" + value + "': "
+                        + e.getMessage());
+            }
+            return null;
+        } catch (org.apache.james.mime4j.field.datetime.parser.TokenMgrError e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Parsing " + paramName + " '" + value + "': "
+                        + e.getMessage());
+            }
+            return null;
+        }
+    }
+
+    private void parse() {
+        String body = getBody();
+
+        ContentDispositionParser parser = new ContentDispositionParser(
+                new StringReader(body));
+        try {
+            parser.parseAll();
+        } catch (ParseException e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Parsing value '" + body + "': " + e.getMessage());
+            }
+            parseException = e;
+        } catch (TokenMgrError e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Parsing value '" + body + "': " + e.getMessage());
+            }
+            parseException = new ParseException(e.getMessage());
+        }
+
+        final String dispositionType = parser.getDispositionType();
+
+        if (dispositionType != null) {
+            this.dispositionType = dispositionType.toLowerCase(Locale.US);
+
+            List<String> paramNames = parser.getParamNames();
+            List<String> paramValues = parser.getParamValues();
+
+            if (paramNames != null && paramValues != null) {
+                final int len = Math.min(paramNames.size(), paramValues.size());
+                for (int i = 0; i < len; i++) {
+                    String paramName = paramNames.get(i).toLowerCase(Locale.US);
+                    String paramValue = paramValues.get(i);
+                    parameters.put(paramName, paramValue);
+                }
+            }
+        }
+
+        parsed = true;
+    }
+
+    static final FieldParser PARSER = new FieldParser() {
+        public ParsedField parse(final String name, final String body,
+                final ByteSequence raw) {
+            return new ContentDispositionField(name, body, raw);
+        }
+    };
+}

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

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingField.java?rev=778457&r1=778456&r2=778457&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingField.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingField.java Mon May 25 17:20:48 2009
@@ -1,65 +1,65 @@
-/****************************************************************
- * 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.util.ByteSequence;
-import org.apache.james.mime4j.util.MimeUtil;
-
-/**
- * Represents a <code>Content-Transfer-Encoding</code> field.
- */
-public class ContentTransferEncodingField extends AbstractField {
-    private String encoding;
-
-    ContentTransferEncodingField(String name, String body, ByteSequence raw) {
-        super(name, body, raw);
-        encoding = body.trim().toLowerCase();
-    }
-
-    /**
-     * Gets the encoding defined in this field.
-     * 
-     * @return the encoding or an empty string if not set.
-     */
-    public String getEncoding() {
-        return encoding;
-    }
-
-    /**
-     * Gets the encoding of the given field if. Returns the default
-     * <code>7bit</code> if not set or if <code>f</code> is
-     * <code>null</code>.
-     * 
-     * @return the encoding.
-     */
-    public static String getEncoding(ContentTransferEncodingField f) {
-        if (f != null && f.getEncoding().length() != 0) {
-            return f.getEncoding();
-        }
-        return MimeUtil.ENC_7BIT;
-    }
-
-    static final FieldParser PARSER = new FieldParser() {
-        public ParsedField parse(final String name, final String body,
-                final ByteSequence raw) {
-            return new ContentTransferEncodingField(name, body, raw);
-        }
-    };
-}
+/****************************************************************
+ * 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.util.ByteSequence;
+import org.apache.james.mime4j.util.MimeUtil;
+
+/**
+ * Represents a <code>Content-Transfer-Encoding</code> field.
+ */
+public class ContentTransferEncodingField extends AbstractField {
+    private String encoding;
+
+    ContentTransferEncodingField(String name, String body, ByteSequence raw) {
+        super(name, body, raw);
+        encoding = body.trim().toLowerCase();
+    }
+
+    /**
+     * Gets the encoding defined in this field.
+     * 
+     * @return the encoding or an empty string if not set.
+     */
+    public String getEncoding() {
+        return encoding;
+    }
+
+    /**
+     * Gets the encoding of the given field if. Returns the default
+     * <code>7bit</code> if not set or if <code>f</code> is
+     * <code>null</code>.
+     * 
+     * @return the encoding.
+     */
+    public static String getEncoding(ContentTransferEncodingField f) {
+        if (f != null && f.getEncoding().length() != 0) {
+            return f.getEncoding();
+        }
+        return MimeUtil.ENC_7BIT;
+    }
+
+    static final FieldParser PARSER = new FieldParser() {
+        public ParsedField parse(final String name, final String body,
+                final ByteSequence raw) {
+            return new ContentTransferEncodingField(name, body, raw);
+        }
+    };
+}

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

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/ContentTypeField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/ContentTypeField.java?rev=778457&r1=778456&r2=778457&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/ContentTypeField.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/ContentTypeField.java Mon May 25 17:20:48 2009
@@ -1,258 +1,258 @@
-/****************************************************************
- * 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.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.james.mime4j.field.contenttype.parser.ContentTypeParser;
-import org.apache.james.mime4j.field.contenttype.parser.ParseException;
-import org.apache.james.mime4j.field.contenttype.parser.TokenMgrError;
-import org.apache.james.mime4j.util.ByteSequence;
-
-/**
- * Represents a <code>Content-Type</code> field.
- */
-public class ContentTypeField extends AbstractField {
-    private static Log log = LogFactory.getLog(ContentTypeField.class);
-
-    /** The prefix of all <code>multipart</code> MIME types. */
-    public static final String TYPE_MULTIPART_PREFIX = "multipart/";
-
-    /** The <code>multipart/digest</code> MIME type. */
-    public static final String TYPE_MULTIPART_DIGEST = "multipart/digest";
-
-    /** The <code>text/plain</code> MIME type. */
-    public static final String TYPE_TEXT_PLAIN = "text/plain";
-
-    /** The <code>message/rfc822</code> MIME type. */
-    public static final String TYPE_MESSAGE_RFC822 = "message/rfc822";
-
-    /** The name of the <code>boundary</code> parameter. */
-    public static final String PARAM_BOUNDARY = "boundary";
-
-    /** The name of the <code>charset</code> parameter. */
-    public static final String PARAM_CHARSET = "charset";
-
-    private boolean parsed = false;
-
-    private String mimeType = "";
-    private Map<String, String> parameters = new HashMap<String, String>();
-    private ParseException parseException;
-
-    ContentTypeField(String name, String body, ByteSequence raw) {
-        super(name, body, raw);
-    }
-
-    /**
-     * Gets the exception that was raised during parsing of the field value, if
-     * any; otherwise, null.
-     */
-    @Override
-    public ParseException getParseException() {
-        if (!parsed)
-            parse();
-
-        return parseException;
-    }
-
-    /**
-     * Gets the MIME type defined in this Content-Type field.
-     * 
-     * @return the MIME type or an empty string if not set.
-     */
-    public String getMimeType() {
-        if (!parsed)
-            parse();
-
-        return mimeType;
-    }
-
-    /**
-     * Gets the value of a parameter. Parameter names are case-insensitive.
-     * 
-     * @param name
-     *            the name of the parameter to get.
-     * @return the parameter value or <code>null</code> if not set.
-     */
-    public String getParameter(String name) {
-        if (!parsed)
-            parse();
-
-        return parameters.get(name.toLowerCase());
-    }
-
-    /**
-     * Gets all parameters.
-     * 
-     * @return the parameters.
-     */
-    public Map<String, String> getParameters() {
-        if (!parsed)
-            parse();
-
-        return Collections.unmodifiableMap(parameters);
-    }
-
-    /**
-     * Determines if the MIME type of this field matches the given one.
-     * 
-     * @param mimeType
-     *            the MIME type to match against.
-     * @return <code>true</code> if the MIME type of this field matches,
-     *         <code>false</code> otherwise.
-     */
-    public boolean isMimeType(String mimeType) {
-        if (!parsed)
-            parse();
-
-        return this.mimeType.equalsIgnoreCase(mimeType);
-    }
-
-    /**
-     * Determines if the MIME type of this field is <code>multipart/*</code>.
-     * 
-     * @return <code>true</code> if this field is has a
-     *         <code>multipart/*</code> MIME type, <code>false</code>
-     *         otherwise.
-     */
-    public boolean isMultipart() {
-        if (!parsed)
-            parse();
-
-        return mimeType.startsWith(TYPE_MULTIPART_PREFIX);
-    }
-
-    /**
-     * Gets the value of the <code>boundary</code> parameter if set.
-     * 
-     * @return the <code>boundary</code> parameter value or <code>null</code>
-     *         if not set.
-     */
-    public String getBoundary() {
-        return getParameter(PARAM_BOUNDARY);
-    }
-
-    /**
-     * Gets the value of the <code>charset</code> parameter if set.
-     * 
-     * @return the <code>charset</code> parameter value or <code>null</code>
-     *         if not set.
-     */
-    public String getCharset() {
-        return getParameter(PARAM_CHARSET);
-    }
-
-    /**
-     * Gets the MIME type defined in the child's Content-Type field or derives a
-     * MIME type from the parent if child is <code>null</code> or hasn't got a
-     * MIME type value set. If child's MIME type is multipart but no boundary
-     * has been set the MIME type of child will be derived from the parent.
-     * 
-     * @param child
-     *            the child.
-     * @param parent
-     *            the parent.
-     * @return the MIME type.
-     */
-    public static String getMimeType(ContentTypeField child,
-            ContentTypeField parent) {
-        if (child == null || child.getMimeType().length() == 0
-                || child.isMultipart() && child.getBoundary() == null) {
-
-            if (parent != null && parent.isMimeType(TYPE_MULTIPART_DIGEST)) {
-                return TYPE_MESSAGE_RFC822;
-            } else {
-                return TYPE_TEXT_PLAIN;
-            }
-        }
-
-        return child.getMimeType();
-    }
-
-    /**
-     * Gets the value of the <code>charset</code> parameter if set for the
-     * given field. Returns the default <code>us-ascii</code> if not set or if
-     * <code>f</code> is <code>null</code>.
-     * 
-     * @return the <code>charset</code> parameter value.
-     */
-    public static String getCharset(ContentTypeField f) {
-        if (f != null) {
-            String charset = f.getCharset();
-            if (charset != null && charset.length() > 0) {
-                return charset;
-            }
-        }
-        return "us-ascii";
-    }
-
-    private void parse() {
-        String body = getBody();
-
-        ContentTypeParser parser = new ContentTypeParser(new StringReader(body));
-        try {
-            parser.parseAll();
-        } catch (ParseException e) {
-            if (log.isDebugEnabled()) {
-                log.debug("Parsing value '" + body + "': " + e.getMessage());
-            }
-            parseException = e;
-        } catch (TokenMgrError e) {
-            if (log.isDebugEnabled()) {
-                log.debug("Parsing value '" + body + "': " + e.getMessage());
-            }
-            parseException = new ParseException(e.getMessage());
-        }
-
-        final String type = parser.getType();
-        final String subType = parser.getSubType();
-
-        if (type != null && subType != null) {
-            mimeType = (type + "/" + subType).toLowerCase();
-
-            List<String> paramNames = parser.getParamNames();
-            List<String> paramValues = parser.getParamValues();
-
-            if (paramNames != null && paramValues != null) {
-                final int len = Math.min(paramNames.size(), paramValues.size());
-                for (int i = 0; i < len; i++) {
-                    String paramName = paramNames.get(i).toLowerCase();
-                    String paramValue = paramValues.get(i);
-                    parameters.put(paramName, paramValue);
-                }
-            }
-        }
-
-        parsed = true;
-    }
-
-    static final FieldParser PARSER = new FieldParser() {
-        public ParsedField parse(final String name, final String body,
-                final ByteSequence raw) {
-            return new ContentTypeField(name, body, raw);
-        }
-    };
-}
+/****************************************************************
+ * 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.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.james.mime4j.field.contenttype.parser.ContentTypeParser;
+import org.apache.james.mime4j.field.contenttype.parser.ParseException;
+import org.apache.james.mime4j.field.contenttype.parser.TokenMgrError;
+import org.apache.james.mime4j.util.ByteSequence;
+
+/**
+ * Represents a <code>Content-Type</code> field.
+ */
+public class ContentTypeField extends AbstractField {
+    private static Log log = LogFactory.getLog(ContentTypeField.class);
+
+    /** The prefix of all <code>multipart</code> MIME types. */
+    public static final String TYPE_MULTIPART_PREFIX = "multipart/";
+
+    /** The <code>multipart/digest</code> MIME type. */
+    public static final String TYPE_MULTIPART_DIGEST = "multipart/digest";
+
+    /** The <code>text/plain</code> MIME type. */
+    public static final String TYPE_TEXT_PLAIN = "text/plain";
+
+    /** The <code>message/rfc822</code> MIME type. */
+    public static final String TYPE_MESSAGE_RFC822 = "message/rfc822";
+
+    /** The name of the <code>boundary</code> parameter. */
+    public static final String PARAM_BOUNDARY = "boundary";
+
+    /** The name of the <code>charset</code> parameter. */
+    public static final String PARAM_CHARSET = "charset";
+
+    private boolean parsed = false;
+
+    private String mimeType = "";
+    private Map<String, String> parameters = new HashMap<String, String>();
+    private ParseException parseException;
+
+    ContentTypeField(String name, String body, ByteSequence raw) {
+        super(name, body, raw);
+    }
+
+    /**
+     * Gets the exception that was raised during parsing of the field value, if
+     * any; otherwise, null.
+     */
+    @Override
+    public ParseException getParseException() {
+        if (!parsed)
+            parse();
+
+        return parseException;
+    }
+
+    /**
+     * Gets the MIME type defined in this Content-Type field.
+     * 
+     * @return the MIME type or an empty string if not set.
+     */
+    public String getMimeType() {
+        if (!parsed)
+            parse();
+
+        return mimeType;
+    }
+
+    /**
+     * Gets the value of a parameter. Parameter names are case-insensitive.
+     * 
+     * @param name
+     *            the name of the parameter to get.
+     * @return the parameter value or <code>null</code> if not set.
+     */
+    public String getParameter(String name) {
+        if (!parsed)
+            parse();
+
+        return parameters.get(name.toLowerCase());
+    }
+
+    /**
+     * Gets all parameters.
+     * 
+     * @return the parameters.
+     */
+    public Map<String, String> getParameters() {
+        if (!parsed)
+            parse();
+
+        return Collections.unmodifiableMap(parameters);
+    }
+
+    /**
+     * Determines if the MIME type of this field matches the given one.
+     * 
+     * @param mimeType
+     *            the MIME type to match against.
+     * @return <code>true</code> if the MIME type of this field matches,
+     *         <code>false</code> otherwise.
+     */
+    public boolean isMimeType(String mimeType) {
+        if (!parsed)
+            parse();
+
+        return this.mimeType.equalsIgnoreCase(mimeType);
+    }
+
+    /**
+     * Determines if the MIME type of this field is <code>multipart/*</code>.
+     * 
+     * @return <code>true</code> if this field is has a
+     *         <code>multipart/*</code> MIME type, <code>false</code>
+     *         otherwise.
+     */
+    public boolean isMultipart() {
+        if (!parsed)
+            parse();
+
+        return mimeType.startsWith(TYPE_MULTIPART_PREFIX);
+    }
+
+    /**
+     * Gets the value of the <code>boundary</code> parameter if set.
+     * 
+     * @return the <code>boundary</code> parameter value or <code>null</code>
+     *         if not set.
+     */
+    public String getBoundary() {
+        return getParameter(PARAM_BOUNDARY);
+    }
+
+    /**
+     * Gets the value of the <code>charset</code> parameter if set.
+     * 
+     * @return the <code>charset</code> parameter value or <code>null</code>
+     *         if not set.
+     */
+    public String getCharset() {
+        return getParameter(PARAM_CHARSET);
+    }
+
+    /**
+     * Gets the MIME type defined in the child's Content-Type field or derives a
+     * MIME type from the parent if child is <code>null</code> or hasn't got a
+     * MIME type value set. If child's MIME type is multipart but no boundary
+     * has been set the MIME type of child will be derived from the parent.
+     * 
+     * @param child
+     *            the child.
+     * @param parent
+     *            the parent.
+     * @return the MIME type.
+     */
+    public static String getMimeType(ContentTypeField child,
+            ContentTypeField parent) {
+        if (child == null || child.getMimeType().length() == 0
+                || child.isMultipart() && child.getBoundary() == null) {
+
+            if (parent != null && parent.isMimeType(TYPE_MULTIPART_DIGEST)) {
+                return TYPE_MESSAGE_RFC822;
+            } else {
+                return TYPE_TEXT_PLAIN;
+            }
+        }
+
+        return child.getMimeType();
+    }
+
+    /**
+     * Gets the value of the <code>charset</code> parameter if set for the
+     * given field. Returns the default <code>us-ascii</code> if not set or if
+     * <code>f</code> is <code>null</code>.
+     * 
+     * @return the <code>charset</code> parameter value.
+     */
+    public static String getCharset(ContentTypeField f) {
+        if (f != null) {
+            String charset = f.getCharset();
+            if (charset != null && charset.length() > 0) {
+                return charset;
+            }
+        }
+        return "us-ascii";
+    }
+
+    private void parse() {
+        String body = getBody();
+
+        ContentTypeParser parser = new ContentTypeParser(new StringReader(body));
+        try {
+            parser.parseAll();
+        } catch (ParseException e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Parsing value '" + body + "': " + e.getMessage());
+            }
+            parseException = e;
+        } catch (TokenMgrError e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Parsing value '" + body + "': " + e.getMessage());
+            }
+            parseException = new ParseException(e.getMessage());
+        }
+
+        final String type = parser.getType();
+        final String subType = parser.getSubType();
+
+        if (type != null && subType != null) {
+            mimeType = (type + "/" + subType).toLowerCase();
+
+            List<String> paramNames = parser.getParamNames();
+            List<String> paramValues = parser.getParamValues();
+
+            if (paramNames != null && paramValues != null) {
+                final int len = Math.min(paramNames.size(), paramValues.size());
+                for (int i = 0; i < len; i++) {
+                    String paramName = paramNames.get(i).toLowerCase();
+                    String paramValue = paramValues.get(i);
+                    parameters.put(paramName, paramValue);
+                }
+            }
+        }
+
+        parsed = true;
+    }
+
+    static final FieldParser PARSER = new FieldParser() {
+        public ParsedField parse(final String name, final String body,
+                final ByteSequence raw) {
+            return new ContentTypeField(name, body, raw);
+        }
+    };
+}

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

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/DateTimeField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/DateTimeField.java?rev=778457&r1=778456&r2=778457&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/DateTimeField.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/DateTimeField.java Mon May 25 17:20:48 2009
@@ -1,89 +1,89 @@
-/****************************************************************
- * 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.Date;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.james.mime4j.field.datetime.parser.DateTimeParser;
-import org.apache.james.mime4j.field.datetime.parser.ParseException;
-import org.apache.james.mime4j.field.datetime.parser.TokenMgrError;
-import org.apache.james.mime4j.util.ByteSequence;
-
-/**
- * Date-time field such as <code>Date</code> or <code>Resent-Date</code>.
- */
-public class DateTimeField extends AbstractField {
-    private static Log log = LogFactory.getLog(DateTimeField.class);
-
-    private boolean parsed = false;
-
-    private Date date;
-    private ParseException parseException;
-
-    DateTimeField(String name, String body, ByteSequence raw) {
-        super(name, body, raw);
-    }
-
-    public Date getDate() {
-        if (!parsed)
-            parse();
-
-        return date;
-    }
-
-    @Override
-    public ParseException getParseException() {
-        if (!parsed)
-            parse();
-
-        return parseException;
-    }
-
-    private void parse() {
-        String body = getBody();
-
-        try {
-            date = new DateTimeParser(new StringReader(body)).parseAll()
-                    .getDate();
-        } catch (ParseException e) {
-            if (log.isDebugEnabled()) {
-                log.debug("Parsing value '" + body + "': " + e.getMessage());
-            }
-            parseException = e;
-        } catch (TokenMgrError e) {
-            if (log.isDebugEnabled()) {
-                log.debug("Parsing value '" + body + "': " + e.getMessage());
-            }
-            parseException = new ParseException(e.getMessage());
-        }
-
-        parsed = true;
-    }
-
-    static final FieldParser PARSER = new FieldParser() {
-        public ParsedField parse(final String name, final String body,
-                final ByteSequence raw) {
-            return new DateTimeField(name, body, raw);
-        }
-    };
-}
+/****************************************************************
+ * 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.Date;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.james.mime4j.field.datetime.parser.DateTimeParser;
+import org.apache.james.mime4j.field.datetime.parser.ParseException;
+import org.apache.james.mime4j.field.datetime.parser.TokenMgrError;
+import org.apache.james.mime4j.util.ByteSequence;
+
+/**
+ * Date-time field such as <code>Date</code> or <code>Resent-Date</code>.
+ */
+public class DateTimeField extends AbstractField {
+    private static Log log = LogFactory.getLog(DateTimeField.class);
+
+    private boolean parsed = false;
+
+    private Date date;
+    private ParseException parseException;
+
+    DateTimeField(String name, String body, ByteSequence raw) {
+        super(name, body, raw);
+    }
+
+    public Date getDate() {
+        if (!parsed)
+            parse();
+
+        return date;
+    }
+
+    @Override
+    public ParseException getParseException() {
+        if (!parsed)
+            parse();
+
+        return parseException;
+    }
+
+    private void parse() {
+        String body = getBody();
+
+        try {
+            date = new DateTimeParser(new StringReader(body)).parseAll()
+                    .getDate();
+        } catch (ParseException e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Parsing value '" + body + "': " + e.getMessage());
+            }
+            parseException = e;
+        } catch (TokenMgrError e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Parsing value '" + body + "': " + e.getMessage());
+            }
+            parseException = new ParseException(e.getMessage());
+        }
+
+        parsed = true;
+    }
+
+    static final FieldParser PARSER = new FieldParser() {
+        public ParsedField parse(final String name, final String body,
+                final ByteSequence raw) {
+            return new DateTimeField(name, body, raw);
+        }
+    };
+}

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

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/DefaultFieldParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/DefaultFieldParser.java?rev=778457&r1=778456&r2=778457&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/DefaultFieldParser.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/DefaultFieldParser.java Mon May 25 17:20:48 2009
@@ -1,53 +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;
-
-public class DefaultFieldParser extends DelegatingFieldParser {
-
-    public DefaultFieldParser() {
-        setFieldParser(FieldName.CONTENT_TRANSFER_ENCODING,
-                ContentTransferEncodingField.PARSER);
-        setFieldParser(FieldName.CONTENT_TYPE, ContentTypeField.PARSER);
-        setFieldParser(FieldName.CONTENT_DISPOSITION,
-                ContentDispositionField.PARSER);
-
-        final FieldParser dateTimeParser = DateTimeField.PARSER;
-        setFieldParser(FieldName.DATE, dateTimeParser);
-        setFieldParser(FieldName.RESENT_DATE, dateTimeParser);
-
-        final FieldParser mailboxListParser = MailboxListField.PARSER;
-        setFieldParser(FieldName.FROM, mailboxListParser);
-        setFieldParser(FieldName.RESENT_FROM, mailboxListParser);
-
-        final FieldParser mailboxParser = MailboxField.PARSER;
-        setFieldParser(FieldName.SENDER, mailboxParser);
-        setFieldParser(FieldName.RESENT_SENDER, mailboxParser);
-
-        final FieldParser addressListParser = AddressListField.PARSER;
-        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);
-    }
-
-}
+/****************************************************************
+ * 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;
+
+public class DefaultFieldParser extends DelegatingFieldParser {
+
+    public DefaultFieldParser() {
+        setFieldParser(FieldName.CONTENT_TRANSFER_ENCODING,
+                ContentTransferEncodingField.PARSER);
+        setFieldParser(FieldName.CONTENT_TYPE, ContentTypeField.PARSER);
+        setFieldParser(FieldName.CONTENT_DISPOSITION,
+                ContentDispositionField.PARSER);
+
+        final FieldParser dateTimeParser = DateTimeField.PARSER;
+        setFieldParser(FieldName.DATE, dateTimeParser);
+        setFieldParser(FieldName.RESENT_DATE, dateTimeParser);
+
+        final FieldParser mailboxListParser = MailboxListField.PARSER;
+        setFieldParser(FieldName.FROM, mailboxListParser);
+        setFieldParser(FieldName.RESENT_FROM, mailboxListParser);
+
+        final FieldParser mailboxParser = MailboxField.PARSER;
+        setFieldParser(FieldName.SENDER, mailboxParser);
+        setFieldParser(FieldName.RESENT_SENDER, mailboxParser);
+
+        final FieldParser addressListParser = AddressListField.PARSER;
+        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);
+    }
+
+}

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

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java?rev=778457&r1=778456&r2=778457&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java Mon May 25 17:20:48 2009
@@ -1,53 +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;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.james.mime4j.util.ByteSequence;
-
-public class DelegatingFieldParser implements FieldParser {
-    
-    private Map<String, FieldParser> parsers = new HashMap<String, FieldParser>();
-    private FieldParser defaultParser = UnstructuredField.PARSER;
-    
-    /**
-     * Sets the parser used for the field named <code>name</code>.
-     * @param name the name of the field
-     * @param parser the parser for fields named <code>name</code>
-     */
-    public void setFieldParser(final String name, final FieldParser parser) {
-        parsers.put(name.toLowerCase(), parser);
-    }
-    
-    public FieldParser getParser(final String name) {
-        final FieldParser field = parsers.get(name.toLowerCase());
-        if(field==null) {
-            return defaultParser;
-        }
-        return field;
-    }
-    
-    public ParsedField parse(final String name, final String body, final ByteSequence raw) {
-        final FieldParser parser = getParser(name);
-        return parser.parse(name, body, raw);
-    }
-}
+/****************************************************************
+ * 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.util.HashMap;
+import java.util.Map;
+
+import org.apache.james.mime4j.util.ByteSequence;
+
+public class DelegatingFieldParser implements FieldParser {
+    
+    private Map<String, FieldParser> parsers = new HashMap<String, FieldParser>();
+    private FieldParser defaultParser = UnstructuredField.PARSER;
+    
+    /**
+     * Sets the parser used for the field named <code>name</code>.
+     * @param name the name of the field
+     * @param parser the parser for fields named <code>name</code>
+     */
+    public void setFieldParser(final String name, final FieldParser parser) {
+        parsers.put(name.toLowerCase(), parser);
+    }
+    
+    public FieldParser getParser(final String name) {
+        final FieldParser field = parsers.get(name.toLowerCase());
+        if(field==null) {
+            return defaultParser;
+        }
+        return field;
+    }
+    
+    public ParsedField parse(final String name, final String body, final ByteSequence raw) {
+        final FieldParser parser = getParser(name);
+        return parser.parse(name, body, raw);
+    }
+}

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

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

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/FieldParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/FieldParser.java?rev=778457&r1=778456&r2=778457&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/FieldParser.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/FieldParser.java Mon May 25 17:20:48 2009
@@ -1,28 +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.field;
-
-import org.apache.james.mime4j.util.ByteSequence;
-
-public interface FieldParser {
-    
-    ParsedField parse(final String name, final String body, final ByteSequence raw);
-    
-}
+/****************************************************************
+ * 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.util.ByteSequence;
+
+public interface FieldParser {
+    
+    ParsedField parse(final String name, final String body, final ByteSequence raw);
+    
+}

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

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

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/MailboxField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/MailboxField.java?rev=778457&r1=778456&r2=778457&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/MailboxField.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/MailboxField.java Mon May 25 17:20:48 2009
@@ -1,84 +1,84 @@
-/****************************************************************
- * 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.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.james.mime4j.field.address.AddressList;
-import org.apache.james.mime4j.field.address.Mailbox;
-import org.apache.james.mime4j.field.address.MailboxList;
-import org.apache.james.mime4j.field.address.parser.ParseException;
-import org.apache.james.mime4j.util.ByteSequence;
-
-/**
- * Mailbox field such as <code>Sender</code> or <code>Resent-Sender</code>.
- */
-public class MailboxField extends AbstractField {
-    private static Log log = LogFactory.getLog(MailboxField.class);
-
-    private boolean parsed = false;
-
-    private Mailbox mailbox;
-    private ParseException parseException;
-
-    MailboxField(final String name, final String body, final ByteSequence raw) {
-        super(name, body, raw);
-    }
-
-    public Mailbox getMailbox() {
-        if (!parsed)
-            parse();
-
-        return mailbox;
-    }
-
-    @Override
-    public ParseException getParseException() {
-        if (!parsed)
-            parse();
-
-        return parseException;
-    }
-
-    private void parse() {
-        String body = getBody();
-
-        try {
-            MailboxList mailboxList = AddressList.parse(body).flatten();
-            if (mailboxList.size() > 0) {
-                mailbox = mailboxList.get(0);
-            }
-        } catch (ParseException e) {
-            if (log.isDebugEnabled()) {
-                log.debug("Parsing value '" + body + "': " + e.getMessage());
-            }
-            parseException = e;
-        }
-
-        parsed = true;
-    }
-
-    static final FieldParser PARSER = new FieldParser() {
-        public ParsedField parse(final String name, final String body,
-                final ByteSequence raw) {
-            return new MailboxField(name, body, raw);
-        }
-    };
-}
+/****************************************************************
+ * 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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.james.mime4j.field.address.AddressList;
+import org.apache.james.mime4j.field.address.Mailbox;
+import org.apache.james.mime4j.field.address.MailboxList;
+import org.apache.james.mime4j.field.address.parser.ParseException;
+import org.apache.james.mime4j.util.ByteSequence;
+
+/**
+ * Mailbox field such as <code>Sender</code> or <code>Resent-Sender</code>.
+ */
+public class MailboxField extends AbstractField {
+    private static Log log = LogFactory.getLog(MailboxField.class);
+
+    private boolean parsed = false;
+
+    private Mailbox mailbox;
+    private ParseException parseException;
+
+    MailboxField(final String name, final String body, final ByteSequence raw) {
+        super(name, body, raw);
+    }
+
+    public Mailbox getMailbox() {
+        if (!parsed)
+            parse();
+
+        return mailbox;
+    }
+
+    @Override
+    public ParseException getParseException() {
+        if (!parsed)
+            parse();
+
+        return parseException;
+    }
+
+    private void parse() {
+        String body = getBody();
+
+        try {
+            MailboxList mailboxList = AddressList.parse(body).flatten();
+            if (mailboxList.size() > 0) {
+                mailbox = mailboxList.get(0);
+            }
+        } catch (ParseException e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Parsing value '" + body + "': " + e.getMessage());
+            }
+            parseException = e;
+        }
+
+        parsed = true;
+    }
+
+    static final FieldParser PARSER = new FieldParser() {
+        public ParsedField parse(final String name, final String body,
+                final ByteSequence raw) {
+            return new MailboxField(name, body, raw);
+        }
+    };
+}

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

Modified: james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/MailboxListField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/MailboxListField.java?rev=778457&r1=778456&r2=778457&view=diff
==============================================================================
--- james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/MailboxListField.java (original)
+++ james/mime4j/trunk/core/src/main/java/org/apache/james/mime4j/field/MailboxListField.java Mon May 25 17:20:48 2009
@@ -1,80 +1,80 @@
-/****************************************************************
- * 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.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.james.mime4j.field.address.AddressList;
-import org.apache.james.mime4j.field.address.MailboxList;
-import org.apache.james.mime4j.field.address.parser.ParseException;
-import org.apache.james.mime4j.util.ByteSequence;
-
-/**
- * Mailbox-list field such as <code>From</code> or <code>Resent-From</code>.
- */
-public class MailboxListField extends AbstractField {
-    private static Log log = LogFactory.getLog(MailboxListField.class);
-
-    private boolean parsed = false;
-
-    private MailboxList mailboxList;
-    private ParseException parseException;
-
-    MailboxListField(final String name, final String body, final ByteSequence raw) {
-        super(name, body, raw);
-    }
-
-    public MailboxList getMailboxList() {
-        if (!parsed)
-            parse();
-
-        return mailboxList;
-    }
-
-    @Override
-    public ParseException getParseException() {
-        if (!parsed)
-            parse();
-
-        return parseException;
-    }
-
-    private void parse() {
-        String body = getBody();
-
-        try {
-            mailboxList = AddressList.parse(body).flatten();
-        } catch (ParseException e) {
-            if (log.isDebugEnabled()) {
-                log.debug("Parsing value '" + body + "': " + e.getMessage());
-            }
-            parseException = e;
-        }
-
-        parsed = true;
-    }
-
-    static final FieldParser PARSER = new FieldParser() {
-        public ParsedField parse(final String name, final String body,
-                final ByteSequence raw) {
-            return new MailboxListField(name, body, raw);
-        }
-    };
-}
+/****************************************************************
+ * 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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.james.mime4j.field.address.AddressList;
+import org.apache.james.mime4j.field.address.MailboxList;
+import org.apache.james.mime4j.field.address.parser.ParseException;
+import org.apache.james.mime4j.util.ByteSequence;
+
+/**
+ * Mailbox-list field such as <code>From</code> or <code>Resent-From</code>.
+ */
+public class MailboxListField extends AbstractField {
+    private static Log log = LogFactory.getLog(MailboxListField.class);
+
+    private boolean parsed = false;
+
+    private MailboxList mailboxList;
+    private ParseException parseException;
+
+    MailboxListField(final String name, final String body, final ByteSequence raw) {
+        super(name, body, raw);
+    }
+
+    public MailboxList getMailboxList() {
+        if (!parsed)
+            parse();
+
+        return mailboxList;
+    }
+
+    @Override
+    public ParseException getParseException() {
+        if (!parsed)
+            parse();
+
+        return parseException;
+    }
+
+    private void parse() {
+        String body = getBody();
+
+        try {
+            mailboxList = AddressList.parse(body).flatten();
+        } catch (ParseException e) {
+            if (log.isDebugEnabled()) {
+                log.debug("Parsing value '" + body + "': " + e.getMessage());
+            }
+            parseException = e;
+        }
+
+        parsed = true;
+    }
+
+    static final FieldParser PARSER = new FieldParser() {
+        public ParsedField parse(final String name, final String body,
+                final ByteSequence raw) {
+            return new MailboxListField(name, body, raw);
+        }
+    };
+}

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

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

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



Mime
View raw message