james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mwiederk...@apache.org
Subject svn commit: r748601 - /james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/
Date Fri, 27 Feb 2009 17:12:59 GMT
Author: mwiederkehr
Date: Fri Feb 27 17:12:58 2009
New Revision: 748601

URL: http://svn.apache.org/viewvc?rev=748601&view=rev
Log:
extracted interface ParsedField from class AbstractField

Added:
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ParsedField.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/AddressListField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentDispositionField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTypeField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DateTimeField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldParser.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxListField.java
    james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/UnstructuredField.java

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=748601&r1=748600&r2=748601&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 27 17:12:58 2009
@@ -23,7 +23,6 @@
 import java.util.regex.Pattern;
 
 import org.apache.james.mime4j.MimeException;
-import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.ByteSequence;
 import org.apache.james.mime4j.util.ContentUtil;
 import org.apache.james.mime4j.util.MimeUtil;
@@ -31,7 +30,7 @@
 /**
  * The base class of all field classes.
  */
-public abstract class AbstractField implements Field {
+public abstract class AbstractField implements ParsedField {
 
     private static final Pattern FIELD_NAME_PATTERN = Pattern
             .compile("^([\\x21-\\x39\\x3b-\\x7e]+):");
@@ -55,11 +54,11 @@
      * their corresponding classes.
      * 
      * @param raw the bytes to parse.
-     * @return a <code>Field</code> instance.
+     * @return a <code>ParsedField</code> instance.
      * @throws MimeException if the raw string cannot be split into field name and body.
      * @see #isValidField()
      */
-    public static Field parse(final ByteSequence raw) throws MimeException {
+    public static ParsedField parse(final ByteSequence raw) throws MimeException {
         String rawStr = ContentUtil.decode(raw);
         return parse(raw, rawStr);
     }
@@ -82,11 +81,11 @@
      * </table>
      * 
      * @param rawStr the string to parse.
-     * @return a <code>Field</code> instance.
+     * @return a <code>ParsedField</code> instance.
      * @throws MimeException if the raw string cannot be split into field name and body.
      * @see #isValidField()
      */
-    public static Field parse(final String rawStr) throws MimeException {
+    public static ParsedField parse(final String rawStr) throws MimeException {
         ByteSequence raw = ContentUtil.encode(rawStr);
         return parse(raw, rawStr);
     }
@@ -130,24 +129,14 @@
     }
 
     /**
-     * Returns <code>true</code> if this field is valid, i.e. no errors were
-     * encountered while parsing the field value.
-     * 
-     * @return <code>true</code> if this field is valid, <code>false</code>
-     *         otherwise.
-     * @see #getParseException()
+     * @see ParsedField#isValidField() 
      */
     public boolean isValidField() {
         return getParseException() == null;
     }
 
     /**
-     * Returns the exception that was thrown by the field parser while parsing
-     * the field value. The result is <code>null</code> if the field is valid
-     * and no errors were encountered.
-     * 
-     * @return the exception that was thrown by the field parser or
-     *         <code>null</code> if the field is valid.
+     * @see ParsedField#getParseException() 
      */
     public ParseException getParseException() {
         return null;
@@ -158,7 +147,7 @@
         return name + ": " + body;
     }
 
-    private static Field parse(final ByteSequence raw, final String rawStr)
+    private static ParsedField parse(final ByteSequence raw, final String rawStr)
             throws MimeException {
         /*
          * Unfold the field.

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AddressListField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AddressListField.java?rev=748601&r1=748600&r2=748601&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AddressListField.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/AddressListField.java Fri
Feb 27 17:12:58 2009
@@ -23,7 +23,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.james.mime4j.field.address.AddressList;
 import org.apache.james.mime4j.field.address.parser.ParseException;
-import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.ByteSequence;
 
 /**
@@ -72,7 +71,7 @@
     }
 
     static final FieldParser PARSER = new FieldParser() {
-        public Field parse(final String name, final String body,
+        public ParsedField parse(final String name, final String body,
                 final ByteSequence raw) {
             return new AddressListField(name, body, raw);
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentDispositionField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentDispositionField.java?rev=748601&r1=748600&r2=748601&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentDispositionField.java
(original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentDispositionField.java
Fri Feb 27 17:12:58 2009
@@ -32,7 +32,6 @@
 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.parser.Field;
 import org.apache.james.mime4j.util.ByteSequence;
 
 /**
@@ -319,7 +318,7 @@
     }
 
     static final FieldParser PARSER = new FieldParser() {
-        public Field parse(final String name, final String body,
+        public ParsedField parse(final String name, final String body,
                 final ByteSequence raw) {
             return new ContentDispositionField(name, body, raw);
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingField.java?rev=748601&r1=748600&r2=748601&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingField.java
(original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTransferEncodingField.java
Fri Feb 27 17:12:58 2009
@@ -19,7 +19,6 @@
 
 package org.apache.james.mime4j.field;
 
-import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.ByteSequence;
 import org.apache.james.mime4j.util.MimeUtil;
 
@@ -58,7 +57,7 @@
     }
 
     static final FieldParser PARSER = new FieldParser() {
-        public Field parse(final String name, final String body,
+        public ParsedField parse(final String name, final String body,
                 final ByteSequence raw) {
             return new ContentTransferEncodingField(name, body, raw);
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTypeField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTypeField.java?rev=748601&r1=748600&r2=748601&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTypeField.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ContentTypeField.java Fri
Feb 27 17:12:58 2009
@@ -30,7 +30,6 @@
 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.parser.Field;
 import org.apache.james.mime4j.util.ByteSequence;
 
 /**
@@ -251,7 +250,7 @@
     }
 
     static final FieldParser PARSER = new FieldParser() {
-        public Field parse(final String name, final String body,
+        public ParsedField parse(final String name, final String body,
                 final ByteSequence raw) {
             return new ContentTypeField(name, body, raw);
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DateTimeField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DateTimeField.java?rev=748601&r1=748600&r2=748601&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DateTimeField.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DateTimeField.java Fri
Feb 27 17:12:58 2009
@@ -27,7 +27,6 @@
 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.parser.Field;
 import org.apache.james.mime4j.util.ByteSequence;
 
 /**
@@ -82,7 +81,7 @@
     }
 
     static final FieldParser PARSER = new FieldParser() {
-        public Field parse(final String name, final String body,
+        public ParsedField parse(final String name, final String body,
                 final ByteSequence raw) {
             return new DateTimeField(name, body, raw);
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java?rev=748601&r1=748600&r2=748601&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java
(original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/DelegatingFieldParser.java
Fri Feb 27 17:12:58 2009
@@ -22,7 +22,6 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.ByteSequence;
 
 public class DelegatingFieldParser implements FieldParser {
@@ -47,7 +46,7 @@
         return field;
     }
     
-    public Field parse(final String name, final String body, final ByteSequence raw) {
+    public ParsedField parse(final String name, final String body, final ByteSequence raw)
{
         final FieldParser parser = getParser(name);
         return parser.parse(name, body, raw);
     }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldParser.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldParser.java?rev=748601&r1=748600&r2=748601&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldParser.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/FieldParser.java Fri Feb
27 17:12:58 2009
@@ -19,11 +19,10 @@
 
 package org.apache.james.mime4j.field;
 
-import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.ByteSequence;
 
 public interface FieldParser {
     
-    Field parse(final String name, final String body, final ByteSequence raw);
+    ParsedField parse(final String name, final String body, final ByteSequence raw);
     
 }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxField.java?rev=748601&r1=748600&r2=748601&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxField.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxField.java Fri Feb
27 17:12:58 2009
@@ -25,7 +25,6 @@
 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.parser.Field;
 import org.apache.james.mime4j.util.ByteSequence;
 
 /**
@@ -77,7 +76,7 @@
     }
 
     static final FieldParser PARSER = new FieldParser() {
-        public Field parse(final String name, final String body,
+        public ParsedField parse(final String name, final String body,
                 final ByteSequence raw) {
             return new MailboxField(name, body, raw);
         }

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxListField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxListField.java?rev=748601&r1=748600&r2=748601&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxListField.java (original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/MailboxListField.java Fri
Feb 27 17:12:58 2009
@@ -24,7 +24,6 @@
 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.parser.Field;
 import org.apache.james.mime4j.util.ByteSequence;
 
 /**
@@ -73,7 +72,7 @@
     }
 
     static final FieldParser PARSER = new FieldParser() {
-        public Field parse(final String name, final String body,
+        public ParsedField parse(final String name, final String body,
                 final ByteSequence raw) {
             return new MailboxListField(name, body, raw);
         }

Added: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ParsedField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ParsedField.java?rev=748601&view=auto
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ParsedField.java (added)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/ParsedField.java Fri Feb
27 17:12:58 2009
@@ -0,0 +1,46 @@
+/****************************************************************
+ * 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.parser.Field;
+
+public interface ParsedField extends Field {
+
+    /**
+     * Returns <code>true</code> if this field is valid, i.e. no errors were
+     * encountered while parsing the field value.
+     * 
+     * @return <code>true</code> if this field is valid, <code>false</code>
+     *         otherwise.
+     * @see #getParseException()
+     */
+    boolean isValidField();
+
+    /**
+     * Returns the exception that was thrown by the field parser while parsing
+     * the field value. The result is <code>null</code> if the field is valid
+     * and no errors were encountered.
+     * 
+     * @return the exception that was thrown by the field parser or
+     *         <code>null</code> if the field is valid.
+     */
+    ParseException getParseException();
+
+}

Modified: james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/UnstructuredField.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/UnstructuredField.java?rev=748601&r1=748600&r2=748601&view=diff
==============================================================================
--- james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/UnstructuredField.java
(original)
+++ james/mime4j/trunk/src/main/java/org/apache/james/mime4j/field/UnstructuredField.java
Fri Feb 27 17:12:58 2009
@@ -20,7 +20,6 @@
 package org.apache.james.mime4j.field;
 
 import org.apache.james.mime4j.codec.DecoderUtil;
-import org.apache.james.mime4j.parser.Field;
 import org.apache.james.mime4j.util.ByteSequence;
 
 /**
@@ -51,7 +50,7 @@
     }
 
     static final FieldParser PARSER = new FieldParser() {
-        public Field parse(final String name, final String body,
+        public ParsedField parse(final String name, final String body,
                 final ByteSequence raw) {
             return new UnstructuredField(name, body, raw);
         }



Mime
View raw message