james-mime4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From b...@apache.org
Subject svn commit: r937694 - in /james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message: MessageBuilderFactoryImpl.java MessageBuilderImpl.java
Date Sat, 24 Apr 2010 20:51:40 GMT
Author: bago
Date: Sat Apr 24 20:51:40 2010
New Revision: 937694

URL: http://svn.apache.org/viewvc?rev=937694&view=rev
Log:
Added MimeEntityConfig and MutableBodyDescriptorFactory configurations (setAttribute) to MessageBuilderFactory
so to be able most mime4j features without directly using the message package (MIME4J-175).

Modified:
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderFactoryImpl.java
    james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderImpl.java

Modified: james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderFactoryImpl.java
URL: http://svn.apache.org/viewvc/james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderFactoryImpl.java?rev=937694&r1=937693&r2=937694&view=diff
==============================================================================
--- james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderFactoryImpl.java
(original)
+++ james/mime4j/trunk/dom/src/main/java/org/apache/james/mime4j/message/MessageBuilderFactoryImpl.java
Sat Apr 24 20:51:40 2010
@@ -22,22 +22,48 @@ import org.apache.james.mime4j.MimeExcep
 import org.apache.james.mime4j.dom.MessageBuilder;
 import org.apache.james.mime4j.dom.MessageBuilderFactory;
 import org.apache.james.mime4j.storage.StorageProvider;
+import org.apache.james.mime4j.stream.MimeEntityConfig;
+import org.apache.james.mime4j.stream.MutableBodyDescriptorFactory;
 
+/**
+ * The default MessageBuilderFactory bundled with Mime4j.
+ * 
+ * Supports the "StorageProvider", "MimeEntityConfig" and "MutableBodyDescriptorFactory"
+ * attributes.
+ */
 public class MessageBuilderFactoryImpl extends MessageBuilderFactory {
 
     private StorageProvider storageProvider = null;
+    private MimeEntityConfig mimeEntityConfig = null;
+    private MutableBodyDescriptorFactory mutableBodyDescriptorFactory = null;
 
     @Override
     public MessageBuilder newMessageBuilder() throws MimeException {
-        return new MessageBuilderImpl(storageProvider);
+        MessageBuilderImpl m = new MessageBuilderImpl();
+        if (storageProvider != null) m.setStorageProvider(storageProvider);
+        if (mimeEntityConfig != null) m.setMimeEntityConfig(mimeEntityConfig);
+        if (mutableBodyDescriptorFactory != null) m.setMutableBodyDescriptorFactory(mutableBodyDescriptorFactory);
+        return m;
     }
 
     @Override
     public void setAttribute(String name, Object value)
             throws IllegalArgumentException {
-        if ("StorageProvider".equals(name) && value instanceof StorageProvider) {
-            this.storageProvider  = (StorageProvider) value;
-            return;
+        if ("StorageProvider".equals(name)) {
+            if (value instanceof StorageProvider) {
+                this.storageProvider  = (StorageProvider) value;
+                return;
+            } else throw new IllegalArgumentException("Unsupported attribute value type for
"+name+", expected a StorageProvider");
+        } else if ("MimeEntityConfig".equals(name)) {
+            if (value instanceof MimeEntityConfig) {
+                this.mimeEntityConfig = (MimeEntityConfig) value;
+                return;
+            } else throw new IllegalArgumentException("Unsupported attribute value type for
"+name+", expected a MimeEntityConfig");
+        } else if ("MutableBodyDescriptorFactory".equals(name)) {
+            if (value instanceof MutableBodyDescriptorFactory) {
+                this.mutableBodyDescriptorFactory  = (MutableBodyDescriptorFactory) value;
+                return;
+            } else throw new IllegalArgumentException("Unsupported attribute value type for
"+name+", expected a MutableBodyDescriptorFactory");
         }
             
         throw new IllegalArgumentException("Unsupported attribute: "+name);

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=937694&r1=937693&r2=937694&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
Sat Apr 24 20:51:40 2010
@@ -8,14 +8,21 @@ import org.apache.james.mime4j.codec.Dec
 import org.apache.james.mime4j.dom.Message;
 import org.apache.james.mime4j.dom.MessageBuilder;
 import org.apache.james.mime4j.storage.StorageProvider;
+import org.apache.james.mime4j.stream.MimeEntityConfig;
+import org.apache.james.mime4j.stream.MutableBodyDescriptorFactory;
 
+/**
+ * Default MessageBuilder implementation delegating Message parsing to the "legacy"
+ * MessageImpl object.
+ */
 public class MessageBuilderImpl extends MessageBuilder {
 
-    private StorageProvider storageProvider;
+    private StorageProvider storageProvider = null;
     private DecodeMonitor decodeMonitor = null;
+    private MimeEntityConfig mimeEntityConfig = null;
+    private MutableBodyDescriptorFactory mutableBodyDescriptorFactory = null;
 
-    public MessageBuilderImpl(StorageProvider storageProvider) {
-        this.storageProvider = storageProvider;
+    public MessageBuilderImpl() {
     }
 
     @Override
@@ -30,7 +37,7 @@ public class MessageBuilderImpl extends 
 
     @Override
     public Message parse(InputStream source) throws MimeException, IOException {
-        return new MessageImpl(source, null, storageProvider, null, decodeMonitor);
+        return new MessageImpl(source, mimeEntityConfig, storageProvider, mutableBodyDescriptorFactory,
decodeMonitor);
     }
 
     @Override
@@ -38,4 +45,17 @@ public class MessageBuilderImpl extends 
         this.decodeMonitor = decodeMonitor;
     }
 
+    public void setStorageProvider(StorageProvider storageProvider) {
+        this.storageProvider = storageProvider;
+    }
+
+    public void setMimeEntityConfig(MimeEntityConfig mimeEntityConfig) {
+        this.mimeEntityConfig = mimeEntityConfig;
+    }
+
+    public void setMutableBodyDescriptorFactory(
+            MutableBodyDescriptorFactory mutableBodyDescriptorFactory) {
+        this.mutableBodyDescriptorFactory  = mutableBodyDescriptorFactory;
+    }
+
 }



Mime
View raw message