james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1137655 - in /james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j: dom/MessageBuilder.java message/DefaultMessageBuilder.java
Date Mon, 20 Jun 2011 15:16:34 GMT
Author: olegk
Date: Mon Jun 20 15:16:33 2011
New Revision: 1137655

URL: http://svn.apache.org/viewvc?rev=1137655&view=rev
Log:
Added methods to create Header and Multipart instances to MessageBuilder interface

Modified:
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/MessageBuilder.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/DefaultMessageBuilder.java

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/MessageBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/MessageBuilder.java?rev=1137655&r1=1137654&r2=1137655&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/MessageBuilder.java (original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/dom/MessageBuilder.java Mon
Jun 20 15:16:33 2011
@@ -28,11 +28,21 @@ import org.apache.james.mime4j.MimeExcep
  * Defines the API to obtain Message instances from a mime stream.
  */
 public interface MessageBuilder {
+
+    Header newHeader();
     
+    Header newHeader(Header source);
+
+    Multipart newMultipart(String subType);
+    
+    Multipart newMultipart(Multipart source);
+
     Message newMessage();
           
     Message newMessage(Message source);
-          
+
+    Header parseHeader(InputStream source) throws MimeException, IOException;
+    
     Message parseMessage(InputStream source) throws MimeException, IOException;
           
 }
\ No newline at end of file

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/DefaultMessageBuilder.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/DefaultMessageBuilder.java?rev=1137655&r1=1137654&r2=1137655&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/DefaultMessageBuilder.java
(original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/DefaultMessageBuilder.java
Mon Jun 20 15:16:33 2011
@@ -230,16 +230,30 @@ public class DefaultMessageBuilder imple
         }
         return copy;
     }
-    
-    /**
-     * Creates a new <code>Header</code> from the specified stream.
-     * 
-     * @param is the stream to read the header from.
-     * 
-     * @throws IOException on I/O errors.
-     * @throws MimeIOException on MIME protocol violations.
-     */
+
+    public Header newHeader() {
+        return new HeaderImpl();
+    }
+
+    public Header newHeader(final Header source) {
+        return copy(source);
+    }
+
+    public Multipart newMultipart(final String subType) {
+        return new MultipartImpl(subType);
+    }
+
+    public Multipart newMultipart(final Multipart source) {
+        return copy(source);
+    }
+
     public Header parseHeader(final InputStream is) throws IOException, MimeIOException {
+        final MimeEntityConfig cfg = config != null ? config : new MimeEntityConfig();
+        boolean strict = cfg.isStrictParsing();
+        final DecodeMonitor mon = monitor != null ? monitor : 
+            strict ? DecodeMonitor.STRICT : DecodeMonitor.SILENT;
+        final FieldParser<? extends ParsedField> fp = fieldParser != null ? fieldParser
: 
+            strict ? DefaultFieldParser.getParser() : LenientFieldParser.getParser();
         final HeaderImpl header = new HeaderImpl();
         final MimeStreamParser parser = new MimeStreamParser();
         parser.setContentHandler(new AbstractContentHandler() {
@@ -253,7 +267,7 @@ public class DefaultMessageBuilder imple
                 if (field instanceof ParsedField) {
                     parsedField = (ParsedField) field;
                 } else {
-                    parsedField = fieldParser.parse(field, monitor);
+                    parsedField = fp.parse(field, mon);
                 }
                 header.addField(parsedField);
             }



Mime
View raw message