james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r958717 - in /james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j: dom/MessageBuilder.java message/MessageBuilderImpl.java message/MessageImpl.java
Date Mon, 28 Jun 2010 20:43:32 GMT
Author: bago
Date: Mon Jun 28 20:43:31 2010
New Revision: 958717

URL: http://svn.apache.org/viewvc?rev=958717&view=rev
Log:
Expose contentDecoding and FlatMode via MessageBuilder API (MIME4J-175)

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/MessageBuilderImpl.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.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=958717&r1=958716&r2=958717&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 28 20:43:31 2010
@@ -39,4 +39,8 @@ public abstract class MessageBuilder {
     public abstract void setDecodeMonitor(
             DecodeMonitor decodeMonitor);
 
+    public abstract void setContentDecoding(boolean contentDecoding);
+    
+    public abstract void setFlatMode();
+
 }

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java?rev=958717&r1=958716&r2=958717&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java
(original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java
Mon Jun 28 20:43:31 2010
@@ -21,6 +21,8 @@ public class MessageBuilderImpl extends 
     private DecodeMonitor decodeMonitor = null;
     private MimeEntityConfig mimeEntityConfig = null;
     private MutableBodyDescriptorFactory mutableBodyDescriptorFactory = null;
+    private boolean flatMode = false;
+    private boolean contentDecoding = true;
 
     public MessageBuilderImpl() {
     }
@@ -37,7 +39,7 @@ public class MessageBuilderImpl extends 
 
     @Override
     public Message parse(InputStream source) throws MimeException, IOException {
-        return new MessageImpl(source, mimeEntityConfig, storageProvider, mutableBodyDescriptorFactory,
decodeMonitor);
+        return new MessageImpl(source, mimeEntityConfig, storageProvider, mutableBodyDescriptorFactory,
decodeMonitor, contentDecoding, flatMode);
     }
 
     @Override
@@ -58,4 +60,14 @@ public class MessageBuilderImpl extends 
         this.mutableBodyDescriptorFactory  = mutableBodyDescriptorFactory;
     }
 
+    @Override
+    public void setContentDecoding(boolean contentDecoding) {
+        this.contentDecoding  = contentDecoding;
+    }
+
+    @Override
+    public void setFlatMode() {
+        this.flatMode = true;
+    }
+
 }

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java?rev=958717&r1=958716&r2=958717&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
(original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageImpl.java
Mon Jun 28 20:43:31 2010
@@ -66,8 +66,6 @@ import org.apache.james.mime4j.util.Mime
  */
 public class MessageImpl extends Message {
 
-    private DecodeMonitor monitor;
-
     /**
      * Creates a new empty <code>Message</code>.
      */
@@ -158,17 +156,47 @@ public class MessageImpl extends Message
             final StorageProvider storageProvider, 
             final MutableBodyDescriptorFactory bodyDescFactory,
             final DecodeMonitor monitor) throws IOException, MimeIOException {
+        this(is, config, storageProvider, bodyDescFactory, monitor, true, false);
+    }
+    
+    /**
+     * Parses the specified MIME message stream into a <code>Message</code>
+     * instance using given {@link MimeEntityConfig} and {@link StorageProvider}.
+     * 
+     * @param is
+     *            the stream to parse.
+     * @param config
+     *            {@link MimeEntityConfig} to use.
+     * @param storageProvider
+     *            {@link StorageProvider} to use for storing text and binary
+     *            message bodies.
+     * @param bodyDescFactory
+     *            {@link MutableBodyDescriptorFactory} to use for creating body descriptors.
+     * @throws IOException
+     *             on I/O errors.
+     * @throws MimeIOException
+     *             on MIME protocol violations.
+     */
+    public MessageImpl(
+            final InputStream is, 
+            final MimeEntityConfig config,
+            final StorageProvider storageProvider, 
+            final MutableBodyDescriptorFactory bodyDescFactory,
+            final DecodeMonitor monitor,
+            boolean contentDecoding,
+            boolean flatMode) throws IOException, MimeIOException {
         try {
-            this.monitor = monitor != null ? monitor : DecodeMonitor.SILENT;
-            MimeStreamParser parser = new MimeStreamParser(config, bodyDescFactory, this.monitor);
-            parser.setContentDecoding(true);
-            parser.setContentHandler(new EntityBuilder(this, storageProvider, this.monitor));
+            DecodeMonitor mon = monitor != null ? monitor : DecodeMonitor.SILENT;
+            MimeStreamParser parser = new MimeStreamParser(config, bodyDescFactory, mon);
+            parser.setContentHandler(new EntityBuilder(this, storageProvider, mon));
+            parser.setContentDecoding(contentDecoding);
+            if (flatMode) parser.setFlat(true);
             parser.parse(is);
         } catch (MimeException e) {
             throw new MimeIOException(e);
         }
     }
-
+    
     public MessageImpl(
             final InputStream is, 
             final MimeEntityConfig config,



Mime
View raw message